def write_to_widget(self, representation, original=False): if representation == ambiguous: iter = self.combo_model.get_iter_first() else: iter = self.combo_model.get_iter(representation) self.combo_box.set_active_iter(iter) Edit.write_to_widget(self, representation, original)
def __init__(self, label_text=None, attribute_name=None, show_popup=True, history_name=None): Edit.__init__(self, label_text, attribute_name, show_popup, history_name)
def write_to_widget(self, representation, original=False): if representation == ambiguous: iter = self.list_store.get_iter_first() else: iter = self.list_store.get_iter(representation) self.list_selection.select_iter(iter) Edit.write_to_widget(self, representation, original)
def create_widgets(self): Edit.create_widgets(self) # create a model self.list_store = gtk.ListStore(gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT) self.list_view = gtk.TreeView(self.list_store) self.list_selection = self.list_view.get_selection() for index, (column_title, column_attribute) in enumerate(self.columns): text_cell_renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(column_title, text_cell_renderer) def data_func(column, cell, model, iter, i): cell.set_property("text", model.get_value(iter, 1)[i]) column.set_cell_data_func(text_cell_renderer, data_func, index) self.list_view.append_column(column) self.data_widget = gtk.ScrolledWindow() self.data_widget.set_shadow_type(gtk.SHADOW_IN) self.data_widget.add(self.list_view) self.data_widget.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.data_widget.set_size_request(-1, 250) self.can_ambiguous = False self.list_selection.connect('changed', self.on_widget_changed) for record in self.records: value = record.__dict__[self.attribute_name] iter = self.list_store.append([ value, [ record.__dict__[column_attribute] for column_title, column_attribute in self.columns ] ]) self.paths[id(value)] = self.list_store.get_path(iter)
def create_widgets(self): Edit.create_widgets(self) self.check_button = gtk.CheckButton() self.check_button.connect("toggled", self.on_widget_changed) self.check_button.connect("clicked", self.on_cb_clicked) self.check_button.add(self.label) self.data_widget = self.check_button
def write_to_widget(self, representation, original=False): if representation == ambiguous: self.check_button.set_active(False) self.check_button.set_inconsistent(True) else: self.check_button.set_inconsistent(False) self.check_button.set_active(representation) Edit.write_to_widget(self, representation, original)
def create_widgets(self): Edit.create_widgets(self) self.color_button = gtk.ColorButton() self.color_button.connect("color-set", self.on_widget_changed) self.color_child = self.color_button.get_child() self.ambiguous_label = gtk.Label(str(ambiguous)) self.ambiguous_label.show_all() self.data_widget = self.color_button
def write_to_widget(self, representation, original=False): self.color_button.remove(self.color_button.get_child()) if representation == ambiguous: self.color_button.add(self.ambiguous_label) else: self.color_button.add(self.color_child) self.color_button.set_color(gtk.gdk.Color(*representation)) Edit.write_to_widget(self, representation, original)
def __init__(self, choices, label_text=None, attribute_name=None, show_popup=True, history_name=None): Edit.__init__(self, label_text, attribute_name, show_popup, history_name) self.choices = choices self.paths = {}
def __init__(self, label_text=None, attribute_name=None, show_popup=True, history_name=None, width=250, height=300): Edit.__init__(self, label_text, attribute_name, show_popup, history_name) TextViewMixin.__init__(self, width, height)
def __init__(self, columns, label_text=None, attribute_name=None, show_popup=True, history_name=None): Edit.__init__(self, label_text, attribute_name, show_popup, history_name) self.columns = columns self.paths = {} self.records = []
def write_to_widget(self, representation, original=False): self.number = None self.bu_former = None for bu in self.buttons.itervalues(): bu.set_active(False) button = self.buttons.get(representation) if button is not None: self.bu_former = button button.set_active(True) else: self.number = ambiguous Edit.write_to_widget(self, representation, original)
def create_widgets(self): Edit.create_widgets(self) # create a model self.combo_model = gtk.ListStore(gobject.TYPE_PYOBJECT, gobject.TYPE_STRING) self.combo_box = gtk.ComboBox(self.combo_model) text_cell_renderer = gtk.CellRendererText() self.combo_box.pack_start(text_cell_renderer) self.combo_box.add_attribute(text_cell_renderer, "text", 1) self.combo_box.connect('changed', self.on_widget_changed) self.data_widget = self.combo_box self.can_ambiguous = False for value, label in self.choices: iter = self.combo_model.append([value, label]) self.paths[value] = self.combo_model.get_path(iter)
def create_widgets(self): Edit.create_widgets(self) self.buttons = {} ta_elements = gtk.Table(11, 19, homogeneous=True) ta_elements.set_row_spacings(0) ta_elements.set_col_spacings(0) # Use periodic to fill the table with buttons. for atom_info in periodic.atoms_by_number.itervalues(): bu_element = gtk.ToggleButton("") bu_element.set_property("can-focus", False) label = bu_element.get_child() label.set_label("<small>%s</small>" % atom_info.symbol) label.set_use_markup(True) bu_element.connect("toggled", self.on_bu_element_toggled, atom_info.number) bu_element.connect("toggled", self.on_widget_changed) tip = str(atom_info.number) + ": " + atom_info.name if atom_info.mass is not None: if atom_info.artificial: tip = tip + "\nMass = *%s" % express_measure( atom_info.mass, measure="Mass") else: tip = tip + "\nMass = %s" % express_measure(atom_info.mass, measure="Mass") if atom_info.vdw_radius is not None: tip = tip + "\nVan der Waals radius = " + express_measure( atom_info.vdw_radius, "Length") bu_element.set_tooltip_text(tip) ta_elements.attach(bu_element, int(atom_info.col), int(atom_info.col) + 1, int(atom_info.row), int(atom_info.row) + 1) self.buttons[atom_info.number] = bu_element # also add a few indicative labels for c, r, label_text in self.mendeljev_labels: indicative = gtk.Label("<b><small>" + label_text + "</small></b>") indicative.set_use_markup(True) ta_elements.attach(indicative, c, c + 1, r, r + 1) self.bu_former = None self.data_widget = ta_elements
def create_widgets(self): Edit.create_widgets(self) self.buttons = {} ta_elements = gtk.Table(11, 19, homogeneous=True) ta_elements.set_row_spacings(0) ta_elements.set_col_spacings(0) # Use periodic to fill the table with buttons. for atom_info in periodic.atoms_by_number.itervalues(): bu_element = gtk.ToggleButton("") bu_element.set_property("can-focus", False) label = bu_element.get_child() label.set_label("<small>%s</small>" % atom_info.symbol) label.set_use_markup(True) bu_element.connect("toggled", self.on_bu_element_toggled, atom_info.number) bu_element.connect("toggled", self.on_widget_changed) tip = str(atom_info.number) + ": " + atom_info.name if atom_info.mass is not None: if atom_info.artificial: tip = tip + "\nMass = *%s" % express_measure(atom_info.mass, measure="Mass") else: tip = tip + "\nMass = %s" % express_measure(atom_info.mass, measure="Mass") if atom_info.vdw_radius is not None: tip = tip + "\nVan der Waals radius = " + express_measure(atom_info.vdw_radius, "Length") bu_element.set_tooltip_text(tip) ta_elements.attach( bu_element, int(atom_info.col), int(atom_info.col) + 1, int(atom_info.row), int(atom_info.row) + 1 ) self.buttons[atom_info.number] = bu_element # also add a few indicative labels for c, r, label_text in self.mendeljev_labels: indicative = gtk.Label("<b><small>" + label_text + "</small></b>") indicative.set_use_markup(True) ta_elements.attach(indicative, c, c+1, r, r+1) self.bu_former = None self.data_widget = ta_elements
def write_to_widget(self, representation, original=False): TextViewMixin.write_to_widget(self, representation) Edit.write_to_widget(self, representation, original)
def destroy_widgets(self): TextViewMixin.destroy_widgets(self) Edit.destroy_widgets(self)
def create_widgets(self): Edit.create_widgets(self) TextViewMixin.create_widgets(self)
def destroy_widgets(self): self.color_button = None Edit.destroy_widgets(self)
def on_widget_changed(self, widget): Edit.on_widget_changed(self, widget) self.color_button.remove(self.color_button.get_child()) self.color_button.add(self.color_child)
def destroy_widgets(self): self.list_view = None self.paths = {} self.list_store = None Edit.destroy_widgets(self)
def destroy_widgets(self): self.check_button = None Edit.destroy_widgets(self)
def destroy_widgets(self): self.buttons = None self.bu_former = None Edit.destroy_widgets(self)
def destroy_widgets(self): self.combo_box = None self.paths = {} self.combo_model = None Edit.destroy_widgets(self)