我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gi.repository.Gtk.ListStore()。
def add_treeview(self): num_columns = [float for x in range(len(self.data.columns))] liststore = Gtk.ListStore(*num_columns) for ref in self.data.values.tolist(): liststore.append(ref) treeview = Gtk.TreeView.new_with_model(liststore) for i, column_title in enumerate(self.data.columns): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(column_title, renderer, text=i) treeview.append_column(column) self.scrollable_treelist = Gtk.ScrolledWindow() self.scrollable_treelist.add(treeview) self.scrollable_treelist.set_vexpand(True) self.scrollable_treelist.set_hexpand(True) self.verticalbox.pack_start(self.scrollable_treelist, True, True, 0) self.verticalbox.show_all()
def __init_txt_goto(self): completion = Gtk.EntryCompletion() store = Gtk.ListStore(str) artists_name = {x.Name for x in ArtistsPlaylist().collections()} albums_name = {x.Name for x in AlbumsPlaylist().collections()} for x in artists_name.union(albums_name): store.append([x]) completion.set_model(store) completion.set_text_column(0) completion.set_inline_completion(True) completion.set_match_func(self.__txt_goto_match_func) completion.set_inline_selection(True) completion.connect('match_selected', lambda x, y, z: self.__manage_goto()) self.txt_goto.set_completion(completion)
def __create_model(self): self.logger.info('Creating ListStore') start = time.perf_counter() model = AdapterSong.create_store() order = AbstractPlaylist.OrderBy[self.userconfig['grid']['sort']['field']] desc = self.userconfig['grid']['sort']['desc'] songs = self.current_playlist.collections(order, desc) for row in songs: model.insert_with_valuesv(-1, AdapterSong.create_col_number(), AdapterSong.create_row(row)) GObject.idle_add(lambda: self.__create_model_finished(model)) end = time.perf_counter() self.logger.info('ListStore created in {:.3f} seconds'.format(end - start))
def __init__(self, core, textviews): self.store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, str) super(TreeViews,self).__init__(self.store) self.uicore = core self.textviews = textviews self.set_rules_hint(True) self.set_has_tooltip(True) # Connect right click popup search menu self.popup_handler = self.connect('button-press-event', self.popup_menu) self.popup_handler = self.connect('row-activated', self.popup_menu) self.fcn_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('function.png')) self.bb_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('block.png')) self.data_sec_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('data-sec.png')) self.exp_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('export.png')) self.imp_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('import.png'))
def __init__(self, playlist, enable_web, transcoder, probe, preferred_transcoder, counter): self.win = Gtk.Window(type=Gtk.WindowType.TOPLEVEL) theme = Gtk.IconTheme.get_default() self.playimage = theme.load_icon("media-playback-start", 16,0) self.store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, int, int, str, str, str, str) self.selection_index = None self.create_model(playlist) if counter: self.store[counter][0] = self.playimage self.playlist_counter = None self.play_now = False self.playlist_changed = False self.double_clicked = False self.drag_index = None self.transcoder = transcoder self.number_clicked = 0 self.double_clicked_index = None self.probe = probe self.preferred_transcoder = preferred_transcoder self.enable_web = enable_web self.show_image = True self.sorted_index = None
def __create_gui(self): """ Create and display the GUI components of the gramplet. """ vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.model = Gtk.ListStore(object, str, int) view = Gtk.TreeView(self.model) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_("Person"), renderer, text=1) view.append_column(column) renderer = Gtk.CellRendererText() renderer.set_property('editable', True) renderer.connect('edited', self.__cell_edited) column = Gtk.TreeViewColumn(_("ID"), renderer, text=2) view.append_column(column) vbox.pack_start(view, expand=True, fill=True, padding=0) return vbox
def __init__(self, choices, change_handler=None): self.model = gtk.ListStore(GObject.TYPE_STRING) self._values = [] for label, value in choices: self.model.append((label,)) self._values.append(value) renderer = gtk.CellRendererText() self.control = gtk.ScrolledWindow() self.control.show() self._treeview = gtk.TreeView(self.model) self._treeview.show() self.control.add(self._treeview) self.control.set_shadow_type(gtk.ShadowType.ETCHED_OUT) self.control.set_policy(gtk.PolicyType.AUTOMATIC, gtk.PolicyType.AUTOMATIC) # Sadly there seems to be no way to adjust the size of the ScrolledWindow to its content. # The default size of the ScrolledWindow is too small (making it hard to select the model). self.control.set_size_request(200, -1) column = gtk.TreeViewColumn() column.pack_start(renderer, expand=False) column.set_attributes(renderer, text=0) self._treeview.append_column(column) self._treeview.set_headers_visible(False) self._selection = self._treeview.get_selection() self._selection.set_mode(gtk.SelectionMode.MULTIPLE) self.connect("changed", change_handler, self._selection)
def create_window(self): self.dialog = Gtk.Dialog(None, None, Gtk.DialogFlags.MODAL) self.dialog.set_decorated(False) # scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_can_focus(False) scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow.set_shadow_type(Gtk.ShadowType.ETCHED_OUT) self.dialog.vbox.pack_start(scrolledwindow, Gtk.AttachOptions.SHRINK, Gtk.AttachOptions.SHRINK,0) # self.store = Gtk.ListStore(str) for value in self.values: self.store.append([value]) self.tree = Gtk.TreeView(self.store) self.tree.set_headers_visible(False) self.tree.set_can_focus(False) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(title=None,cell_renderer=renderer, text=0) self.tree.append_column(column) # scrolledwindow.add(self.tree) self.tree.connect('focus-out-event',self.on_focus_out) self.dialog.connect('focus-out-event',self.on_focus_out) self.tree.connect('cursor-changed',self.on_cursor_changed) self.dialog.show_all()
def __init__(self): Gtk.ScrolledWindow.__init__(self) self.view = Gtk.IconView() self.list = Gtk.ListStore(Pixbuf, str) self.view.set_model(self.list) self.view.set_pixbuf_column(0) self.view.set_text_column(1) self.view.set_activate_on_single_click(True) self.view.set_item_width(100) self.menu = Gtk.Menu() copy = Gtk.MenuItem('Copy') copy.connect('activate', self.copy) paste = Gtk.MenuItem('Paste') paste.connect('activate', self.paste) self.menu.append(copy) self.menu.append(paste) self.view.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) self.view.connect('button-press-event', self.show_menu) self.view.set_vexpand(True) self.view.set_hexpand(True) self.add(self.view) self.view.connect('item-activated', self.row_activated)
def __init__(self): Gtk.ScrolledWindow.__init__(self) self.list = Gtk.ListStore(str, bool) self.view = Gtk.TreeView(self.list) self.view.set_hexpand(True) text_renderer = Gtk.CellRendererText() check_renderer = Gtk.CellRendererToggle() name_column = Gtk.TreeViewColumn('Gtk color list', text_renderer, text=0) check_column = Gtk.TreeViewColumn('', check_renderer, active=1) self.view.append_column(check_column) self.view.append_column(name_column) self.view.connect('row-activated', self.row_activated) self.add(self.view) names = ['active_text_color', 'inactive_text_color', 'active_text_shadow_color', 'inactive_text_shadow_color', 'active_border_color', 'inactive_border_color', 'active_color_1', 'active_color_2', 'active_highlight_1', 'active_highlight_2', 'active_mid_1', 'active_mid_2', 'active_shadow_1', 'active_shadow_2', 'inactive_color_1', 'inactive_color_2', 'inactive_highlight_1', 'inactive_highlight_2', 'inactive_mid_1', 'inactive_mid_2', 'inactive_shadow_1', 'inactive_shadow_2'] for name in names: self.list.append([name, False])
def __init__(self): super(CellRendererFadeWindow, self).__init__(title="CellRendererFade Example") self.set_default_size(200, 200) self.liststore = Gtk.ListStore(str, str) self.liststore.append(["New", Gtk.STOCK_NEW]) self.liststore.append(["Open", Gtk.STOCK_OPEN]) self.liststore.append(["Save", Gtk.STOCK_SAVE]) treeview = Gtk.TreeView(model=self.liststore) renderer_text = Gtk.CellRendererText() column_text = Gtk.TreeViewColumn("Text", renderer_text, text=0) treeview.append_column(column_text) renderer_pixbuf = CellRenderFade(param=0.001) column_pixbuf = Gtk.TreeViewColumn("Image", renderer_pixbuf, stock_id=1) treeview.append_column(column_pixbuf) self.add(treeview)
def __init__( self, manager: Manager, window_config: Window, command_ssh: AbstractCommand, command_edit: AbstractCommand ): self._listbox = None self._frame = None self._scrollable = None self._btn_reload = None self._btn_settings = None self._list_store = Gtk.ListStore(str) self.__command_ssh = command_ssh self.__command_edit = command_edit self._manager = manager self._window_config = window_config
def __init__(self, icons): super(OneConfViews, self).__init__() model = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING, GObject.TYPE_STRING) model.set_sort_column_id(self.COL_HOSTNAME, Gtk.SortType.ASCENDING) model.set_sort_func(self.COL_HOSTNAME, self._sort_hosts) self.set_model(model) self.set_headers_visible(False) self.col = Gtk.TreeViewColumn('hostname') hosticon_renderer = Gtk.CellRendererPixbuf() hostname_renderer = Gtk.CellRendererText() self.col.pack_start(hosticon_renderer, False) self.col.add_attribute(hosticon_renderer, 'pixbuf', self.COL_ICON) self.col.pack_start(hostname_renderer, True) self.col.add_attribute(hostname_renderer, 'text', self.COL_HOSTNAME) self.append_column(self.col) self.current_hostid = None self.hostids = [] # TODO: load the dynamic one (if present), later self.default_computer_icon = icons.load_icon("computer", 22, 0) self.connect("cursor-changed", self.on_cursor_changed)
def __init__(self, plants = (), show_text = False, selectable = True): super(PlantList, self).__init__() s = Gtk.ListStore(object, Pixbuf, str) self.set_model(s) self.set_pixbuf_column(1) if show_text: self.set_text_column(2) self.set_spacing(2) self.set_row_spacing(2) self.set_column_spacing(2) self.set_item_padding(2) self.set_item_width(40) if not selectable: self.set_selection_mode(Gtk.SelectionMode.NONE) self.set_plants(plants)
def build_store(self): """Build store for Gtk treeview""" return Gtk.ListStore(*[item.get("type") for item in self.data])
def __init__(self): Gtk.Window.__init__(self, title='My Window Title') self.connect('delete-event', Gtk.main_quit) store = Gtk.ListStore(str, str, str, str) self.populate_store(store) self.treeview = Gtk.TreeView(model=store) renderer = Gtk.CellRendererText() column_catalog = Gtk.TreeViewColumn('Catalog Name', renderer, text=0) column_catalog.set_sort_column_id(0) self.treeview.append_column(column_catalog) column_dbname = Gtk.TreeViewColumn('Database Name', renderer, text=1) column_dbname.set_sort_column_id(1) self.treeview.append_column(column_dbname) column_charset = Gtk.TreeViewColumn('Character Set', renderer, text=2) column_charset.set_sort_column_id(2) self.treeview.append_column(column_charset) column_collation = Gtk.TreeViewColumn('Collation', renderer, text=3) column_collation.set_sort_column_id(3) self.treeview.append_column(column_collation) 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) self.add(scrolled_window) self.show_all() # Add data to ListStore
def get_combobox(self): """ @description: get the combobox of the toolbar @return: a Gtk.Combobox """ # the data in the model, of type string listmodel = Gtk.ListStore(str) # append the data in the model listmodel.append(['All']) listmodel.append(['External']) listmodel.append(['Internal']) listmodel.append(['Modules']) # a combobox to see the data stored in the model combobox = Gtk.ComboBox(model=listmodel) combobox.set_tooltip_text("What type of command to add?") # a cellrenderer to render the text cell = Gtk.CellRendererText() # pack the cell into the beginning of the combobox, allocating # no more space than needed combobox.pack_start(cell, False) # associate a property ("text") of the cellrenderer (cell) to a column (column 0) # in the model used by the combobox combobox.add_attribute(cell, "text", 0) # the first row is the active one by default at the beginning combobox.set_active(0) # connect the signal emitted when a row is selected to the callback function combobox.connect("changed", self.on_combochanged) return combobox # callback function attach to the combobox
def __get_combobox(self, store, iter): """ @description: get the combobox of the toolbar @return: a Gtk.Combobox """ # the data in the model, of type string listmodel = Gtk.ListStore(str) # append the data in the model self.dic = {} self.dic[0] = 'time' listmodel.append(['time']) self.dic[1] = 'power' listmodel.append(['power']) self.dic[2] = 'clipboard' listmodel.append(['clipboard']) selected = 0 if iter is not None: for i in range(len(self.dic)): if self.dic[i] == store[iter][1]: selected = i # a combobox to see the data stored in the model combobox = Gtk.ComboBox(model=listmodel) combobox.set_tooltip_text("Which internal command to choose" + '?') # a cellrenderer to render the text cell = Gtk.CellRendererText() # pack the cell into the beginning of the combobox, allocating # no more space than needed combobox.pack_start(cell, False) # associate a property ("text") of the cellrenderer (cell) to a column (column 0) # in the model used by the combobox combobox.add_attribute(cell, "text", 0) # the first row is the active one by default at the beginning combobox.set_active(selected) return combobox
def __get_combobox(self): """ @description: get the combobox of the toolbar @return: a Gtk.Combobox """ # the data in the model, of type string listmodel = Gtk.ListStore(str) # append the data in the model selected = 4 i = 0 self.language_list = ['en-AU', 'en-CA', 'en-GB', 'en-IN', 'en-US'] for language_name in self.language_list: listmodel.append([language_name]) if language_name == self.locale: selected = i i += 1 # a combobox to see the data stored in the model combobox = Gtk.ComboBox(model=listmodel) combobox.set_tooltip_text("What format to choose?") # a cellrenderer to render the text cell = Gtk.CellRendererText() # pack the cell into the beginning of the combobox, allocating # no more space than needed combobox.pack_start(cell, False) # associate a property ("text") of the cellrenderer (cell) to a column (column 0) # in the model used by the combobox combobox.add_attribute(cell, "text", 0) # the first row is the active one by default at the beginning combobox.set_active(selected) # connect the signal emitted when a row is selected to the callback function combobox.connect("changed", self.on_combochanged) return combobox
def __get_rate_combobox(self): """ @description: get the sample rate combobox of the toolbar @return: a Gtk.Combobox """ # the data in the model, of type string listmodel = Gtk.ListStore(int) # append the data in the model selected = 0 i = 0 self.rate_list = [8000, 16000] for rate_name in self.rate_list: listmodel.append([rate_name]) if rate_name == self.audio_rate: selected = i i += 1 # a combobox to see the data stored in the model rate_combobox = Gtk.ComboBox(model=listmodel) rate_combobox.set_tooltip_text("Set Sampling Rate") # a cellrenderer to render the text rate_cell = Gtk.CellRendererText() # pack the cell into the beginning of the combobox, allocating # no more space than needed rate_combobox.pack_start(rate_cell, False) # associate a property ("text") of the cellrenderer (cell) to a column (column 0) # in the model used by the combobox rate_combobox.add_attribute(rate_cell, "text", 0) # the first row is the active one by default at the beginning rate_combobox.set_active(selected) # connect the signal emitted when a row is selected to the callback function rate_combobox.connect("changed", self.on_rate_combochanged) return rate_combobox
def __get_speaker_combobox(self): """ @description: get the speaker combobox of the toolbar @return: a Gtk.Combobox """ # the data in the model, of type string listmodel = Gtk.ListStore(str) # append the data in the model selected = 0 i = 0 self.speaker_list = ['Mama (Male)', 'His Wife (Female)'] for speaker_name in self.speaker_list: listmodel.append([speaker_name]) if speaker_name == self.speaker: selected = i i += 1 # a combobox to see the data stored in the model speaker_combobox = Gtk.ComboBox(model=listmodel) speaker_combobox.set_tooltip_text("Whose speaker to choose?") # a cellrenderer to render the text speaker_cell = Gtk.CellRendererText() # pack the cell into the beginning of the combobox, allocating # no more space than needed speaker_combobox.pack_start(speaker_cell, False) # associate a property ("text") of the cellrenderer (cell) to a column (column 0) # in the model used by the combobox speaker_combobox.add_attribute(speaker_cell, "text", 0) # the first row is the active one by default at the beginning speaker_combobox.set_active(selected) # connect the signal emitted when a row is selected to the callback function speaker_combobox.connect("changed", self.on_speaker_combochanged) return speaker_combobox
def setup_widgets(self): # Create self._icon = Gtk.Image() self._model = Gtk.ListStore(str, object, str) self._combo = Gtk.ComboBox.new_with_model(self._model) self._box = Gtk.Box(Gtk.Orientation.HORIZONTAL, 0) self._savebutton = None self._switch_to_button = None # Setup rend1 = Gtk.CellRendererText() rend2 = Gtk.CellRendererText() self._icon.set_margin_right(10) self._combo.pack_start(rend1, True) self._combo.pack_start(rend2, False) self._combo.add_attribute(rend1, "text", 0) self._combo.add_attribute(rend2, "text", 2) self._combo.set_row_separator_func( lambda model, iter : model.get_value(iter, 1) is None and model.get_value(iter, 0) == "-" ) self.update_icon() # Signals self._combo.connect('changed', self.on_combo_changed) self.connect("button_press_event", self.on_button_press) # Pack self._box.pack_start(self._icon, False, True, 0) self._box.pack_start(self._combo, True, True, 0) self.add(self._box)
def __init__(self): from playlist_creator import preferences_file_location, systems_list self.settings_file_location = preferences_file_location with open(self.settings_file_location) as data_file: self.preferences_data = json.load(data_file) builder = Gtk.Builder() builder.add_from_file("glade/app.glade") builder.connect_signals(self) self.notebook = builder.get_object("notebook") self.renderer_text = Gtk.CellRendererText() self.playlists_directory_chooser = builder.get_object("playlists_directory_chooser") self.cores_directory_chooser = builder.get_object("cores_directory_chooser") self.infos_directory_chooser = builder.get_object("infos_directory_chooser") self.playlists_location = self.preferences_data[0]['playlists_location'] self.cores_location = self.preferences_data[0]['cores_location'] self.infos_location = self.preferences_data[0]['infos_location'] self.playlists_directory_chooser.set_current_folder(self.playlists_location) self.cores_directory_chooser.set_current_folder(self.cores_location) self.infos_directory_chooser.set_current_folder(self.infos_location) self.system_names = Gtk.ListStore(str) for system_name in systems_list: self.system_names.append([system_name]) # get all cores and populate list self.__populate_cores_list__() if len(self.preferences_data) > 1: for system_from_prefs in self.preferences_data[1]: self.create_new_tab(system_from_prefs['system_name'], system_from_prefs['roms_dir'], system_from_prefs['core_path'], system_from_prefs['core_name']) window = builder.get_object("window") window.show_all() Gtk.main()
def __populate_cores_list__(self): self.cores_list = Gtk.ListStore(str) for core in sorted(os.listdir(self.cores_location)): self.cores_list.append([core])
def __init__(self): Gtk.Frame.__init__(self) self.sbrick = None self.set_label("SBrick Information") self.store = Gtk.ListStore(str, str) self.iterSBrickID = self.store.append(["SBrick BlueGiga ID", "--"]) self.iterHardwareVersion = self.store.append(["Hardware Version", "--"]) self.iterSoftwareVersion = self.store.append(["Software Version", "--"]) self.iterNeedAuthentication = self.store.append(["Need Authentication", "--"]) self.iterIsAuthenticated = self.store.append(["Is Authenticated", "--"]) self.iterAuthenticationTimeout = self.store.append(["Authentication Timeout", "--"]) self.iterInputVoltage = self.store.append(["Input Voltage", "--"]) self.iterTemperature = self.store.append(["Temperature", "--"]) self.iterPowerCycles = self.store.append(["Power Cycles", "--"]) self.iterWatchdogTimeout = self.store.append(["Watchdog Timeout", "--"]) self.iterUpTime = self.store.append(["Up Time", "--"]) self.iterThermalLimit = self.store.append(["Thermal Limit", "--"]) self.listView = Gtk.TreeView(self.store) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Item", renderer, text=0) self.listView.append_column(column) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Value", renderer, text=1) self.listView.append_column(column) self.scrollTree = Gtk.ScrolledWindow() self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.scrollTree.add_with_viewport(self.listView) self.scrollTree.set_min_content_height(100) self.add(self.scrollTree) self.set_sensitive(False)
def _create_market_combo(self): store = Gtk.ListStore(str, str, str) for market_config in config['markets']: provider = btcwidget.exchanges.factory.get(market_config['exchange']) market_name = '{} - {}'.format(provider.get_name(), market_config['market']) store.append([market_name, market_config['exchange'], market_config['market']]) combo = Gtk.ComboBox.new_with_model(store) renderer_text = Gtk.CellRendererText() combo.pack_start(renderer_text, True) combo.add_attribute(renderer_text, "text", 0) return combo, store
def __init__(self, window): self.window = window Gtk.ListStore.__init__(self, str, str, str, bool, bool) self.regex = re.compile("^Boot([0-9A-F]+)(\*)? (.+)\t(?:.+File\((.+)\))?.*$") self.refresh()
def __init__(self, builder): GObject.GObject.__init__(self) self._services = Gtk.ListStore(str, str, int) self._profile = None # Widgets self._panel = builder.get_object('server-panel') self._toolbar = builder.get_object('server-toolbar') # Zeroconf self._zeroconf_list = builder.get_object('server-zeroconf-list') self._zeroconf_list.set_model(self._services) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Zeroconf", renderer, text=0) self._zeroconf_list.append_column(column) # Host self._host_entry = builder.get_object('server-host') # Port self._port_spinner = builder.get_object('server-port') # Passwort self._password_entry = builder.get_object('server-password') # Image directory self._image_dir_entry = builder.get_object('server-image-dir') # Zeroconf provider self._zeroconf_provider = ZeroconfProvider() self._zeroconf_provider.connect_signal(ZeroconfProvider.SIGNAL_SERVICE_NEW, self.on_new_service)
def sComboBox(exname, name, strings): liststore = Gtk.ListStore(str) for s in strings: liststore.append([s]) g = Gtk.ComboBox.new_with_model_and_entry(liststore) g.set_entry_text_column(0) g.get_child().set_text(cfg.get_string("%s/%s" % (exname, name))) g.connect('changed', lambda w: cfg.set_string("%s/%s" % (exname, name), w.get_child().get_text().decode("utf-8"))) return g
def __init__(self, parent, app): super().__init__() self.parent = parent self.app = app # pixbuf, name, path, tooltip, size, humansize, # isdir, mtime, human mtime, type, pcs_file self.liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, GObject.TYPE_INT64, str, GObject.TYPE_INT, GObject.TYPE_INT64, str, str, str) self.init_ui()
def __init__(self, app): super().__init__(app, 'key_management', "Key Management") builder = self.get_builder() # XXX: Keeping state is bad but we can fix this later self._selected_keys = [] self._key_list_box = builder.get_object('lst_keys') self._refresh_key_list() self._keyserver_combo = builder.get_object('cmb_keyserver') # Populate keyserver list keyserver_list = Gtk.ListStore(str, str) for keyserver in Config.get_keyservers(): keyserver_list.append([keyserver, keyserver]) cell = Gtk.CellRendererText() self._keyserver_combo.pack_start(cell, True) self._keyserver_combo.add_attribute(cell, 'text', 1) self._keyserver_combo.set_model(keyserver_list) self._keyserver_combo.set_id_column(0) self._keyserver_combo.set_entry_text_column(1) # Set default keyserver self._keyserver_combo.set_active(0) self._edit_key_button = builder.get_object('btn_edit') self._upload_key_button = builder.get_object('btn_upload') self._export_key_button = builder.get_object('btn_export') self._delete_key_button = builder.get_object('btn_delete') self.add(builder.get_object('main_vbox')) self._update_button_state()
def add_gpg_keys_to_combo_box(combo_box, secret=False): gpg_keys_list = Gtk.ListStore(str, str) for key in GpgUtils.get_gpg_keys(secret): key_id = key[0] key_name = key[1] gpg_keys_list.append([key_id, key_name]) cell = Gtk.CellRendererText() combo_box.pack_start(cell, True) combo_box.add_attribute(cell, 'text', 1) combo_box.set_model(gpg_keys_list) combo_box.set_entry_text_column(1)
def __init_cmb_visualiser(self): store = Gtk.ListStore(str) for x in self.player.streamer.Visualizers: store.append([x]) self.cmb_visualiser.set_model(store)
def create_store(): model = Gtk.ListStore(str, str, str, str, str, str, str, str, str, str) model.set_default_sort_func(lambda *unused: 0) model.set_sort_column_id(Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, Gtk.SortType.ASCENDING) return model
def create_store(): model = Gtk.ListStore(str, str, str, str) model.set_default_sort_func(lambda *unused: 0) model.set_sort_column_id( Gtk.TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, Gtk.SortType.ASCENDING) return model
def __init__(self, core): self.store = Gtk.ListStore(str, str, str, str, str, str, str, str) super(InfoTree,self).__init__(self.store) self.uicore = core self.set_rules_hint(True) self.show_all()
def set_completion(self): # Seek entry EntryCompletion self.completion = Gtk.EntryCompletion() self.liststore = Gtk.ListStore(str) # Add function names to the list for function in self.uicore.allfuncs: self.liststore.append([function]) self.completion.set_model(self.liststore) self.seek.set_completion(self.completion) self.completion.set_text_column(0)
def populate_treeview(self, rows): """ Accepts an array of n rows made of 2 elements each, and returns a ListView.""" store = Gtk.ListStore(str, str) for row in rows: store.append([row[0], row[1]]) tv = Gtk.TreeView(store) tv.set_rules_hint(True) return tv
def __init__(self, core, textviews): self.store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, str) super(SectionsTreeView ,self).__init__(self.store) self.uicore = core self.textviews = textviews self.set_rules_hint(True) self.set_has_tooltip(True) self.create_sections_columns() # Connect right click popup search menu self.popup_handler = self.connect('row-activated', self.popup_menu)
def __init__(self, core, textviews): self.uicore = core self.textviews = textviews self.store = Gtk.ListStore(str, str, str) self.create_classes_columns()
def create_tree(self): # Scrolled Window self.sw = Gtk.ScrolledWindow() self.sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN) self.sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.store = Gtk.ListStore(str, str) self.tree = Gtk.TreeView(self.store) self.sw.add(self.tree) self.tree.set_rules_hint(True) # Connect right click popup search menu self.popup_handler = self.tree.connect('button-press-event', self.popup_menu) # Create the column bblocks = Gtk.TreeViewColumn() bblocks.set_title("Basic Blocks") cell = Gtk.CellRendererText() bblocks.pack_start(cell, True) bblocks.add_attribute(cell, "text", 0) self.treestore = Gtk.TreeStore(str) # Add column to tree self.tree.append_column(bblocks) self.tree.set_model(self.treestore) self.tree.expand_all()
def __init__(self, choices, start=None, change_handler=None): self.model = gtk.ListStore(GObject.TYPE_STRING) self._values = [] for label, value in choices: self.model.append((label, )) self._values.append(value) renderer = gtk.CellRendererText() self.control = gtk.ComboBox.new_with_model(self.model) self.control.pack_start(renderer, expand=False) self.control.add_attribute(renderer, 'text', 0) if start is None: self.control.set_active(0) else: self.set_value(start) self.connect("changed", change_handler)
def _build_widgets(self): """Generate the headerbar.""" header_bar = self._builder.get_object("headerbar") title = _("Comparing commits of {0}").format( self._git.get_project_name()) header_bar.set_title(title) self._stats = self._builder.get_object("stats") # Build list of modified files self._source = self._builder.get_object("source") files = self._git.get_modified() files.sort() liststore = Gtk.ListStore(str) for filename in files: liststore.append([filename]) combobox = self._builder.get_object("files") combobox.set_model(liststore) renderer_text = Gtk.CellRendererText() combobox.pack_start(renderer_text, True) combobox.add_attribute(renderer_text, "text", 0) combobox.set_active(0) # Load the buffer of the first file on the list self._set_buffer(files[0])
def load_combo(self): # Gateway combo model = Gtk.ListStore(str, str) #id, name selected_iter = None # load list of gateways gateway_info = [] try: with open('/usr/share/pia-manager/gateways.list.dynamic') as fp: gateway_info = fp.readlines() except IOError: with open('/usr/share/pia-manager/gateways.list') as fp: gateway_info = fp.readlines() for line in gateway_info: line = line.strip() if not line.startswith("#"): bits = line.split() if len(bits) >= 2: gateway_id = bits[0] gateway_name = " ".join(bits[1:]) iter = model.append([gateway_id, gateway_name]) if gateway_id == self.gateway_value: selected_iter = iter self.gateway.set_model(model) if selected_iter is not None: self.gateway.set_active_iter(selected_iter)
def set_up_completion(self): completion = self.gtk_completion = Gtk.EntryCompletion() self.completion_choices = Gtk.ListStore(str) self.completion_choices_as_set = set() completion.set_model(self.completion_choices) completion.set_text_column(0) if self.gtk_completion_enabled: self.set_completion(completion)
def __init__(self, config): self.config = config self.bhandlers = dict() # Create objects for alternative and prewiew self.alternatives = Prospector(config.get("Directories", "alternatives")) # Read icon size settins from config self.VIEW_ICON_SIZE = int(config.get("PreviewSize", "group")) # Load GUI self.builder = Gtk.Builder() self.builder.add_from_file(os.path.join(acyls.dirs['gui'], "alternatives.glade")) gui_elements = ( 'alternatives_grid', 'alt_theme_combo', 'alt_group_combo', 'alt_icon_view', ) self.gui = {element: self.builder.get_object(element) for element in gui_elements} # Mainpage buttnons hanlers self.mhandlers = dict() self.mhandlers['apply_button'] = self.on_apply_click # Build store self.store = Gtk.ListStore(Pixbuf) self.gui['alt_icon_view'].set_model(self.store) self.gui['alt_icon_view'].set_pixbuf_column(0) self.iconview_lock = TreeViewHolder(self.gui['alt_icon_view']) # Fill up GUI for name in self.alternatives.structure[0]['directories']: self.gui['alt_group_combo'].append_text(name.capitalize()) # connect signals self.gui['alt_group_combo'].connect("changed", self.on_alt_group_combo_changed) self.gui['alt_theme_combo'].connect("changed", self.on_alt_theme_combo_changed) # setup self.gui['alt_group_combo'].set_active(0) # GUI handlers
def __init__(self, config): self.bhandlers = dict() self.mhandlers = dict() # Create object for iconview self.iconview = Prospector(config.get("Directories", "real")) # Read icon size settins from config self.VIEW_ICON_SIZE = int(config.get("PreviewSize", "group")) # Load GUI self.builder = Gtk.Builder() self.builder.add_from_file(os.path.join(acyls.dirs['gui'], "viewer.glade")) gui_elements = ( 'iconview_grid', 'iconview_combo', 'icons_view', ) self.gui = {element: self.builder.get_object(element) for element in gui_elements} # Build store self.store = Gtk.ListStore(Pixbuf) self.gui['icons_view'].set_model(self.store) self.gui['icons_view'].set_pixbuf_column(0) self.iconview_lock = TreeViewHolder(self.gui['icons_view']) # Fill up GUI for name in self.iconview.structure[0]['directories']: self.gui['iconview_combo'].append_text(name.capitalize()) # connect signals self.gui['iconview_combo'].connect("changed", self.on_iconview_combo_changed) # setup self.gui['iconview_combo'].set_active(0) # GUI handlers
def build_data_stores(self): """Build stores for GUI dataviews""" self.store = dict() # custom icons self.ied = {'Name': 0, 'State': 1} self.store['custom_icons'] = Gtk.ListStore(str, bool) self.store['custom_icons'].append(["Simple Icon Group", False]) renderer_toggle = Gtk.CellRendererToggle() renderer_toggle.connect("toggled", self.on_custom_icon_toggled) self.gui['custom_icons_treeview'].append_column(Gtk.TreeViewColumn("Name", Gtk.CellRendererText(), text=0)) self.gui['custom_icons_treeview'].append_column(Gtk.TreeViewColumn("State", renderer_toggle, active=1)) self.gui['custom_icons_treeview'].set_model(self.store['custom_icons']) # color list self.ced = {'Color': 0, 'Alpha': 1, 'Offset': 2, 'RGBA': 3} colorstore_visible_keys = [k for k in self.ced.keys() if k != 'RGBA'] self.store['colorlist'] = Gtk.ListStore(str, float, int, str) for key in sorted(colorstore_visible_keys, key=lambda k: self.ced[k]): self.gui['colorlist_treeview'].append_column( Gtk.TreeViewColumn(key, Gtk.CellRendererText(), text=self.ced[key]) ) self.gui['colorlist_treeview'].set_model(self.store['colorlist']) # gradient direction self.ded = {'Coord': 0, 'Value': 1} self.store['direction'] = Gtk.ListStore(str, int) self.gui['renderer_spin'] = Gtk.CellRendererSpin(editable=True, adjustment=Gtk.Adjustment(0, 0, 100, 5, 0, 0)) self.signals['direction_edited'] = self.gui['renderer_spin'].connect("edited", self.on_direction_edited) self.gui['direction_treeview'].append_column(Gtk.TreeViewColumn("Coord", Gtk.CellRendererText(), text=0)) self.gui['direction_treeview'].append_column(Gtk.TreeViewColumn("Value", self.gui['renderer_spin'], text=1)) self.gui['direction_treeview'].set_model(self.store['direction'])
def run_query(self, query): try: for column in self.query_tree.get_columns(): self.query_tree.remove_column(column) cursor = self.conn.cursor() cursor.execute(query) self.conn.commit() self.query_info.set_text(cursor.statusmessage) if not cursor.description: return columns = [] # TODO get rid of manual incrementing i = 0 for description in cursor.description: renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(description.name.replace('_', '__'), renderer, text=i) column.set_resizable(True) i += 1 self.query_tree.append_column(column) columns.append(str) store = Gtk.ListStore(*columns) for row in cursor.fetchall(): store.append([str(i) for i in row]) self.query_tree.set_model(store) except DatabaseError as e: Alert(e.message, self.query_tree.get_toplevel()) self.conn.rollback() self.query_tree.show_all()
def refresh_schema(self): cursor = self.conn.cursor() cursor.execute('SELECT * FROM %s LIMIT 1' % self.table) for column in self.data_tree.get_columns(): self.data_tree.remove_column(column) self.columns = [] # TODO get rid of manual incrementing i = 0 for description in cursor.description: s = None if description.type_code == 16: renderer = Gtk.CellRendererToggle() self.columns.append(bool) column = Gtk.TreeViewColumn(description.name.replace('_', '__'), renderer, active=i) else: renderer = Gtk.CellRendererText() renderer.set_property('editable', True) renderer.connect('edited', self.on_text_edit, i) renderer.set_property('placeholder-text', 'Null') renderer.set_property('ellipsize', Pango.EllipsizeMode.END) self.columns.append(str) column = Gtk.TreeViewColumn(description.name.replace('_', '__'), renderer, text=i) column.set_clickable(True) column.set_resizable(True) column.set_fixed_width(100) if i == 0: # TODO Should this be here? self.order = description.name column.set_sort_indicator(True) column.set_sort_order(1) self.last_selected_column = column column.connect('clicked', self.on_column_click, description.name) self.data_tree.append_column(column) i += 1 self.store = Gtk.ListStore(*self.columns) self.data_tree.set_model(self.store)