Python gi.repository.Gtk.CellRendererToggle() Examples
The following are 15
code examples of gi.repository.Gtk.CellRendererToggle().
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: 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 #2
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 #3
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 #4
Source File: compare_campaigns.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, *args, **kwargs): super(CampaignCompWindow, self).__init__(*args, **kwargs) self.comp_graph = CampaignGraphComparison(self.application, style_context=self.application.style_context) self.gobjects['scrolledwindow_compare'].add(self.comp_graph.canvas) self.gobjects['box_compare'].pack_end(self.comp_graph.navigation_toolbar, False, False, 0) self.comp_graph.navigation_toolbar.hide() treeview = self.gobjects['treeview_campaigns'] tvm = managers.TreeViewManager( treeview, cb_refresh=self.load_campaigns ) toggle_renderer = Gtk.CellRendererToggle() toggle_renderer.connect('toggled', self.signal_renderer_toggled) self.stack = self.gobjects['stack_main'] self.prev_child = self.stack.get_visible_child() b = Gtk.CellRendererText() tvm.set_column_titles( ('Compare', 'Name', 'Company', 'Type', 'Created By', 'Creation Date', 'Expiration'), column_offset=1, renderers=(toggle_renderer, b, b, b, b, b, b) ) self._model = Gtk.ListStore(str, bool, str, str, str, str, str, str) self._model.set_sort_column_id(2, Gtk.SortType.ASCENDING) treeview.set_model(self._model) self.load_campaigns() self.window.show()
Example #5
Source File: plugins.py From gtg with GNU General Public License v3.0 | 5 votes |
def _init_plugin_tree(self): """ Initialize the PluginTree Gtk.TreeView. The format is modelled after the one used in gedit; see http://git.gnome.org/browse/gedit/tree/gedit/gedit-plugin-mapnager.c """ # force creation of the Gtk.ListStore so we can reference it self._refresh_plugin_store() # renderer for the toggle column renderer = Gtk.CellRendererToggle() renderer.set_property('xpad', 6) renderer.connect('toggled', self.on_plugin_toggle) # toggle column column = Gtk.TreeViewColumn(None, renderer, active=PLUGINS_COL_ENABLED, activatable=PLUGINS_COL_ACTIVATABLE, sensitive=PLUGINS_COL_ACTIVATABLE) self.plugin_tree.append_column(column) # plugin name column column = Gtk.TreeViewColumn() column.set_spacing(6) # text renderer for the plugin name column name_renderer = Gtk.CellRendererText() name_renderer.set_property('ellipsize', Pango.EllipsizeMode.END) column.pack_start(name_renderer, True) column.set_cell_data_func(name_renderer, plugin_markup, self) self.plugin_tree.append_column(column) # finish setup self.plugin_tree.set_model(self.plugin_store) self.plugin_tree.set_search_column(2)
Example #6
Source File: layer_view.py From innstereo with GNU General Public License v2.0 | 5 votes |
def __init__(self, store): """ Initializes the TreeViewColumns and some special behaviour. Removes the headers, enables the tree-lines, turns the selection-mode to multiple. Adds a column for the toggle, the pixbuf and the name of the layer. """ Gtk.TreeView.__init__(self, model=store) self.store = store self.set_headers_visible(False) self.set_enable_tree_lines(True) self.select = self.get_selection() self.select.set_mode(Gtk.SelectionMode.MULTIPLE) self.set_property("can-focus", True) targets = [("text/plain", 0, 0)] self.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.MOVE) self.enable_model_drag_dest(targets, Gdk.DragAction.MOVE) self.renderer_activate_layer = Gtk.CellRendererToggle() self.column_activate_layer = Gtk.TreeViewColumn("", self.renderer_activate_layer, active=0) self.append_column(self.column_activate_layer) icon_renderer = Gtk.CellRendererPixbuf() icon_column = Gtk.TreeViewColumn("", icon_renderer, pixbuf=1) self.append_column(icon_column) self.renderer_name = Gtk.CellRendererText(weight=700, weight_set=True) self.column_name = Gtk.TreeViewColumn(_("Layer"), self.renderer_name, text=2) self.column_name.set_min_width(100) self.renderer_name.set_property("editable", True) self.column_name.set_resizable(True) self.append_column(self.column_name)
Example #7
Source File: io_data_port_list.py From RAFCON with Eclipse Public License 1.0 | 5 votes |
def register_view(self, view): """Called when the View was registered""" super(DataPortListController, self).register_view(view) view['name_col'].add_attribute(view['name_text'], 'text', self.NAME_STORAGE_ID) view['data_type_col'].add_attribute(view['data_type_text'], 'text', self.DATA_TYPE_NAME_STORAGE_ID) if not isinstance(self.model.state, LibraryState) and self.model.state.get_next_upper_library_root_state() is None: view['name_text'].set_property("editable", True) view['data_type_text'].set_property("editable", True) # in the linkage overview the the default value is not shown if isinstance(view, InputPortsListView) or isinstance(view, OutputPortsListView): view['default_value_col'].add_attribute(view['default_value_text'], 'text', self.DEFAULT_VALUE_STORAGE_ID) self._apply_value_on_edited_and_focus_out(view['default_value_text'], self._apply_new_data_port_default_value) view['default_value_col'].set_cell_data_func(view['default_value_text'], self._default_value_cell_data_func) if isinstance(self.model.state, LibraryState): view['default_value_col'].set_title("Used value") if self.model.state.get_next_upper_library_root_state() is None: # never enabled means it is disabled view['default_value_text'].set_property("editable", True) self._apply_value_on_edited_and_focus_out(view['name_text'], self._apply_new_data_port_name) self._apply_value_on_edited_and_focus_out(view['data_type_text'], self._apply_new_data_port_type) if isinstance(self.model.state, LibraryState): view['use_runtime_value_toggle'] = Gtk.CellRendererToggle() view['use_runtime_value_col'] = Gtk.TreeViewColumn("Use Runtime Value") view.make_column_title_elllipsable(view['use_runtime_value_col'], tooltip="If set, the default value to the left will be used as default "\ "value. Otherwise, the original default value of the library") view['use_runtime_value_col'].set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) view.get_top_widget().append_column(view['use_runtime_value_col']) view['use_runtime_value_col'].pack_start(view['use_runtime_value_toggle'], True) view['use_runtime_value_col'].add_attribute(view['use_runtime_value_toggle'], 'active', self.USE_RUNTIME_VALUE_STORAGE_ID) if self.model.state.get_next_upper_library_root_state() is None: view['use_runtime_value_toggle'].set_property("activatable", True) view['use_runtime_value_toggle'].connect("toggled", self.on_use_runtime_value_toggled) self._reload_data_port_list_store()
Example #8
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 #9
Source File: indicator.py From yandex-disk-indicator with GNU General Public License v3.0 | 5 votes |
def __init__(self, widget, parent, dcofig): # show current list self.dconfig = dcofig self.parent = parent Gtk.Dialog.__init__(self, title=_('Folders that are excluded from synchronization'), parent=parent, flags=1) self.set_icon(APPLOGO) self.set_size_request(400, 300) self.add_button(_('Add catalogue'), Gtk.ResponseType.APPLY).connect("clicked", self.addFolder, self) self.add_button(_('Remove selected'), Gtk.ResponseType.REJECT).connect("clicked", self.deleteSelected) self.add_button(_('Close'), Gtk.ResponseType.CLOSE).connect("clicked", self.exitFromDialog) self.exList = Gtk.ListStore(bool, str) view = Gtk.TreeView(model=self.exList) render = Gtk.CellRendererToggle() render.connect("toggled", self.lineToggled) view.append_column(Gtk.TreeViewColumn(" ", render, active=0)) view.append_column(Gtk.TreeViewColumn(_('Path'), Gtk.CellRendererText(), text=1)) scroll = Gtk.ScrolledWindow() scroll.add_with_viewport(view) self.get_content_area().pack_start(scroll, True, True, 6) # Populate list with paths from "exclude-dirs" property of daemon configuration self.dirset = [val for val in CVal(self.dconfig.get('exclude-dirs', None))] for val in self.dirset: self.exList.append([False, val]) # LOGGER.debug(str(self.dirset)) self.show_all()
Example #10
Source File: preferencesdialog.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def __init__(self, plugins): BrowserTreeView.__init__(self) model = PluginsTreeModel(plugins) self.set_model(model) cellrenderer = Gtk.CellRendererToggle() cellrenderer.connect('toggled', lambda o, p: model.do_toggle_path(p)) self.append_column( Gtk.TreeViewColumn(_('Enabled'), cellrenderer, active=1, activatable=2)) # T: Column in plugin tab self.append_column( Gtk.TreeViewColumn(_('Plugin'), Gtk.CellRendererText(), text=3)) # T: Column in plugin tab
Example #11
Source File: checkplacetitles.py From addons-source with GNU General Public License v2.0 | 4 votes |
def display(self): top_dialog = Glade() top_dialog.connect_signals({ "destroy_passed_object" : self.close, "on_ok_clicked" : self.on_ok_clicked, "on_help_clicked" : self.on_help_clicked, "on_delete_event" : self.close, }) window = top_dialog.toplevel self.set_window(window, top_dialog.get_object('title'), self.label) self.setup_configs('interface.changenames', 500, 450) self.clear_button = top_dialog.get_object('checkbutton1') self.copy_button = top_dialog.get_object('checkbutton2') self.tag_button = top_dialog.get_object('checkbutton3') self.treeview = top_dialog.get_object("list") self.r = Gtk.CellRendererToggle() self.r.set_property('activatable', True) self.r.set_property('radio', True) self.r.connect('toggled', self.toggled) c = Gtk.TreeViewColumn(_('Select'), self.r, active=1) self.treeview.append_column(c) c = Gtk.TreeViewColumn(_('Database'), Gtk.CellRendererText(),text=2) self.treeview.append_column(c) c = Gtk.TreeViewColumn(_('Display'), Gtk.CellRendererText(),text=3) self.treeview.append_column(c) self.selection = self.treeview.get_selection() self.model = Gtk.ListStore(str, bool, str, str) self.treeview.set_model(self.model) self.progress.set_pass(_('Building display'), len(self.name_list)) for handle, title, descr in self.name_list: self.model.append([handle, title == descr, title, descr]) self.progress.step() self.progress.close() self.show()
Example #12
Source File: __init__.py From ubuntu-cleaner with GNU General Public License v3.0 | 4 votes |
def setup_ui_tasks(self, widget): self.janitor_model.set_sort_column_id(self.JANITOR_NAME, Gtk.SortType.ASCENDING) #add janitor columns janitor_column = Gtk.TreeViewColumn() renderer = Gtk.CellRendererToggle() renderer.connect('toggled', self.on_janitor_check_button_toggled) janitor_column.pack_start(renderer, False) janitor_column.add_attribute(renderer, 'active', self.JANITOR_CHECK) self.janitor_view.append_column(janitor_column) janitor_column = Gtk.TreeViewColumn() renderer = Gtk.CellRendererPixbuf() janitor_column.pack_start(renderer, False) janitor_column.add_attribute(renderer, 'pixbuf', self.JANITOR_ICON) janitor_column.set_cell_data_func(renderer, self.icon_column_view_func, self.JANITOR_ICON) renderer = Gtk.CellRendererText() renderer.set_property('ellipsize', Pango.EllipsizeMode.END) janitor_column.pack_start(renderer, True) janitor_column.add_attribute(renderer, 'markup', self.JANITOR_DISPLAY) renderer = Gtk.CellRendererSpinner() janitor_column.pack_start(renderer, False) janitor_column.add_attribute(renderer, 'active', self.JANITOR_SPINNER_ACTIVE) janitor_column.add_attribute(renderer, 'pulse', self.JANITOR_SPINNER_PULSE) self.janitor_view.append_column(janitor_column) #end janitor columns #new result columns result_display_renderer = self.builder.get_object('result_display_renderer') result_display_renderer.set_property('ellipsize', Pango.EllipsizeMode.END) result_icon_renderer= self.builder.get_object('result_icon_renderer') self.result_column.set_cell_data_func(result_icon_renderer, self.icon_column_view_func, self.RESULT_ICON) #end new result columns self.scan_button.set_visible(not self.is_auto_scan()) self.update_model() self._expand_janitor_view() self.hpaned1.connect('notify::position', self.on_move_handle)
Example #13
Source File: plugin_selection.py From coinprice-indicator with MIT License | 4 votes |
def __init__(self, parent): Gtk.Window.__init__(self, title="Plugins") self.parent = parent self.set_keep_above(True) self.set_border_width(5) self.set_position(Gtk.WindowPosition.MOUSE) self.connect('key-release-event', self._on_key_release) grid = Gtk.Grid() grid.set_column_homogeneous(True) grid.set_row_homogeneous(True) self.add(grid) self.plugin_store = Gtk.ListStore(bool, str, object) for item in self.parent.EXCHANGES: self.plugin_store.append([item.active, item.name, item]) self.plugin_store.set_sort_column_id(1, Gtk.SortType.ASCENDING) self.view_plugins = Gtk.TreeView(self.plugin_store) rend_checkbox = Gtk.CellRendererToggle() rend_checkbox.connect("toggled", self._toggle) rend_plugin = Gtk.CellRendererText() col_chk = Gtk.TreeViewColumn("", rend_checkbox, active=0) col_plugin = Gtk.TreeViewColumn("Plugin", rend_plugin, text=1) # col_plugin.set_sort_column_id(0) self.view_plugins.append_column(col_chk) self.view_plugins.append_column(col_plugin) self.set_focus_child(self.view_plugins) sw = Gtk.ScrolledWindow() sw.set_vexpand(True) sw.add(self.view_plugins) grid.attach(sw, 0, 0, 100, 220) buttonbox = Gtk.Box(spacing=2) button_set = Gtk.Button('Select') button_set.connect("clicked", self._select_plugins) button_set.set_can_default(True) button_set.get_style_context().add_class(Gtk.STYLE_CLASS_SUGGESTED_ACTION) button_cancel = Gtk.Button('Close') button_cancel.connect("clicked", self._close) buttonbox.pack_start(button_set, True, True, 0) buttonbox.pack_start(button_cancel, True, True, 0) grid.attach(buttonbox, 0, 245, 100, 50) self.show_all() self.present()
Example #14
Source File: BTBrowserDialog.py From bcloud with GNU General Public License v3.0 | 4 votes |
def __init__(self, parent, app, title, source_url, save_path): '''初始化BT种子查询对话框. source_url - 如果是BT种子的话, 就是种子的绝对路径. 如果是磁链的话, 就是以magent:开头的磁链链接. ''' super().__init__(title, app.window, Gtk.DialogFlags.MODAL, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self.app = app self.source_url = source_url self.save_path = save_path self.set_default_response(Gtk.ResponseType.OK) self.set_default_size(520, 480) self.set_border_width(10) box = self.get_content_area() select_all_button = Gtk.ToggleButton.new_with_label(_('Select All')) select_all_button.props.halign = Gtk.Align.START select_all_button.props.margin_bottom = 5 select_all_button.connect('toggled', self.on_select_all_toggled) box.pack_start(select_all_button, False, False, 0) scrolled_win = Gtk.ScrolledWindow() box.pack_start(scrolled_win, True, True, 0) # check, name, size, humansize self.liststore = Gtk.ListStore(bool, str, GObject.TYPE_INT64, str) self.treeview = Gtk.TreeView(model=self.liststore) self.treeview.set_tooltip_column(NAME_COL) scrolled_win.add(self.treeview) check_cell = Gtk.CellRendererToggle() check_cell.connect('toggled', self.on_check_cell_toggled) check_col = Gtk.TreeViewColumn('', check_cell, active=CHECK_COL) self.treeview.append_column(check_col) name_cell = Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END, ellipsize_set=True) name_col = Gtk.TreeViewColumn(_('Name'), name_cell, text=NAME_COL) name_col.set_expand(True) self.treeview.append_column(name_col) size_cell = Gtk.CellRendererText() size_col = Gtk.TreeViewColumn(_('Size'), size_cell, text=HUMANSIZE_COL) self.treeview.append_column(size_col) box.show_all() self.request_data()
Example #15
Source File: tableeditor.py From zim-desktop-wiki with GNU General Public License v2.0 | 4 votes |
def _prepare_treeview_with_headcolumn_list(self, liststore): ''' Preparation of the treeview element, that displays the columns of the table :param liststore: model for current treeview :return: the treeview ''' treeview = Gtk.TreeView(liststore) # 1. Column - Title cell = Gtk.CellRendererText() cell.set_property('editable', True) column = Gtk.TreeViewColumn(_('Title'), cell, text=self.Col.title) column.set_min_width(120) treeview.append_column(column) cell.connect('edited', self.on_cell_changed, liststore, self.Col.title) cell.connect('editing-started', self.on_cell_editing_started, liststore, self.Col.title) # 2. Column - Wrap Line cell = Gtk.CellRendererToggle() cell.connect('toggled', self.on_wrap_toggled, liststore, self.Col.wrapped) column = Gtk.TreeViewColumn(_('Auto\nWrap'), cell) # T: table header treeview.append_column(column) column.add_attribute(cell, 'active', self.Col.wrapped) # 3. Column - Alignment store = Gtk.ListStore(str, str, str) store.append(COLUMNS_ALIGNMENTS['left']) store.append(COLUMNS_ALIGNMENTS['center']) store.append(COLUMNS_ALIGNMENTS['right']) column = Gtk.TreeViewColumn(_('Align')) # T: table header cellicon = Gtk.CellRendererPixbuf() column.pack_start(cellicon, True) column.add_attribute(cellicon, 'stock-id', self.Col.alignicon) cell = Gtk.CellRendererCombo() cell.set_property('model', store) cell.set_property('has-entry', False) cell.set_property('text-column', 2) cell.set_property('width', 50) cell.set_property('editable', True) column.pack_start(cell, True) column.add_attribute(cell, 'text', self.Col.aligntext) cell.connect('changed', self.on_alignment_changed, liststore) treeview.append_column(column) return treeview