Python gi.repository.Gtk.CellRendererText() Examples
The following are 30
code examples of gi.repository.Gtk.CellRendererText().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gi.repository.Gtk
, or try the search function
.
Example #1
Source File: widgets.py From badKarma with GNU General Public License v3.0 | 6 votes |
def __init__(self, database, host, *args, **kwargs): super(Historyview, self).__init__(*args, **kwargs) """ Single host's task history """ self.database = database self.host = host self.set_model(Gtk.ListStore(int, str, str, int, str)) self.history_liststore = self.get_model() for i, column_title in enumerate(["id","Started", "Ended", "Pid", "Task"]): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(column_title, renderer, text=i) self.append_column(column) self.show_all() self.refresh(self.database, self.host)
Example #2
Source File: handler.py From WattmanGTK with GNU General Public License v2.0 | 6 votes |
def __init__(self, builder, GPUs): self.builder = builder self.GPUs = GPUs self.GPU = GPUs[0] self.init_state = {} self.set_maximum_values() self.set_initial_values() self.init_state = self.create_state_dict() self.update_gui() # initialise GPU selection combobox textrenderer = Gtk.CellRendererText() self.gpustore = Gtk.ListStore(str) for i, card in enumerate(GPUs): self.gpustore.append([f"{i+1}: {card.fancyname}"]) combobox = self.builder.get_object("GPU Selection") combobox.set_model(self.gpustore) combobox.pack_start(textrenderer, True) combobox.add_attribute(textrenderer, "text", 0) combobox.set_entry_text_column(0) combobox.set_active(0) combobox.connect("changed", self.on_GPU_changed) # TODO implement POLKIT for writing as root, for now --> disable button self.builder.get_object("Lock").set_sensitive(False)
Example #3
Source File: backendstree.py From gtg with GNU General Public License v3.0 | 6 votes |
def _init_renderers(self): """Initializes the cell renderers""" # We hide the columns headers self.set_headers_visible(False) # For the backend icon pixbuf_cell = Gtk.CellRendererPixbuf() tvcolumn_pixbuf = Gtk.TreeViewColumn('Icon', pixbuf_cell) tvcolumn_pixbuf.add_attribute(pixbuf_cell, 'pixbuf', self.COLUMN_ICON) self.append_column(tvcolumn_pixbuf) # For the backend name text_cell = Gtk.CellRendererText() tvcolumn_text = Gtk.TreeViewColumn('Name', text_cell) tvcolumn_text.add_attribute(text_cell, 'markup', self.COLUMN_TEXT) self.append_column(tvcolumn_text) text_cell.connect('edited', self.cell_edited_callback) text_cell.set_property('editable', True) # For the backend tags tags_cell = Gtk.CellRendererText() tvcolumn_tags = Gtk.TreeViewColumn('Tags', tags_cell) tvcolumn_tags.add_attribute(tags_cell, 'markup', self.COLUMN_TAGS) self.append_column(tvcolumn_tags)
Example #4
Source File: backendstree.py From gtg with GNU General Public License v3.0 | 6 votes |
def cell_edited_callback(self, text_cell, path, new_text): """If a backend name is changed, it saves the changes in the Backend @param text_cell: not used. The Gtk.CellRendererText that emitted the signal. Only here because it's passed by the signal @param path: the Gtk.TreePath of the edited cell @param new_text: the new name of the backend """ # we strip everything not permitted in backend names new_text = ''.join(c for c in new_text if (c.isalnum() or c in [" ", "-", "_"])) selected_iter = self.liststore.get_iter(path) # update the backend name backend_id = self.liststore.get_value(selected_iter, self.COLUMN_BACKEND_ID) backend = self.dialog.get_requester().get_backend(backend_id) if backend: backend.set_human_name(new_text) # update the text in the liststore self.liststore.set(selected_iter, self.COLUMN_TEXT, new_text)
Example #5
Source File: plot.py From WattmanGTK with GNU General Public License v2.0 | 6 votes |
def init_treeview(self): textrenderer = Gtk.CellRendererText() self.plotrenderer = Gtk.CellRendererToggle() self.plotrenderer.connect("toggled", self.on_plot_toggled) self.normaliserenderer = Gtk.CellRendererToggle() self.normaliserenderer.connect("toggled", self.on_normalise_toggled) self.tree = self.builder.get_object("Signal Selection") self.tree.append_column(Gtk.TreeViewColumn("Plot", self.plotrenderer, active=0)) self.tree.append_column(Gtk.TreeViewColumn("Scale", self.normaliserenderer, active=1, activatable=2)) columnnames=["Name","Unit","min","mean","max","current"] for i,column in enumerate(columnnames): tcolumn = Gtk.TreeViewColumn(column,textrenderer,text=i+3,foreground=9) self.tree.append_column(tcolumn) for plotsignal in self.Plotsignals: self.signalstore.append([plotsignal.plotenable, plotsignal.plotnormalise, True, plotsignal.name, convert_to_si(plotsignal.unit)[0], '0', '0', '0', '0', plotsignal.plotcolor]) self.tree.set_model(self.signalstore)
Example #6
Source File: uistuff.py From pychess with GNU General Public License v3.0 | 6 votes |
def createCombo(combo, data=[], name=None, ellipsize_mode=None): if name is not None: combo.set_name(name) lst_store = Gtk.ListStore(Pixbuf, str) for row in data: lst_store.append(row) combo.clear() combo.set_model(lst_store) crp = Gtk.CellRendererPixbuf() crp.set_property('xalign', 0) crp.set_property('xpad', 2) combo.pack_start(crp, False) combo.add_attribute(crp, 'pixbuf', 0) crt = Gtk.CellRendererText() crt.set_property('xalign', 0) crt.set_property('xpad', 4) combo.pack_start(crt, True) combo.add_attribute(crt, 'text', 1) if ellipsize_mode is not None: crt.set_property('ellipsize', ellipsize_mode)
Example #7
Source File: DenominoViso.py From addons-source with GNU General Public License v2.0 | 6 votes |
def create_treeview(self, lstore, list_of_lists, editable_column = None): self.tv_w = Gtk.TreeView(model=lstore) self.tv_w.set_size_request(-1, 70) self.tv_w.get_selection().set_mode(Gtk.SelectionMode.SINGLE) self.tv_w_renderers = [] for i,v in enumerate(list_of_lists[0]): if (type(v) == type("string") or type(v) == type(1)): renderer = Gtk.CellRendererText() if editable_column or editable_column == 0: column = Gtk.TreeViewColumn('',renderer, text=i, \ editable = editable_column) else: column = Gtk.TreeViewColumn('',renderer, text=i) elif type(v) == type(False): renderer = Gtk.CellRendererToggle() column = Gtk.TreeViewColumn('',renderer, active=i) else: raise TypeError self.tv_w.append_column(column) self.tv_w_renderers.append(renderer)
Example #8
Source File: MediaVerify.py From addons-source with GNU General Public License v2.0 | 6 votes |
def create_tab(self, title): """ Create a page in the notebook. """ scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) view = Gtk.TreeView() column = Gtk.TreeViewColumn(_('Files')) view.append_column(column) cell = Gtk.CellRendererText() column.pack_start(cell, True) column.add_attribute(cell, 'text', 0) column.set_sort_column_id(0) column.set_sort_indicator(True) model = Gtk.ListStore(str, str) view.set_model(model) page = self.notebook.get_n_pages() view.connect('button-press-event', self.button_press, page) scrolled_window.add(view) self.models.append(model) self.views.append(view) label = Gtk.Label(title) self.notebook.append_page(scrolled_window, label)
Example #9
Source File: editform.py From addons-source with GNU General Public License v2.0 | 6 votes |
def build_interface(self): """ Builds the interface. """ self.model = Gtk.ListStore(str, str) self.view = Gtk.TreeView(model=self.model) self.selection = self.view.get_selection() renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_('Key'), renderer, text=0) self.view.append_column(column) renderer = Gtk.CellRendererText() renderer.set_property('editable', True) renderer.connect('edited', self.__cell_edited, (self.model, 1)) column = Gtk.TreeViewColumn(_('Value'), renderer, text=1) self.view.append_column(column) scrollwin = Gtk.ScrolledWindow() scrollwin.add(self.view) scrollwin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.pack_start(scrollwin, expand=True, fill=True, padding=0)
Example #10
Source File: combobox_enhanced.py From gtg with GNU General Public License v3.0 | 6 votes |
def smartifyComboboxEntry(combobox, list_obj, callback): entry = Gtk.Entry() # check if Clipboard contains an element of the list clipboard = Gtk.Clipboard() ifClipboardTextIsInListCallback(clipboard, list_obj, entry.set_text) # pressing Enter will cause the callback ifKeyPressedCallback(entry, "Return", callback) # wrap the combo-box if it's too long if len(list_obj) > 15: combobox.set_wrap_width(5) # populate the combo-box if len(list_obj) > 0: list_store = listStoreFromList(list_obj) entry.set_completion(completionFromListStore(list_store)) combobox.set_model(list_store) combobox.set_active(0) entry.set_text(list_store[0][0]) combobox.add(entry) combobox.connect('changed', setText, entry) # render the combo-box drop down menu cell = Gtk.CellRendererText() combobox.pack_start(cell, True) combobox.add_attribute(cell, 'text', 0) return entry
Example #11
Source File: actionbar.py From Audio-Cutter with GNU General Public License v3.0 | 6 votes |
def _setup_widgets(self): """Create/Setup the main widgets of the ActionBar.""" # Save Button self._save_btn.set_label(_("Save")) self._save_btn.connect("clicked", self._on_save) self._save_btn.get_style_context().add_class("suggested-action") self._save_btn.set_sensitive(False) self.pack_end(self._save_btn) # Output format Combo box model = Gtk.ListStore(str, str) for mimetype, desc in AUDIO_MIMES.items(): model.append([desc, mimetype]) renderer_text = Gtk.CellRendererText() self._output_format.pack_start(renderer_text, True) self._output_format.add_attribute(renderer_text, "text", 0) self._output_format.set_active(0) self._output_format.set_model(model) self._output_format.set_sensitive(False) self.pack_end(self._output_format)
Example #12
Source File: file_parser.py From innstereo with GNU General Public License v2.0 | 6 votes |
def create_treeview(self): """ Creates the viewport and adds it to the dialog window. The parsing dialog displays the parsing results in a TreeView. This requires setting up a TreeStore that has enough columns for a typical file to be imported. The TreeViewColumns are set up for text and appended to the TreeView. The TreeView is then added to to the ScrolledWindow defined in Glade. """ self.store = Gtk.ListStore(str, str, str, str, str, str, str, str) self.view = Gtk.TreeView(self.store) for x in range(8): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(str(x), renderer, text=x) column.set_alignment(0.5) column.set_expand(True) self.view.append_column(column) self.scr_win.add(self.view) self.dialog.show_all()
Example #13
Source File: gtk3ui.py From deluge-webapi with BSD 3-Clause "New" or "Revised" License | 6 votes |
def create_listview(self): self.model = Gtk.ListStore(str) self.list = self.builder.get_object('listview_allowed_domains') self.list.set_model(self.model) parent = self.list.get_parent() parent.remove(self.list) self.scrollTree = self.builder.get_object('scrolledwindow_allowed_domains') self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.scrollTree.add(self.list) column = Gtk.TreeViewColumn('domain', Gtk.CellRendererText(), text=0) column.set_clickable(True) column.set_resizable(True) self.list.append_column(column) self.selection = self.list.get_selection()
Example #14
Source File: custom.py From Dindo-Bot with MIT License | 6 votes |
def __init__(self, data_list=[], model=None, text_key=None, value_key=None, sort_key=None): Gtk.ComboBox.__init__(self) # set max chars width renderer_text = Gtk.CellRendererText() renderer_text.props.max_width_chars = 10 renderer_text.props.ellipsize = Pango.EllipsizeMode.END # append data if model is None: self.model = Gtk.ListStore(str, str) else: self.model = model self.append_list(data_list, text_key, value_key, sort_key) self.set_model(self.model) self.pack_start(renderer_text, True) self.add_attribute(renderer_text, 'text', 0) # save data list values (for further use) self.values = [ item[value_key] for item in data_list ]
Example #15
Source File: modification_history.py From RAFCON with Eclipse Public License 1.0 | 6 votes |
def __init__(self): View.__init__(self) Gtk.TreeView.__init__(self) foreground = 5 tvcolumn = Gtk.TreeViewColumn('Nr', Gtk.CellRendererText(), text=1, foreground=foreground) tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) self.append_column(tvcolumn) tvcolumn = Gtk.TreeViewColumn('Action', Gtk.CellRendererText(), text=2, foreground=foreground) tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) self.append_column(tvcolumn) tvcolumn = Gtk.TreeViewColumn('Parameters', Gtk.CellRendererText(), text=7, foreground=foreground) tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) self.append_column(tvcolumn) tvcolumn = Gtk.TreeViewColumn('Affects', Gtk.CellRendererText(), text=3, foreground=foreground) tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) # tvcolumn.set_min_width(150) self.append_column(tvcolumn) self['history_treeview'] = self self.top = 'history_treeview'
Example #16
Source File: semantic_data_editor.py From RAFCON with Eclipse Public License 1.0 | 6 votes |
def __init__(self): super(SemanticDataEditorView, self).__init__() self.scrollbar_widget = self['semantic_data_scroller'] self['delete_entry'].set_border_width(constants.BUTTON_BORDER_WIDTH) self['new_dict_entry'].set_border_width(constants.BUTTON_BORDER_WIDTH) self['new_entry'].set_border_width(constants.BUTTON_BORDER_WIDTH) tree_view = self["semantic_data_tree_view"] # prepare tree view columns key_renderer = Gtk.CellRendererText() key_renderer.set_property('editable', True) col = Gtk.TreeViewColumn('Key', key_renderer, text=self.KEY_STORAGE_ID) tree_view.append_column(col) value_renderer = Gtk.CellRendererText() value_renderer.set_property('editable', True) col = Gtk.TreeViewColumn('Value', value_renderer, text=self.VALUE_STORAGE_ID) tree_view.append_column(col) is_dict_renderer = Gtk.CellRendererText() col = Gtk.TreeViewColumn('Is Dict', is_dict_renderer, text=self.IS_DICT_STORAGE_ID) tree_view.append_column(col) gui_helper_label.ellipsize_labels_recursively(self['semantic_data_toolbar'])
Example #17
Source File: ObjectCollection.py From FlatCAM with MIT License | 5 votes |
def __init__(self): ### Icons for the list view self.icons = {} for kind in ObjectCollection.icon_files: self.icons[kind] = GdkPixbuf.Pixbuf.new_from_file(ObjectCollection.icon_files[kind]) ### GUI List components ## Model self.store = Gtk.ListStore(FlatCAMObj) ## View self.view = Gtk.TreeView(model=self.store) #self.view.connect("row_activated", self.on_row_activated) self.tree_selection = self.view.get_selection() self.change_subscription = self.tree_selection.connect("changed", self.on_list_selection_change) ## Renderers # Icon renderer_pixbuf = Gtk.CellRendererPixbuf() column_pixbuf = Gtk.TreeViewColumn("Type", renderer_pixbuf) def _set_cell_icon(column, cell, model, it, data): obj = model.get_value(it, 0) cell.set_property('pixbuf', self.icons[obj.kind]) column_pixbuf.set_cell_data_func(renderer_pixbuf, _set_cell_icon) self.view.append_column(column_pixbuf) # Name renderer_text = Gtk.CellRendererText() column_text = Gtk.TreeViewColumn("Name", renderer_text) def _set_cell_text(column, cell, model, it, data): obj = model.get_value(it, 0) cell.set_property('text', obj.options["name"]) column_text.set_cell_data_func(renderer_text, _set_cell_text) self.view.append_column(column_text)
Example #18
Source File: ParrentListSection.py From pychess with GNU General Public License v3.0 | 5 votes |
def addColumns(self, treeview, *columns, **keyargs): if "hide" in keyargs: hide = keyargs["hide"] else: hide = [] if "pix" in keyargs: pix = keyargs["pix"] else: pix = [] for i, name in enumerate(columns): if i in hide: continue if i in pix: crp = Gtk.CellRendererPixbuf() crp.props.xalign = .5 column = Gtk.TreeViewColumn(name, crp, pixbuf=i) else: crt = Gtk.CellRendererText() column = Gtk.TreeViewColumn(name, crt, text=i) column.set_resizable(True) column.set_sort_column_id(i) # prevent columns appear choppy column.set_sizing(Gtk.TreeViewColumnSizing.GROW_ONLY) column.set_reorderable(True) treeview.append_column(column)
Example #19
Source File: recipe-578773.py From code with MIT License | 5 votes |
def __init__(self): Gtk.Window.__init__(self, title='My Window Title') self.connect('delete-event', Gtk.main_quit) store = Gtk.ListStore(str, str) self.populate_store(store) self.treeview = Gtk.TreeView(model=store) renderer = Gtk.CellRendererText() column_name = Gtk.TreeViewColumn('Song Name', renderer, text=0) column_name.set_sort_column_id(0) self.treeview.append_column(column_name) column_artist = Gtk.TreeViewColumn('Artist', renderer, text=1) column_artist.set_sort_column_id(1) self.treeview.append_column(column_artist) scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy( Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled_window.add(self.treeview) scrolled_window.set_min_content_height(200) button = Gtk.Button('Delete Selected Row') button.connect('clicked', self.on_button_clicked) box = Gtk.Box() box.pack_start(scrolled_window, True, True, 1) box.pack_start(button, False, False, 1) self.add(box) self.show_all()
Example #20
Source File: colors_list.py From oomox with GNU General Public License v3.0 | 5 votes |
def __init__(self, display_name, key, options, callback): self.options = options options_store = Gtk.ListStore(str) for option in self.options: options_store.append([option.get('display_name', option['value'])]) dropdown = Gtk.ComboBox.new_with_model(options_store) renderer_text = Gtk.CellRendererText() dropdown.pack_start(renderer_text, True) dropdown.add_attribute(renderer_text, "text", 0) super().__init__( display_name=display_name, key=key, callback=callback, value_widget=dropdown ) self.remove(self.hbox) self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(self.vbox) self.vbox.add(self.hbox) self.description_label = Gtk.Label(xalign=1) self.description_label.set_margin_top(3) self.description_label.set_margin_bottom(7) self.description_label.set_state_flags(Gtk.StateFlags.INSENSITIVE, False)
Example #21
Source File: preset_list.py From oomox with GNU General Public License v3.0 | 5 votes |
def __init__(self, preset_select_callback): super().__init__() self.set_size_request(width=UI_SETTINGS.preset_list_minimal_width, height=-1) self.preset_select_callback = preset_select_callback self.treestore = Gtk.TreeStore(str, str, str, bool) self.treeview = Gtk.TreeView( model=self.treestore, headers_visible=False ) self.treeview.connect( "key-press-event", self._on_keypress ) self.treeview.connect( "row-collapsed", self._on_row_collapsed ) self.treeview.connect( "row-expanded", self._on_row_expanded ) column = Gtk.TreeViewColumn( cell_renderer=Gtk.CellRendererText(), markup=self.DISPLAY_NAME ) self.treeview.append_column(column) self.load_presets() self.add(self.treeview) GLib.idle_add( self.focus_first_available, priority=GLib.PRIORITY_HIGH ) ########################################################################### # Public interface: ###########################################################################
Example #22
Source File: cardexreport.py From amir with GNU General Public License v3.0 | 5 votes |
def __init__(self): self.builder = get_builder("cardex") self.window = self.builder.get_object("window1") self.treeview = self.builder.get_object("factorTreeView") self.treestore = Gtk.TreeStore( str, str, str, str, str, str, str, str, str) self.treeview.set_model(self.treestore) headers = (_("Date"), _("Type"), _("Quantity"), _("Unit Price"), _("Total Price"), _( "Remained"), _("Factor Code"), _("Customer Name"), _("Customer Code")) #headers = (_("Factor Code") ,_("Customer Code"), _("Customer Name"),_("Stock inventory"),_("Sell Quantity"),_("Buy Quantity") , _("Total Price"),_("Date") ) i = 0 for header in headers: column = Gtk.TreeViewColumn(header, Gtk.CellRendererText(), text=i) column.set_spacing(5) column.set_resizable(True) column.set_sort_column_id(i) column.set_sort_indicator(True) self.treeview.append_column(column) i += 1 self.rows = [] self.window.show_all() self.builder.connect_signals(self) self.session = share.config.db.session self.dateToEntry = self.builder.get_object("dateToEntry") self.dateFromEntry = self.builder.get_object("dateFromEntry") if share.config.datetypes[share.config.datetype] == "jalali": (year, month, day) = ("1397", "12", "20") else: (year, month, day) = ("2018", "12", "20") datelist = ["", "", ""] datelist[share.config.datefields["year"]] = year datelist[share.config.datefields["month"]] = month datelist[share.config.datefields["day"]] = day delimiter = share.config.datedelims[share.config.datedelim] placeH = datelist[0]+delimiter+datelist[1]+delimiter+datelist[2] self.dateToEntry.set_placeholder_text(placeH) self.dateFromEntry.set_placeholder_text(placeH) self.builder.get_object("typeComboBox").set_active(2)
Example #23
Source File: gui_utilities.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 5 votes |
def gtk_treeview_set_column_titles(treeview, column_titles, column_offset=0, renderers=None): """ Populate the column names of a GTK TreeView and set their sort IDs. :param treeview: The treeview to set column names for. :type treeview: :py:class:`Gtk.TreeView` :param list column_titles: The names of the columns. :param int column_offset: The offset to start setting column names at. :param list renderers: A list containing custom renderers to use for each column. :return: A dict of all the :py:class:`Gtk.TreeViewColumn` objects keyed by their column id. :rtype: dict """ columns = {} for column_id, column_title in enumerate(column_titles, column_offset): renderer = renderers[column_id - column_offset] if renderers else Gtk.CellRendererText() if isinstance(renderer, Gtk.CellRendererToggle): column = Gtk.TreeViewColumn(column_title, renderer, active=column_id) elif hasattr(renderer.props, 'python_value'): column = Gtk.TreeViewColumn(column_title, renderer, python_value=column_id) else: column = Gtk.TreeViewColumn(column_title, renderer, text=column_id) column.set_property('min-width', 25) column.set_property('reorderable', True) column.set_property('resizable', True) column.set_sort_column_id(column_id) treeview.append_column(column) columns[column_id] = column return columns
Example #24
Source File: ChannelsPanel.py From pychess with GNU General Public License v3.0 | 5 votes |
def __init__(self, icon): GObject.GObject.__init__(self) self.id2iter = {} pm = Gtk.ListStore(str, str, int, str) self.sort_model = Gtk.TreeModelSort(model=pm) self.set_model(self.sort_model) self.idSet = set() self.set_headers_visible(False) self.set_tooltip_column(3) self.set_search_column(1) self.sort_model.set_sort_column_id(1, Gtk.SortType.ASCENDING) self.sort_model.set_sort_func(1, self.compareFunction, 1) # First column crp = Gtk.CellRendererPixbuf() crp.props.pixbuf = icon self.rightcol = Gtk.TreeViewColumn("", crp) self.append_column(self.rightcol) # Second column crt = Gtk.CellRendererText() crt.props.ellipsize = Pango.EllipsizeMode.END self.leftcol = Gtk.TreeViewColumn("", crt, text=1) self.leftcol.set_expand(True) self.append_column(self.leftcol) # Mouse self.pressed = None self.stdcursor = Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR) self.linkcursor = Gdk.Cursor.new(Gdk.CursorType.HAND2) self.connect("button_press_event", self.button_press) self.connect("button_release_event", self.button_release) self.connect("motion_notify_event", self.motion_notify) self.connect("leave_notify_event", self.leave_notify) # Selection self.get_selection().connect("changed", self.selection_changed)
Example #25
Source File: enginesDialog.py From pychess with GNU General Public License v3.0 | 5 votes |
def __init__(self, model): GObject.GObject.__init__(self) self.data = None self.text_renderer = Gtk.CellRendererText() self.text_renderer.set_property("editable", True) self.text_renderer.connect("edited", self.text_edited_cb, model) self.toggle_renderer = Gtk.CellRendererToggle() self.toggle_renderer.set_property("activatable", True) self.toggle_renderer.set_property("xalign", 0) self.toggle_renderer.connect("toggled", self.toggled_cb, model) self.ro_toggle_renderer = Gtk.CellRendererToggle() self.ro_toggle_renderer.set_property("activatable", False) self.ro_toggle_renderer.set_property("xalign", 0) self.spin_renderer = Gtk.CellRendererSpin() self.spin_renderer.set_property("editable", True) self.spin_renderer.connect("edited", self.spin_edited_cb, model) self.combo_renderer = Gtk.CellRendererCombo() self.combo_renderer.set_property("has_entry", False) self.combo_renderer.set_property("editable", True) self.combo_renderer.set_property("text_column", 0) self.combo_renderer.connect("edited", self.text_edited_cb, model) self.button_renderer = Gtk.CellRendererText() self.button_renderer.set_property("editable", False)
Example #26
Source File: __init__.py From pychess with GNU General Public License v3.0 | 5 votes |
def get_save_dialog(export=False): savedialog = Gtk.FileChooserDialog( "", mainwindow(), Gtk.FileChooserAction.SAVE, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT)) savedialog.set_current_folder(os.path.expanduser("~")) # Add widgets to the savedialog savecombo = Gtk.ComboBox() savecombo.set_name("savecombo") crt = Gtk.CellRendererText() savecombo.pack_start(crt, True) savecombo.add_attribute(crt, 'text', 0) crt = Gtk.CellRendererText() savecombo.pack_start(crt, False) savecombo.add_attribute(crt, 'text', 1) if export: savecombo.set_model(exportformats) else: savecombo.set_model(saveformats) savecombo.set_active(1) # pgn savedialog.set_extra_widget(savecombo) return savedialog, savecombo
Example #27
Source File: LecturesPanel.py From pychess with GNU General Public License v3.0 | 5 votes |
def load(self, persp): self.persp = persp self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.tv = Gtk.TreeView() renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_("Title"), renderer, text=1) self.tv.append_column(column) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_("Author"), renderer, text=2) self.tv.append_column(column) self.tv.connect("row-activated", self.row_activated) self.store = Gtk.ListStore(str, str, str) for file_name, title, author in LECTURES: self.store.append([file_name, title, author]) self.tv.set_model(self.store) self.tv.get_selection().set_mode(Gtk.SelectionMode.BROWSE) self.tv.set_cursor(conf.get("learncombo%s" % LECTURE)) scrollwin = Gtk.ScrolledWindow() scrollwin.add(self.tv) scrollwin.show_all() self.box.pack_start(scrollwin, True, True, 0) self.box.show_all() return self.box
Example #28
Source File: outcomes.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
def on_to_outcome_edited(self, renderer, path, new_outcome_identifier): """Connects the outcome with a transition to the newly set outcome :param Gtk.CellRendererText renderer: The cell renderer that was edited :param str path: The path string of the renderer :param str new_outcome_identifier: An identifier for the new outcome that was selected """ if self.model.parent is None: return outcome_id = self.list_store[path][self.ID_STORAGE_ID] transition_parent_state = self.model.parent.state if outcome_id in self.dict_to_other_state or outcome_id in self.dict_to_other_outcome: if outcome_id in self.dict_to_other_state: t_id = self.dict_to_other_state[outcome_id][2] else: t_id = self.dict_to_other_outcome[outcome_id][2] if new_outcome_identifier is not None: new_to_outcome_id = int(new_outcome_identifier.split('.')[2]) if not transition_parent_state.transitions[t_id].to_outcome == new_to_outcome_id: to_state_id = self.model.parent.state.state_id try: transition_parent_state.transitions[t_id].modify_target(to_state=to_state_id, to_outcome=new_to_outcome_id) except ValueError as e: logger.warning("The target of transition couldn't be modified: {0}".format(e)) else: transition_parent_state.remove_transition(t_id) else: # there is no transition till now if new_outcome_identifier is not None: to_outcome = int(new_outcome_identifier.split('.')[2]) try: self.model.parent.state.add_transition(from_state_id=self.model.state.state_id, from_outcome=outcome_id, to_state_id=self.model.parent.state.state_id, to_outcome=to_outcome, transition_id=None) except (ValueError, TypeError) as e: logger.warning("The transition couldn't be added: {0}".format(e)) else: logger.debug("outcome-editor got None in to_outcome-combo-change no transition is added")
Example #29
Source File: execution_history.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
def __init__(self): View.__init__(self) Gtk.TreeView.__init__(self) self.set_name("history_tree") tvcolumn = Gtk.TreeViewColumn('History', Gtk.CellRendererText(), text=0) tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) self.append_column(tvcolumn) self['history_treeview'] = self self.top = 'history_treeview'
Example #30
Source File: state_machine_tree.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
def __init__(self): View.__init__(self) Gtk.TreeView.__init__(self) self.set_name('state_machine_tree') tvcolumn = Gtk.TreeViewColumn('Name') tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) # tvcolumn.set_min_width(150) self.append_column(tvcolumn) cell = Gtk.CellRendererText() tvcolumn.pack_start(cell, True) tvcolumn.add_attribute(cell, 'text', 0) tvcolumn.set_sort_column_id(0) tvcolumn = Gtk.TreeViewColumn('ID') tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) # tvcolumn.set_min_width(150) self.append_column(tvcolumn) cell = Gtk.CellRendererText() tvcolumn.pack_start(cell, True) tvcolumn.add_attribute(cell, 'text', 1) tvcolumn.set_sort_column_id(1) tvcolumn = Gtk.TreeViewColumn('Type') tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) # tvcolumn.set_min_width(150) self.append_column(tvcolumn) cell = Gtk.CellRendererText() tvcolumn.pack_start(cell, True) tvcolumn.add_attribute(cell, 'text', 2) tvcolumn.set_sort_column_id(2) self['state_machine_tree_view'] = self self.top = 'state_machine_tree_view'