def build(self): label = gtk.Label('Size:') self.pack_start(label, False, False, 2) self.width_spin = UnitSpin(self.user_changes) self.pack_start(self.width_spin, False, False, 0) label = gtk.Label('x') self.pack_start(label, False, False, 0) self.height_spin = UnitSpin(self.user_changes) self.pack_start(self.height_spin, False, False, 0) label = UnitLabel() self.pack_start(label, False, False, 2) self.keep_ratio = KeepRatioLabel() self.pack_start(self.keep_ratio, False, False, 5)
def multiply_dialog(parent): result = [] caption = _("Multiply selection") dialog = gtk.Dialog( caption, parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) dialog.set_icon(parent.get_icon()) dialog.set_default_size(200, 300) dialog.set_resizable(False) vbox = gtk.VBox(False, 5) vbox.set_border_width(5) dialog.vbox.pack_start(vbox, 15) #=========QUANTITY====================== frame1 = gtk.Frame(' Quantity ') frame1.set_border_width(5) tab1 = gtk.Table(2, 3, False) tab1.set_row_spacings(10) tab1.set_col_spacings(10) tab1.set_border_width(5) #-------------------------- label = gtk.Label(_('Horizontal:')) label.set_alignment(0, 0.5) tab1.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK) hu_adj = gtk.Adjustment(1.0, 1.0, 1000.0, 1.0, 1.0, 0.0) spinner = gtk.SpinButton(hu_adj, 0, 0) spinner.set_numeric(True) tab1.attach(spinner, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK) label = gtk.Label(_('units')) label.set_alignment(0, 0.5) tab1.attach(label, 2, 3, 0, 1, gtk.FILL, gtk.SHRINK) #-------------------------- label = gtk.Label(_('Vertical:')) label.set_alignment(0, 0.5) tab1.attach(label, 0, 1, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK) vu_adj = gtk.Adjustment(1.0, 1.0, 1000.0, 1.0, 1.0, 0.0) spinner = gtk.SpinButton(vu_adj, 0, 0) spinner.set_numeric(True) tab1.attach(spinner, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK) label = gtk.Label(_('units')) label.set_alignment(0, 0.5) tab1.attach(label, 2, 3, 1, 2, gtk.FILL, gtk.SHRINK) frame1.add(tab1) vbox.pack_start(frame1, 5) #===========SPACING==================== def callback(): pass frame2 = gtk.Frame(' Spacing ') frame2.set_border_width(5) tab2 = gtk.Table(2, 3, False) tab2.set_row_spacings(10) tab2.set_col_spacings(10) tab2.set_border_width(5) #-------------------------- label = gtk.Label(_('Horizontal:')) label.set_alignment(0, 0.5) tab2.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK) h_spinner = UnitSpin(callback) tab2.attach(h_spinner, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK) label = UnitLabel() label.set_alignment(0, 0.5) tab2.attach(label, 2, 3, 0, 1, gtk.FILL, gtk.SHRINK) #-------------------------- label = gtk.Label(_('Vertical:')) label.set_alignment(0, 0.5) tab2.attach(label, 0, 1, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK) v_spinner = UnitSpin(callback) tab2.attach(v_spinner, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK) label = UnitLabel() label.set_alignment(0, 0.5) tab2.attach(label, 2, 3, 1, 2, gtk.FILL, gtk.SHRINK) frame2.add(tab2) vbox.pack_start(frame2, 5) #=============================== dialog.show_all() ret = dialog.run() if ret == gtk.RESPONSE_OK: result = [ int(hu_adj.get_value()), int(vu_adj.get_value()), h_spinner.get_point_value(), v_spinner.get_point_value() ] dialog.destroy() return result
def __init__(self, app): gtk.VBox.__init__(self) self.app = app self.caption_label = gtk.Label(self.caption) spacer = gtk.VBox() self.add(spacer) self.set_border_width(15) self.set_size_request(385, 220) tab = gtk.Table(3, 2, False) tab.set_row_spacings(10) tab.set_col_spacings(10) spacer.add(tab) #--------------------------- label = gtk.Label(_('Plotter model:')) label.set_alignment(0, 0.5) tab.attach(label, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK) self.combo = gtk.combo_box_new_text() self.combo.connect('changed', self.combo_changed) items = plt_data.keys() items.sort() for item in items: self.combo.append_text(item) tab.attach(self.combo, 1, 2, 0, 1, gtk.SHRINK, gtk.SHRINK) #--------------------------- self.radiobut1 = gtk.RadioButton(None, _("Predefined model")) tab.attach(self.radiobut1, 0, 1, 1, 2, gtk.SHRINK, gtk.SHRINK) self.radiobut1.connect("toggled", self.radio_changed) self.radiobut2 = gtk.RadioButton(self.radiobut1, _("Custom model")) tab.attach(self.radiobut2, 1, 2, 1, 2, gtk.SHRINK, gtk.SHRINK) self.radiobut2.connect("toggled", self.radio_changed) #--------------------------- self.data_frame = gtk.Frame(_('Plotter data')) tab.attach(self.data_frame, 0, 2, 2, 3, gtk.FILL | gtk.EXPAND, gtk.SHRINK) data_tab = gtk.Table(3, 3, False) data_tab.set_border_width(15) data_tab.set_row_spacings(10) data_tab.set_col_spacings(10) self.data_frame.add(data_tab) #=========================== label = gtk.Label(_('Plotter model:')) label.set_alignment(1, 0.5) data_tab.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK) self.plt_name = gtk.Entry() self.plt_name.set_text(config.plotter_name) data_tab.attach(self.plt_name, 1, 3, 0, 1, gtk.FILL | gtk.EXPAND, gtk.SHRINK) #=========================== label = gtk.Label(_('Cutting width:')) label.set_alignment(1, 0.5) data_tab.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK) self.height_spin = UnitSpin(self.user_changes) self.height_spin.set_point_value(config.plotter_page_height) data_tab.attach(self.height_spin, 1, 2, 1, 2, gtk.SHRINK, gtk.SHRINK) unit_label = UnitLabel() unit_label.set_alignment(0, 0.5) data_tab.attach(unit_label, 2, 3, 1, 2, gtk.FILL | gtk.EXPAND, gtk.SHRINK) #=========================== label = gtk.Label(_('Cutting length:')) label.set_alignment(1, 0.5) data_tab.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.SHRINK) self.width_spin = UnitSpin(self.user_changes) self.width_spin.set_point_value(config.plotter_page_width) data_tab.attach(self.width_spin, 1, 2, 2, 3, gtk.SHRINK, gtk.SHRINK) unit_label = UnitLabel() unit_label.set_alignment(0, 0.5) data_tab.attach(unit_label, 2, 3, 2, 3, gtk.FILL | gtk.EXPAND, gtk.SHRINK) #=========================== if config.plotter_name in items and \ round(plt_data[config.plotter_name][0], 6) == round(config.plotter_page_height, 6) and \ round(plt_data[config.plotter_name][1], 6) == round(config.plotter_page_width, 6): self.combo.set_active(items.index(config.plotter_name)) self.radiobut1.set_active(True) self.data_frame.set_sensitive(False) else: self.radiobut2.set_active(True)