def _setMediasCells(self) -> None: """ Arrange the video, audio and snapshot cells. :return: """ # cell video, audio and snapshot to toggle renderer_video_toggle: CellRendererToggle = CellRendererToggle() column_toggle = TreeViewColumn(title='Video', cell_renderer=renderer_video_toggle, active=4) self._subtitles_treeview.append_column(column_toggle) renderer_video_toggle.connect("toggled", self._onCellVideoToggled) renderer_audio_toggle: CellRendererToggle = CellRendererToggle() column_toggle = TreeViewColumn(title='Audio', cell_renderer=renderer_audio_toggle, active=5) self._subtitles_treeview.append_column(column_toggle) renderer_audio_toggle.connect("toggled", self._onCellAudioToggled) renderer_snapshot_toggle: CellRendererToggle = CellRendererToggle() column_toggle = TreeViewColumn(title='Snapshot', cell_renderer=renderer_snapshot_toggle, active=6) self._subtitles_treeview.append_column(column_toggle) renderer_snapshot_toggle.connect("toggled", self._onCellImageToggled)
def _setTimerCells(self) -> None: """ Arrange the start and end timer cells. :return: """ # Making some cells editable 'Start' and 'End' respectivily editable_start_field: CellRendererText = CellRendererText() editable_end_field: CellRendererText = CellRendererText() editable_start_field.set_property('editable', True) editable_end_field.set_property('editable', True) self._subtitles_treeview.append_column( TreeViewColumn(title='Start', cell_renderer=editable_start_field, text=2)) self._subtitles_treeview.append_column( TreeViewColumn(title='End', cell_renderer=editable_end_field, text=3)) editable_start_field.connect('edited', self._startFieldEdited) editable_end_field.connect('edited', self._endFieldEdited)
def on_contents_toggle_expand_all(self, tvcol: Gtk.TreeViewColumn) -> bool: if tvcol.get_title() == '+': self.trvw_contents.expand_all() tvcol.set_title('-') else: self.trvw_contents.collapse_all() tvcol.set_title('+') return False
def columnas(titulo, celda, texto, resize, anchominimo=None, anchomaximo=None): col = TreeViewColumn(titulo, celda, text=texto) col.set_resizable(resize) # Columna puede cambiar de tamaño col.set_alignment(0.5) # Alineación del Título if anchominimo is not None: col.set_property('min-width', anchominimo) if anchomaximo is not None: col.set_property('max-width', anchomaximo) return col
def __init__(self): component.Component.__init__( self, 'QueuedTorrents', depend=['StatusBar', 'AddTorrentDialog'] ) self.queue = [] self.status_item = None self.config = ConfigManager('gtk3ui.conf') self.builder = Builder() self.builder.add_from_file( deluge.common.resource_filename( __package__, os.path.join('glade', 'queuedtorrents.ui') ) ) self.builder.get_object('chk_autoadd').set_active(self.config['autoadd_queued']) self.dialog = self.builder.get_object('queued_torrents_dialog') self.dialog.set_icon(get_logo(32)) self.builder.connect_signals(self) self.treeview = self.builder.get_object('treeview') self.treeview.append_column( TreeViewColumn(_('Torrent'), CellRendererText(), text=0) ) self.liststore = ListStore(str, str) self.treeview.set_model(self.liststore) self.treeview.set_tooltip_column(1)
def __init__(self, **kwargs): super(ReaderWindow, self).__init__( title='Eearth Reader', **kwargs ) app = self.get_application() assert isinstance(app, EarthReaderApp) self.set_wmclass('Earth Reader', 'Earth Reader') self.set_icon_list(ICON_LIST) self.box = Box(spacing=0) self.add(self.box) subscriptions = SubscriptionTreeModel(app.stage) self.subscriptions_sidebar = ScrolledWindow() self.subscription_list = TreeView(subscriptions) cell_renderer = CellRendererText() subscription_column = TreeViewColumn('Title', cell_renderer, text=0) def cell_data_func(column, renderer, model, tree_iter, *args): if isinstance(model[tree_iter], Category): renderer.set_property('cell-background', 'silver') else: renderer.set_property('cell-background', None) subscription_column.set_cell_data_func(cell_renderer, cell_data_func) self.subscription_list.append_column(subscription_column) self.subscriptions_sidebar.add(self.subscription_list) self.box.pack_start(self.subscriptions_sidebar, expand=True, fill=True, padding=0) entries_store = dummy_entries() entry_column = TreeViewColumn('Title', CellRendererText(), text=0) self.entry_list_box = ScrolledWindow() self.entry_list = TreeView(entries_store) self.entry_list.append_column(entry_column) self.entry_list_box.add(self.entry_list) self.box.pack_start(self.entry_list_box, expand=True, fill=True, padding=0) self.content_view = WebView() self.box.pack_start(self.content_view, expand=True, fill=True, padding=0)
def _setDialogCells(self) -> None: """ Arrange the dialogue and indice cell at the treeview. :return: """ for i, title in enumerate(['Indice', 'Dialog']): renderer: CellRendererText = CellRendererText() path_column: TreeViewColumn = TreeViewColumn( title=title, cell_renderer=renderer, text=i) if title == 'Dialog': path_column.set_sizing(TreeViewColumnSizing.FIXED) path_column.set_fixed_width(520) path_column.set_min_width(520) self._subtitles_treeview.append_column(path_column)
def cell_data_func(self, treeviewcolumn: Gtk.TreeViewColumn, cellrenderer: Optional[Gtk.CellRendererText], model: Gtk.ListStore, it: Gtk.TreeIter, data): pc = model[it][0] colid = treeviewcolumn.get_sort_column_id() if colid == 1: text = '{:.0f}'.format(pc.l1) elif colid == 2: text = '{:.0f}'.format(pc.l2) elif colid == 3: text = ', '.join(['{:.0f}'.format(e) for e in pc.l1_elements]) elif colid == 4: text = ', '.join(['{:.0f}'.format(e) for e in pc.l2_elements]) elif colid == 5: text = '{:.01f}'.format(pc.sd) elif colid == 6: text = '{:.0f}'.format(pc.D1) elif colid == 7: text = '{:.0f}'.format(pc.D2) elif colid == 8: text = '{:.2f}'.format(pc.alpha * 1000) elif colid == 9: text = '{:.2f}'.format(pc.Dsample) elif colid == 10: text = '{:.2f}'.format(pc.Dbs) elif colid == 11: text = '{:.4f}'.format(pc.qmin) elif colid == 12: text = '{:.1f}'.format(pc.dmax) elif colid == 13: text = '{:.1f}'.format(pc.Rgmax) elif colid == 14: text = '{:.1f}'.format(pc.dspheremax) elif colid == 15: text = '{:.0f}'.format(pc.D3) elif colid == 16: text = '{:.0f}'.format(pc.intensity) elif colid == 17: text = pc.dominant_constraint else: raise ValueError(colid) if cellrenderer is not None: cellrenderer.set_property('text', text) else: return text
def select(tree_column: Gtk.TreeViewColumn) -> Gtk.CellRenderer: return tree_column.get_cells()[position]
def __init__(self): super(PeersTab, self).__init__('Peers', 'peers_tab', 'peers_tab_label') self.peer_menu = self.main_builder.get_object('menu_peer_tab') component.get('MainWindow').connect_signals(self) self.listview = self.main_builder.get_object('peers_listview') self.listview.props.has_tooltip = True self.listview.connect('button-press-event', self._on_button_press_event) self.listview.connect('query-tooltip', self._on_query_tooltip) # flag, ip, client, downspd, upspd, country code, int_ip, seed/peer icon, progress self.liststore = ListStore(Pixbuf, str, str, int, int, str, float, Pixbuf, float) self.cached_flag_pixbufs = {} self.seed_pixbuf = icon_seeding self.peer_pixbuf = icon_downloading # key is ip address, item is row iter self.peers = {} # Country column column = TreeViewColumn() render = CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, 'pixbuf', 0) column.set_sort_column_id(5) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(20) column.set_reorderable(True) self.listview.append_column(column) # Address column column = TreeViewColumn(_('Address')) render = CellRendererPixbuf() column.pack_start(render, False) column.add_attribute(render, 'pixbuf', 7) render = CellRendererText() column.pack_start(render, False) column.add_attribute(render, 'text', 1) column.set_sort_column_id(6) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Client column column = TreeViewColumn(_('Client')) render = CellRendererText() column.pack_start(render, False) column.add_attribute(render, 'text', 2) column.set_sort_column_id(2) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Progress column column = TreeViewColumn(_('Progress')) render = CellRendererProgress() column.pack_start(render, True) column.set_cell_data_func(render, cell_data_peer_progress, 8) column.set_sort_column_id(8) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(100) column.set_reorderable(True) self.listview.append_column(column) # Down Speed column column = TreeViewColumn(_('Down Speed')) render = CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, cell_data_speed_down, 3) column.set_sort_column_id(3) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(50) column.set_reorderable(True) self.listview.append_column(column) # Up Speed column column = TreeViewColumn(_('Up Speed')) render = CellRendererText() column.pack_start(render, False) column.set_cell_data_func(render, cell_data_speed_up, 4) column.set_sort_column_id(4) column.set_clickable(True) column.set_resizable(True) column.set_expand(False) column.set_min_width(50) # Bugfix: Last column needs max_width set to stop scrollbar appearing column.set_max_width(150) column.set_reorderable(True) self.listview.append_column(column) self.listview.set_model(self.liststore) self.load_state() self.torrent_id = None
def __init__(self, emu: Optional[DeSmuME], debugger_controller: DebuggerController, builder: Gtk.Builder): self.emu = emu self.debugger = debugger_controller self.builder = builder self._was_running_last_sync = False self._files__sw: Gtk.ScrolledWindow = builder.get_object( 'ground_state_files_tree_sw') self._entities__sw: Gtk.ScrolledWindow = builder.get_object( 'ground_state_entities_tree_sw') self._files__not_loaded: Gtk.Viewport = builder.get_object( 'ground_state_files_tree_engine_not_loaded') self._entities__not_loaded: Gtk.Viewport = builder.get_object( 'ground_state_entities_tree_engine_not_loaded') self._ssb_tree_store_iters: Dict[int, Gtk.TreeIter] = {} self._files__tree: Gtk.TreeView = builder.get_object( 'ground_state_files_tree') icon = Gtk.CellRendererPixbuf() path = Gtk.CellRendererText() column = TreeViewColumn("Path") column.pack_start(icon, True) column.pack_start(path, True) column.add_attribute(icon, "icon_name", 0) column.add_attribute(path, "text", 1) self._files__tree.append_column(resizable(column)) self._files__tree.append_column( resizable(TreeViewColumn("Hanger", Gtk.CellRendererText(), text=3))) self._files__tree.append_column( resizable(TreeViewColumn("Type", Gtk.CellRendererText(), text=2))) self._entities__tree: Gtk.TreeView = builder.get_object( 'ground_state_entities_tree') #self._files__tree.append_column(resizable(TreeViewColumn("Preview", Gtk.CellRendererPixbuf(), xxx=4))) icon = Gtk.CellRendererPixbuf() debug_icon = Gtk.CellRendererPixbuf() slot_id = Gtk.CellRendererText() column = TreeViewColumn("ID") column.pack_start(icon, True) column.pack_start(debug_icon, True) column.pack_start(slot_id, True) column.add_attribute(debug_icon, "icon_name", 6) column.add_attribute(icon, "icon_name", 7) column.add_attribute(slot_id, "text", 0) self._entities__tree.append_column(resizable(column)) self._entities__tree.append_column( resizable(TreeViewColumn("Kind", Gtk.CellRendererText(), text=5))) self._entities__tree.append_column( resizable(TreeViewColumn("Hanger", Gtk.CellRendererText(), text=1))) self._entities__tree.append_column( resizable(TreeViewColumn("X", Gtk.CellRendererText(), text=8))) self._entities__tree.append_column( resizable(TreeViewColumn("Y", Gtk.CellRendererText(), text=9))) self._entities__tree.append_column( resizable(TreeViewColumn("Sector", Gtk.CellRendererText(), text=2))) self._entities__tree.append_column( resizable(TreeViewColumn("Script", Gtk.CellRendererText(), text=3))) self._files__tree_store: Gtk.TreeStore = builder.get_object( 'ground_state_files_tree_store') self._entities__tree_store: Gtk.TreeStore = builder.get_object( 'ground_state_entities_store')
def launch_playlist(wdg): self.widgets = wdg[1] self.playlist_label = self.widgets.get_object('label_playlist') self.playlist_repeat = self.widgets.get_object('tool-repeat') self.playlist_shuffle = self.widgets.get_object('tool-shuffle') self.playlist_clean = self.widgets.get_object('tool-clean') self.playlist_combo = self.widgets.get_object('combo-playlist') self.playlist_save = self.widgets.get_object('tool-saveplaylist') self.playlist_lyrics = self.widgets.get_object('tool-lyrics') self.playlist_tree = self.widgets.get_object('treeview_playlist') self.playlist_tree.set_headers_visible(False) self.playlist_tree.props.reorderable = True self.playlist_tree.connect('key_press_event', self.key_pressed) self.playlist_tree.connect('row_activated', self.row_activated) self.liststore = ListStore(str, str, str, str, int) self.playlist_tree.set_model(self.liststore) renderer_pix = CellRendererPixbuf() column_pixbuf = TreeViewColumn('1', renderer_pix, icon_name=0) column_pixbuf.set_fixed_width(18) self.playlist_tree.append_column(column_pixbuf) renderer_text = CellRendererText() column_text = TreeViewColumn('2', renderer_text, markup=1) column_text.props.expand = True column_text.props.max_width = 192 self.playlist_tree.append_column(column_text) column_text = TreeViewColumn('3', renderer_text, markup=2) column_text.set_fixed_width(40) self.playlist_tree.append_column(column_text) self.repeat_btn = self.widgets.get_object('tool-repeat') if self.config['repeat']: self.repeat_btn.set_active(True) self.repeat_btn.connect('clicked', self.toggle, 'repeat') self.shuffle_btn = self.widgets.get_object('tool-shuffle') if self.config['shuffle']: self.shuffle_btn.set_active(True) self.shuffle_btn.connect('clicked', self.toggle, 'shuffle') def clean_wdg(widget): # Clean playlist self.clean() # Show popover if self.current_playlist_id > 3: self.clean_btn.set_sensitive(True) self.clean_pop.show_all() self.clean_btn = self.widgets.get_object('tool-clean') self.clean_btn.connect('clicked', clean_wdg) self.clean_pop = Popover.new(self.clean_btn) self.clean_pop.set_size_request(100, 30) gtkpla = join(self.functions.datadir, 'glade', 'plist-del-pop.ui') win = gtk_builder() win.set_translation_domain('bluemindo') win.add_from_file(gtkpla) hbox = win.get_object('box-playlist') lbl = win.get_object('label') lbl.set_text(_('Do you also want to remove the playlist?')) btn = win.get_object('del-btn') btn.set_label(_('Delete')) btn.connect('clicked', self.delete_playlist) self.clean_pop.add(hbox) # Populate combobox self.combolist = ListStore(int, str) self.combobox = self.widgets.get_object('combobox') self.combobox.set_model(self.combolist) self.combobox.set_popup_fixed_width(False) self.combobox.props.expand = False renderer_text = CellRendererText() renderer_text.props.ellipsize = EllipsizeMode.END self.combobox.pack_start(renderer_text, True) self.combobox.set_entry_text_column(1) self.combobox.add_attribute(renderer_text, 'text', 1) self.combolist.append([0, _('Current')]) self.combolist.append([1, _('Top 50 songs')]) self.combolist.append([2, _('Top 10 albums')]) playlists = self.playlists_mgmnt.get_playlists() if len(playlists) > 0: self.combolist.append([3, '']) item_id = 3 playlists.sort(key=lambda it: it[1]) for item in playlists: item_id += 1 self.combolist.append([item_id, item]) self.user_playlists[item_id] = item self.last_user_playlist = item_id def combo_sep(model, iter): if model[iter][0] == 3: return True self.combobox.set_row_separator_func(combo_sep) def on_combo_changed(widget): path = widget.get_active() item_id = self.combolist[path][0] # First, clean the playlist self.clean(None) # Second, populate the playlist if item_id > 0: self.populate(item_id) # Then, update playlist identifier self.current_playlist_id = item_id # Show delete/remove button if the playlist is from the user if item_id > 3: self.clean_btn.set_sensitive(True) self.combobox.set_active(0) self.combobox.connect('changed', on_combo_changed) self.tool_save = self.widgets.get_object('tool-saveplaylist') self.tool_save.connect('clicked', self.save_playlist) self.save_pop = Popover.new(self.tool_save) self.save_pop.set_size_request(100, 30) gtkpla = join(self.functions.datadir, 'glade', 'plist-add-pop.ui') win = gtk_builder() win.set_translation_domain('bluemindo') win.add_from_file(gtkpla) hbox = win.get_object('box-playlist') self.save_pop.add(hbox) self.save_entry = win.get_object('save-entry') self.save_entry.connect('key_press_event', self.save_playlist_key) self.save_btn = win.get_object('save-btn') self.save_btn.connect('clicked', self.save_playlist_button) self.save_btn.set_label(_('Save')) self.clean_btn.set_sensitive(False) self.tool_save.set_sensitive(False)
def columna_active(titulo, act): col = TreeViewColumn(titulo, CellRendererToggle(), active=act) col.set_resizable(False) # Columna no puede cambiar de tamaño col.set_alignment(0.5) # Alineación del Título (centrado) col.set_property('min-width', 90) # Ancho Mínimo de Columna return col