我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用gi.repository.Gtk.TreeViewColumn()。
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__(self, window): Gtk.ScrolledWindow.__init__(self) # Parent window self._window = window # Tree view self._tree_view = Gtk.TreeView(Gtk.ListStore(int, int, str, str)) self._tree_view.set_headers_visible(False) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Message", renderer, text=2, background=3) self._tree_view.append_column(column) self._tree_view.connect("row-activated", self.on_row_activated) self.add(self._tree_view) self.show_all()
def create_relocs_columns(self): rendererPix = Gtk.CellRendererPixbuf() rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Name") column.set_spacing(5) column.pack_start(rendererPix, False) column.pack_start(rendererText, True) column.set_attributes(rendererText, text=1) column.set_attributes(rendererPix, pixbuf=0) column.set_sort_column_id(0) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Virtual Address", rendererText, text=2) self.store.set_sort_column_id(2,Gtk.SortType.ASCENDING) column.set_sort_column_id(2) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Size", rendererText, text=3) column.set_sort_column_id(3) self.append_column(column)
def create_exports_columns(self): rendererPix = Gtk.CellRendererPixbuf() rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Offset") column.set_spacing(5) column.pack_start(rendererPix, False) column.pack_start(rendererText, True) column.set_attributes(rendererText, text=1) column.set_attributes(rendererPix, pixbuf=0) self.store.set_sort_column_id(1,Gtk.SortType.ASCENDING) column.set_sort_column_id(1) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Name", rendererText, text=2) column.set_sort_column_id(2) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Ordinal", rendererText, text=3) column.set_sort_column_id(3) self.append_column(column) self.set_model(self.store)
def create_tree(self, imps): # Create the column imports = Gtk.TreeViewColumn() imports.set_title("Imports") imports.set_spacing(5) self.treestore = Gtk.TreeStore(GdkPixbuf.Pixbuf, str) rendererPix = Gtk.CellRendererPixbuf() rendererText = Gtk.CellRendererText() imports.pack_start(rendererPix, False) imports.pack_start(rendererText, True) imports.set_attributes(rendererText, text=1) imports.set_attributes(rendererPix, pixbuf=0) # Iterate imports and add to the tree for element in imps.keys(): it = self.treestore.append(None, [self.fcn_pix, element]) for imp in imps[element]: self.treestore.append(it, [self.imp_pix, imp[0] + '\t' + imp[1]]) # Add column to tree self.append_column(imports) self.set_model(self.treestore) self.expand_all()
def create_strings_columns(self): rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Address", rendererText, text=0) column.set_sort_column_id(0) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Size", rendererText, text=1) #self.store.set_sort_column_id(2,Gtk.SortType.ASCENDING) column.set_sort_column_id(1) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("String", rendererText, text=2) column.set_sort_column_id(2) self.append_column(column)
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.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 get_treeview_column(name, renderer, m_col, m_col_sort=None, resizable=False): """ A function used to generate a generic treeview column. :param str name: The name of the column. :param renderer: The Gtk renderer to be used for the column. :param m_col: The column position in the model. :param m_col_sort: The column to sort column data by. :param bool resizable: Decide whether the column should be resizable. :return: A TreeViewColumn Object with the desired setttings. """ tv_col = Gtk.TreeViewColumn(name) tv_col.pack_start(renderer, True) tv_col.add_attribute(renderer, 'text', m_col) tv_col.set_property('resizable', resizable) if m_col_sort is not None: tv_col.set_sort_column_id(m_col_sort) return tv_col
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 setup_download_queue(self): """ Setup the download queue""" renderer = Gtk.CellRendererText() name = Gtk.TreeViewColumn("Name",renderer,text=0) status = Gtk.TreeViewColumn("Status",renderer,text=0) progress = Gtk.TreeViewColumn("Progress",renderer,text=0) self.download_queue.append_column(name) self.download_queue.append_column(status) self.download_queue.append_column(progress)
def build_columns(self, treeview, **kwargs): """Build columns for Gtk treeview""" for i, item in enumerate(self.data): column = Gtk.TreeViewColumn( item.get("title"), item.get("render", Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END)), **{item.get("attr", "text"): i} ) column.set_visible(item.get("visible", True)) for k, v in kwargs.items(): column.set_property(k, v) treeview.append_column(column)
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 __init__(self): glade_dir = gv.jcchess.get_glade_dir() self.glade_file = os.path.join(glade_dir, "gamelist.glade") # create gamelist window self.builder = Gtk.Builder() self.builder.set_translation_domain(gv.domain) self.builder.add_from_file(self.glade_file) self.builder.connect_signals(self) self.window = self.builder.get_object("gamelist_window") self.treeview = self.builder.get_object("gamelist_treeview") self.liststore = self.builder.get_object("liststore1") cell0 = Gtk.CellRendererText() # cell0.set_property("cell-background", Gdk.color_parse("#F8F8FF")) tvcolumn0 = Gtk.TreeViewColumn() self.treeview.append_column(tvcolumn0) tvcolumn0.pack_start(cell0, True) tvcolumn0.set_min_width(50) tvcolumn0.set_attributes(cell0, text=0) self.treeview.connect("row_activated", self.entry_clicked) self.tree_selection = self.treeview.get_selection() self.window.hide() # user has closed the window # just hide it
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 __init__(self, model, dep_type, label): Gtk.TreeView.__init__(self) self.current = None self.dep_type = dep_type self.filter_model = model.filter_new() self.filter_model.set_visible_func(self._filter, data=None) self.set_model(self.filter_model) self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PACKAGE))
def __init__(self, model, label): Gtk.TreeView.__init__(self) self.current = None self.filter_model = model.filter_new() self.filter_model.set_visible_func(self._filter) self.set_model(self.filter_model) self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PARENT))
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 create_functions_columns(self): rendererText = Gtk.CellRendererText() rendererText.tooltip_handle = self.connect('motion-notify-event', self.fcn_tooltip) rendererPix = Gtk.CellRendererPixbuf() column = Gtk.TreeViewColumn("Function") column.set_spacing(5) column.pack_start(rendererPix, False) column.pack_start(rendererText, True) column.set_attributes(rendererText, text=1) column.set_attributes(rendererPix, pixbuf=0) column.set_sort_column_id(1) self.store.set_sort_column_id(1,Gtk.SortType.ASCENDING) self.append_column(column) self.set_model(self.store)
def create_sections_columns(self): rendererPix = Gtk.CellRendererPixbuf() rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Name") column.set_spacing(5) column.pack_start(rendererPix, False) column.pack_start(rendererText, True) column.set_attributes(rendererText, text=1) column.set_attributes(rendererPix, pixbuf=0) column.set_sort_column_id(0) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Virtual Address", rendererText, text=2) self.store.set_sort_column_id(2,Gtk.SortType.ASCENDING) column.set_sort_column_id(2) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Virtual Size", rendererText, text=3) column.set_sort_column_id(3) self.append_column(column) rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Raw Size", rendererText, text=4) column.set_sort_column_id(4) self.append_column(column) self.set_model(self.store)
def create_classes_columns(self): rendererText = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Name", rendererText, text=0) column.set_sort_column_id(0) self.append_column(column)
def on_row_activated( # pylint: disable=no-self-use self, treeview, treepath, column): '''Signal handler for activating a row in the browsing treeview :param treeview: The browsing treeview :type treeview: Gtk.TreeView object :param treepath: The path of the activated row in the browsing treeview :type treepath: Gtk.TreePath object :param column: The column of the activated row in the browsing treeview :type column: Gtk.TreeViewColumn object ''' if _ARGS.debug: sys.stdout.write( 'on_row_activated() %s %s %s\n' %(repr(treeview), repr(treepath), repr(column)))
def setColumns(Treeview, Title, MWIDTH,align): for i, column_title in enumerate(Title): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(column_title, renderer, text=i) column.set_sort_column_id(i) column.set_alignment(align) column.add_attribute(renderer, "background", len(Title)) column.set_property("min-width", MWIDTH) Treeview.set_property("can-focus",False) Treeview.append_column(column) # adding Scrollbar to the Treeview
def setColumnFrameBuffer(TreeFB,Title): for i, column_title in enumerate(Title): FBrenderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(column_title, FBrenderer, text=i) column.add_attribute(FBrenderer, "background", 25) if i < len(Title) - 1: FBrenderer.set_alignment(0.5, 0.5) column.set_alignment(0.5) column.set_property("min-width", 40) TreeFB.set_property("can-focus", False) TreeFB.append_column(column)
def setOclColumns(Treeview,Title): for i, column_title in enumerate(Title): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(column_title, renderer, text=i) column.add_attribute(renderer, "background", len(Title)) if i == 1: column.add_attribute(renderer, "foreground", len(Title) + 1) column.set_property("min-width", Const.MWIDTH) Treeview.set_property("can-focus", False) Treeview.append_column(column)
def __init__(self): builder = Gtk.Builder() builder.add_from_file("layout.glade") builder.connect_signals(self) window = builder.get_object("BrowserWindow") window.set_default_size(900, 675) self.url_bar = builder.get_object("UrlBar") self.refresh_button = builder.get_object("Refresh") self.history_forward = builder.get_object("HistoryForward") self.history_backward = builder.get_object("HistoryBackward") # create popup menu for browser tabs self.tab_menu = TabContextMenu(self) self.uni_menu = UniverseContextMenu(self) # tabs tracks the open BrowserTab objects self.tabs = {} self.focused = None self.tab_store = builder.get_object("TabTreeStore") self.tab_tree_view = builder.get_object("TabTreeView") self.tab_tree_view.set_activate_on_single_click(True) # stores a list of tab ID's, in order of call self.focus_history = [] # setup the treeview's renderer renderer = Gtk.CellRendererText() renderer.set_property("ellipsize", 3) self.title_column = Gtk.TreeViewColumn("Tab Title", renderer, text=0) self.tab_tree_view.append_column(self.title_column) self.tab_tree_view.connect("row_activated", self.tree_activates_tab) # self.views tracks all of the sockets self.views = builder.get_object("ViewPorts") window.show_all() # create a new tab self.new_tab("http://duckduckgo.com")
def __init__(self): Gtk.TreeView.__init__(self) self.task_store = Gtk.TreeStore(str, str) self.set_model(self.task_store) column = Gtk.TreeViewColumn(_('Tasks'), Gtk.CellRendererText(), text=0) self.append_column(column) self.connect('notify::tasks', self.tasks_changed)
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 __fill_listbox(self): self._list_store.clear() connections = self._manager.get_connections() for connection in connections: self._list_store.append([connection.label]) renderer = Gtk.CellRendererText() column = self._listbox.get_column(0) if not column: column = Gtk.TreeViewColumn(None, renderer, text=0) self._listbox.append_column(column) self._listbox.show_all() # noinspection PyUnusedLocal
def __row_activated(self, target: Gtk.TreeView, path: Gtk.TreePath, column: Gtk.TreeViewColumn): i = path.get_indices()[0] connection = self._manager.get_connection(i) self.__command_ssh.run(connection, connection.args)
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)
def __init__(self, header, cache, pkgnames, icons, icon_size, db): super(PackageNamesView, self).__init__() model = Gtk.ListStore(GdkPixbuf.Pixbuf, str) self.set_model(model) tp = Gtk.CellRendererPixbuf() column = Gtk.TreeViewColumn("Icon", tp, pixbuf=self.COL_ICON) self.append_column(column) tr = Gtk.CellRendererText() tr.set_property("ellipsize", Pango.EllipsizeMode.END) column = Gtk.TreeViewColumn(header, tr, markup=self.COL_TEXT) self.append_column(column) for pkgname in sorted(pkgnames): if (not pkgname in cache or not cache[pkgname].installed): continue s = "%s \n<small>%s</small>" % ( cache[pkgname].installed.summary.capitalize(), pkgname) app_details = Application("", pkgname).get_details(db) proposed_icon = app_details.icon if not proposed_icon or not icons.has_icon(proposed_icon): proposed_icon = Icons.MISSING_APP if icons.has_icon(proposed_icon): icon = icons.load_icon(proposed_icon, icon_size, 0) pb = icon.scale_simple( icon_size, icon_size, GdkPixbuf.InterpType.BILINEAR) else: LOG.warn("cant set icon for '%s' " % pkgname) pb = icons.load_icon(Icons.MISSING_APP, icon_size, Gtk.IconLookupFlags.GENERIC_FALLBACK) pb = pb.scale_simple(icon_size, icon_size, GdkPixbuf.InterpType.BILINEAR) model.append([pb, s]) # finally, we don't allow selection, it's just a simple display list tree_selection = self.get_selection() tree_selection.set_mode(Gtk.SelectionMode.NONE)
def _build_tree_view(self, model): for i, name in enumerate(self._COLUMN_NAMES): renderer = Gtk.CellRendererText() renderer.set_property("wrap-width", 200) column = Gtk.TreeViewColumn(name, renderer, markup=i) self.append_column(column) self.set_model(model) return
def init_bank_list_widget(self): self.bank_list_widget = self.gtk_builder.get_object('bank-list-trv') if self.bank_list_widget: self.bank_list_model = Gtk.ListStore(int, str, str, str) self.bank_list_widget.set_model(self.bank_list_model) # Note: column 0 contains program number but is not rendered column_loc = Gtk.TreeViewColumn('Loc.', Gtk.CellRendererText(), text=1) self.bank_list_widget.append_column(column_loc) column_changed = Gtk.TreeViewColumn('*', Gtk.CellRendererText(), text=2) self.bank_list_widget.append_column(column_changed) cell_name = Gtk.CellRendererText() cell_name.set_property('editable', True) column_name = Gtk.TreeViewColumn('Bank Name', cell_name, text=3) self.bank_list_widget.append_column(column_name) cell_name.connect('edited', self.on_prog_name_edited) self.bank_list_widget.connect('cursor_changed', self.select_program_from_ui) self.bank_list_widget.connect('button_press_event', self.popup_context_menu) else: self.bank_list_model = None print('Could not find widget for bank list')
def __init__(self): Gtk.Window.__init__(self, title='My Window Title') self.connect('delete-event', Gtk.main_quit) # Gtk.ListStore will hold data for the TreeView # Only the first two columns will be displayed # The third one is for sorting file sizes as numbers store = Gtk.ListStore(str, str, long) # Get the data - see below self.populate_store(store) treeview = Gtk.TreeView(model=store) # The first TreeView column displays the data from # the first ListStore column (text=0), which contains # file names renderer_1 = Gtk.CellRendererText() column_1 = Gtk.TreeViewColumn('File Name', renderer_1, text=0) # Calling set_sort_column_id makes the treeViewColumn sortable # by clicking on its header. The column is sorted by # the ListStore column index passed to it # (in this case 0 - the first ListStore column) column_1.set_sort_column_id(0) treeview.append_column(column_1) # xalign=1 right-aligns the file sizes in the second column renderer_2 = Gtk.CellRendererText(xalign=1) # text=1 pulls the data from the second ListStore column # which contains filesizes in bytes formatted as strings # with thousand separators column_2 = Gtk.TreeViewColumn('Size in bytes', renderer_2, text=1) # Mak the Treeview column sortable by the third ListStore column # which contains the actual file sizes column_2.set_sort_column_id(2) treeview.append_column(column_2) # Use ScrolledWindow to make the TreeView scrollable # Otherwise the TreeView would expand to show all items # Only allow vertical scrollbar scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy( Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled_window.add(treeview) scrolled_window.set_min_content_height(200) self.add(scrolled_window) self.show_all()
def __init__(self): glade_dir = gv.jcchess.get_glade_dir() self.glade_file = os.path.join(glade_dir, "move_list.glade") Move_List.move_list_ref = self self.comments = comments.get_ref() self.saved_move_list = [] # create move list window self.builder = Gtk.Builder() self.builder.set_translation_domain(gv.domain) self.builder.add_from_file(self.glade_file) self.builder.connect_signals(self) self.window = self.builder.get_object("move_list_window") self.vbox = self.builder.get_object("vbox1") #man self.treeview = Gtk.TreeView() #man self.liststore = self.builder.get_object("liststore1") self.scrolled_window = Gtk.ScrolledWindow() #self.scrolled_window.set_size_request(150,300) self.treeview.set_model(self.liststore) self.scrolled_window.add(self.treeview) self.vbox.add(self.scrolled_window) self.comments_button = self.builder.get_object("comments_button") #self.builder.connect("button_press_event",self.comments_button_clicked_cb) cell0 = Gtk.CellRendererText() # cell0.set_property("cell-background", Gdk.color_parse("#F8F8FF")) tvcolumn0 = Gtk.TreeViewColumn("#") self.treeview.append_column(tvcolumn0) tvcolumn0.pack_start(cell0, True) tvcolumn0.set_min_width(50) tvcolumn0.set_attributes(cell0, text=0) cell1 = Gtk.CellRendererText() # cell1.set_property("cell-background", Gdk.color_parse("#F8F8FF")) tvcolumn1 = Gtk.TreeViewColumn(_("Move")) self.treeview.append_column(tvcolumn1) tvcolumn1.pack_start(cell1, True) tvcolumn1.set_min_width(100) tvcolumn1.set_attributes(cell1, text=1) cell2 = Gtk.CellRendererText() # cell1.set_property("cell-background", Gdk.color_parse("#F8F8FF")) tvcolumn2 = Gtk.TreeViewColumn(_("Cmt")) self.treeview.append_column(tvcolumn2) tvcolumn2.pack_start(cell2, True) tvcolumn2.set_min_width(20) tvcolumn2.set_attributes(cell2, text=2) self.tree_selection = self.treeview.get_selection() self.treeview.connect("button_press_event", self.treeview_button_press) self.treeview.connect("key_press_event", self.treeview_key_press) self.update() # user has closed the window # just hide it
def __init__(self, parent): Gtk.Dialog.__init__(self, "Alarms", parent, 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)) self._store = Gtk.ListStore(str, str, str, object) for i, alarm in enumerate(config['alarms']): row = self._build_row(alarm) self._store.append(row) self._tree = Gtk.TreeView(self._store) self._selection = self._tree.get_selection() self._selection.connect("changed", self._on_tree_selection_changed) self._tree.set_size_request(300, 150) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Exchange", renderer, text=self._EXCHANGE_COL) self._tree.append_column(column) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Market", renderer, text=self._MARKET_COL) self._tree.append_column(column) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Alarm Trigger", renderer, text=self._TRIGGER_COL) self._tree.append_column(column) vbox = Gtk.Box(spacing=6, orientation=Gtk.Orientation.VERTICAL) new_button = Gtk.Button.new_with_label("New Alarm") new_button.connect("clicked", self._on_new_button_clicked) vbox.pack_start(new_button, False, False, 0) self._remove_button = Gtk.Button.new_with_label("Remove Alarm") self._remove_button.connect("clicked", self._on_remove_button_clicked) vbox.pack_start(self._remove_button, False, False, 0) self._market_combo, self._market_store = self._create_market_combo() self._market_combo.connect("changed", self._on_market_changed) vbox.pack_start(self._market_combo, False, False, 0) self._above_radio = Gtk.RadioButton.new_with_label_from_widget(None, "Above") self._above_radio.connect("clicked", self._on_type_radio_clicked) self._below_radio = Gtk.RadioButton.new_with_label_from_widget(self._above_radio, "Below") self._below_radio.connect("clicked", self._on_type_radio_clicked) type_hbox = Gtk.Box(spacing=6, orientation=Gtk.Orientation.HORIZONTAL) type_hbox.pack_start(self._above_radio, True, True, 0) type_hbox.pack_start(self._below_radio, True, True, 0) vbox.pack_start(type_hbox, False, False, 0) self._price_entry = Gtk.Entry() self._price_entry.connect("changed", self._on_price_changed) _add_label_and_widget(vbox, "Price:", self._price_entry) hbox = Gtk.Box(spacing=6) hbox.pack_start(self._tree, True, True, 0) hbox.pack_start(vbox, False, False, 0) self.get_content_area().add(hbox) self._set_inputs_sensitive(False) self.show_all()
def __init__(self): Gtk.Window.__init__(self) self.set_title("Dependency Explorer") self.set_default_size(500, 500) self.connect("delete-event", Gtk.main_quit) # Create the data models self.pkg_model = Gtk.ListStore(GObject.TYPE_STRING) self.pkg_model.set_sort_column_id(COL_PKG_NAME, Gtk.SortType.ASCENDING) self.depends_model = Gtk.ListStore(GObject.TYPE_INT, GObject.TYPE_STRING, GObject.TYPE_STRING) self.depends_model.set_sort_column_id(COL_DEP_PACKAGE, Gtk.SortType.ASCENDING) pane = Gtk.HPaned() pane.set_position(250) self.add(pane) # The master list of packages scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled.set_shadow_type(Gtk.ShadowType.IN) self.pkg_treeview = Gtk.TreeView(self.pkg_model) self.pkg_treeview.get_selection().connect("changed", self.on_cursor_changed) column = Gtk.TreeViewColumn("Package", Gtk.CellRendererText(), text=COL_PKG_NAME) self.pkg_treeview.append_column(column) pane.add1(scrolled) scrolled.add(self.pkg_treeview) box = Gtk.VBox(homogeneous=True, spacing=4) # Runtime Depends scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled.set_shadow_type(Gtk.ShadowType.IN) self.rdep_treeview = PackageDepView(self.depends_model, TYPE_RDEP, "Runtime Depends") self.rdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) scrolled.add(self.rdep_treeview) box.add(scrolled) # Build Depends scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled.set_shadow_type(Gtk.ShadowType.IN) self.dep_treeview = PackageDepView(self.depends_model, TYPE_DEP, "Build Depends") self.dep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) scrolled.add(self.dep_treeview) box.add(scrolled) pane.add2(box) # Reverse Depends scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled.set_shadow_type(Gtk.ShadowType.IN) self.revdep_treeview = PackageReverseDepView(self.depends_model, "Reverse Depends") self.revdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PARENT) scrolled.add(self.revdep_treeview) box.add(scrolled) pane.add2(box) self.show_all()
def __init__(self): Gtk.Window.__init__(self, title="EFI boot manager") self.set_border_width(10) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6) self.add(vbox) self.store = EFIStore(self) self.tree = Gtk.TreeView(self.store, vexpand=True) vbox.add(self.tree) renderer_text = Gtk.CellRendererText() renderer_check = Gtk.CellRendererToggle(radio=False) renderer_radio = Gtk.CellRendererToggle(radio=True) renderer_check.connect("toggled", self.store.change_active) renderer_radio.connect("toggled", self.store.change_boot_next) self.tree.append_column(Gtk.TreeViewColumn("BootNum", renderer_text, text=0)) self.tree.append_column(Gtk.TreeViewColumn("Name", renderer_text, text=1)) self.tree.append_column(Gtk.TreeViewColumn("Loader", renderer_text, text=2)) self.tree.append_column(Gtk.TreeViewColumn("Active", renderer_check, active=3)) self.tree.append_column(Gtk.TreeViewColumn("NextBoot", renderer_radio, active=4)) for column in self.tree.get_columns(): column.set_resizable(True) column.set_min_width(75) hb = Gtk.HeaderBar() hb.set_show_close_button(True) hb.props.title = "EFI boot manager" self.set_titlebar(hb) clear_btn = btn_with_icon("edit-clear-all-symbolic") clear_btn.connect("button-press-event", self.discard_changes) hb.pack_end(clear_btn) write_btn = btn_with_icon("document-save-symbolic") write_btn.connect("button-press-event", self.apply_changes) hb.pack_end(write_btn) hbox = Gtk.HButtonBox() hbox.set_layout(Gtk.ButtonBoxStyle.EXPAND) vbox.add(hbox) up = btn_with_icon("go-up-symbolic") down = btn_with_icon("go-down-symbolic") new = btn_with_icon("list-add-symbolic") delete = btn_with_icon("list-remove-symbolic") hbox.add(up) hbox.add(down) hbox.add(new) hbox.add(delete) up.connect("button-press-event", self.up) down.connect("button-press-event", self.down) new.connect("button-press-event", self.new) delete.connect("button-press-event", self.delete) self.connect("delete-event", self.quit) self.set_default_size(300, 260)
def __init__(self): Gtk.Dialog.__init__(self, _("GNU Solfege Preferences"), solfege.win, 0, (Gtk.STOCK_HELP, Gtk.ResponseType.HELP, Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)) cfg.ConfigUtils.__init__(self, 'configwindow') self.connect('response', self.apply_and_close) # We do this so that the window is only hidden when the # user click on the close button provided by the window manager. self.connect('delete-event', self.on_destroy)#lambda w, e: True) hbox = Gtk.HBox() hbox.set_spacing(gu.hig.SPACE_LARGE) hbox.set_border_width(gu.hig.SPACE_SMALL) self.vbox.pack_start(hbox, True, True, 0) frame = Gtk.Frame() self.g_pages = Gtk.TreeStore(str) self.g_pview = Gtk.TreeView(self.g_pages) self.g_pview.set_headers_visible(False) hbox.pack_start(frame, False, False, 0) frame.add(self.g_pview) self.g_page_box = Gtk.HBox() hbox.pack_start(self.g_page_box, True, True, 0) self.m_page_mapping = {} def cursor_changed(treeview): path, col = treeview.get_cursor() if not path: return path = tuple(path) for key, page in self.m_page_mapping.items(): if key == path: page.show() else: page.hide() self.m_page_mapping[path].show_all() tvcol = Gtk.TreeViewColumn("Col 0") self.g_pview.append_column(tvcol) cell = Gtk.CellRendererText() tvcol.pack_start(cell, True) tvcol.add_attribute(cell, 'text', 0) hbox.show_all() self.create_midi_config() self.create_user_config() self.create_external_programs_config() self.create_gui_config() self.create_practise_config() self.create_sound_config() self.create_statistics_config() self.g_pview.connect('cursor-changed', cursor_changed)
def create_idtone_accels_config(self, parent): it, page_vbox = self.new_page_box(parent, _("Identify tone keyboard accelerators")) self.g_idtone_accels = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING) notenames = ('c', 'cis', 'd', 'dis', 'e', 'f', 'fis', 'g', 'gis', 'a', 'ais', 'b') for notename in notenames: self.g_idtone_accels.append(( solfege.mpd.MusicalPitch.new_from_notename(notename).get_user_notename(), cfg.get_string('idtone/tone_%s_ak' % notename))) self.g_treeview = Gtk.TreeView(self.g_idtone_accels) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_("Note name"), renderer, text=0) self.g_treeview.append_column(column) renderer = Gtk.CellRendererAccel() renderer.set_property('editable', True) def acc_ff(renderer, path, accel_key, accel_mods, hw_key): is_unique = True for notename in notenames: if (notename != notenames[int(path)] and cfg.get_string('idtone/tone_%s_ak' % notename) == unichr(accel_key)): is_unique = False break if not is_unique: gu.dialog_ok(_(u"The accelerator in use for the tone “%s”. You have to choose another key.") % solfege.mpd.MusicalPitch.new_from_notename(notename).get_user_notename(), parent=self, msgtype=Gtk.MessageType.ERROR) return it = self.g_idtone_accels.get_iter(path) cfg.set_string('idtone/tone_%s_ak' % notenames[int(path)], unichr(accel_key)) self.g_idtone_accels.set(it, 1, unichr(accel_key)) return True renderer.connect('accel-edited', acc_ff) column = Gtk.TreeViewColumn(_i("keyboard|Key"), renderer, text=1) self.g_treeview.append_column(column) page_vbox.pack_start(self.g_treeview, True, True, 0) layouts = {'ascii': (_('ASCII'), u'awsedfujikol'), 'dvorak': (_('Dvorak'), u'a,o.eughctrn'), } hbox = Gtk.HBox() page_vbox.pack_start(hbox, False, False, 0) def set_buttons(widget, layout): v = layouts[layout][1] idx = 0 it = self.g_idtone_accels.get_iter_first() while True: self.g_idtone_accels.set_value(it, 1, v[idx]) cfg.set_string('idtone/tone_%s_ak' % notenames[idx], v[idx]) it = self.g_idtone_accels.iter_next(it) idx += 1 if not it: break for key in layouts: btn = Gtk.Button(layouts[key][0]) btn.connect('clicked', set_buttons, key) hbox.pack_start(btn, True, True, 0)
def create_interval_accels_config(self, parent): it, page_vbox = self.new_page_box(parent, _("Interval keyboard accelerators")) self.g_interval_accels = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING) intervals = ['minor2', 'major2', 'minor3', 'major3', 'perfect4', 'diminished5', 'perfect5', 'minor6', 'major6', 'minor7', 'major7', 'perfect8', 'minor9', 'major9', 'minor10', 'major10'] for interval in intervals: self.g_interval_accels.append(( mpd.Interval.new_from_int(intervals.index(interval)).get_name(), cfg.get_string('interval_input/%s' % interval))) self.g_intervals_treeview = Gtk.TreeView(self.g_interval_accels) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_("Interval"), renderer, text=0) self.g_intervals_treeview.append_column(column) renderer = Gtk.CellRendererAccel() renderer.set_property('editable', True) def acc_ff(renderer, path, accel_key, accel_mods, hw_key): is_unique = True for interval in intervals: if (interval != intervals[int(path)] and cfg.get_string('interval_input/%s' % interval) == unichr(accel_key)): is_unique = False break if not is_unique: gu.dialog_ok(_(u"The accelerator in use for “%s”. You have to choose another key.") % mpd.Interval.new_from_int(intervals.index(interval)).get_name(), parent=self, msgtype=Gtk.MessageType.ERROR) return it = self.g_interval_accels.get_iter(path) cfg.set_string('interval_input/%s' % intervals[int(path)], unichr(accel_key)) self.g_interval_accels.set(it, 1, unichr(accel_key)) return True renderer.connect('accel-edited', acc_ff) column = Gtk.TreeViewColumn(_i("keyboard|Key"), renderer, text=1) self.g_intervals_treeview.append_column(column) page_vbox.pack_start(self.g_intervals_treeview, True, True, 0) hbox = Gtk.HBox() page_vbox.pack_start(hbox, False, False, 0) layouts = {'ascii': (_('ASCII'), u'1qaz2wsx3edc4rfv'), 'dvorak': (_('Dvorak'), u"1'a;2,oq3.ej4puk"), } def set_buttons(widget, layout): v = layouts[layout][1] idx = 0 it = self.g_interval_accels.get_iter_first() while True: self.g_interval_accels.set_value(it, 1, v[idx]) cfg.set_string('interval_input/%s' % intervals[idx], v[idx]) it = self.g_interval_accels.iter_next(it) idx += 1 if not it: break for key in layouts: btn = Gtk.Button(layouts[key][0]) btn.connect('clicked', set_buttons, key) hbox.pack_start(btn, True, True, 0)
def __init__(self, default_profile): Gtk.Dialog.__init__(self, _("GNU Solfege - Choose User Profile")) # We save the initially selected profile, because we need to keep # track of it if the user renames it and then presses cancel. self.m_default_profile = default_profile vbox = gu.hig_dlg_vbox() self.vbox.pack_start(vbox, False, False, 0) l = Gtk.Label(_("Solfege will save your statistics and test results in the user profile. By adding additional user profiles to Solfege, multiple users can share a user account on the operating system.")) l.set_alignment(0.0, 0.5) l.set_line_wrap(True) vbox.pack_start(l, True, True, 0) hbox = Gtk.HBox() hbox.set_spacing(gu.hig.SPACE_MEDIUM) vbox.pack_start(hbox, True, True, 0) button_box = Gtk.VBox() self.g_create_profile = Gtk.Button.new_with_mnemonic(_(u"_Create profile\u2026")) self.g_create_profile.connect('clicked', self.on_create_profile) button_box.pack_start(self.g_create_profile, False, False, 0) self.g_rename_profile = Gtk.Button.new_with_mnemonic(_(u"_Rename profile\u2026")) self.g_rename_profile.connect('clicked', self.on_rename_profile) button_box.pack_start(self.g_rename_profile, False, False, 0) self.g_delete_profile = Gtk.Button.new_with_mnemonic(_(u"_Delete profile\u2026")) self.g_delete_profile.connect('clicked', self.on_delete_profile) button_box.pack_start(self.g_delete_profile, False, False, 0) hbox.pack_start(button_box, False, False, 0) self.g_liststore = liststore = Gtk.ListStore(GObject.TYPE_STRING) liststore.append((_("Standard profile"),)) if os.path.exists(os.path.join(filesystem.app_data(), 'profiles')): for subdir in os.listdir(os.path.join(filesystem.app_data(), 'profiles')): liststore.append((subdir,)) # self.g_tw = tw = Gtk.TreeView(liststore) tw.connect('row-activated', lambda a, b, c: self.response(Gtk.ResponseType.ACCEPT)) tw.set_headers_visible(False) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(None, renderer, text=0) tw.append_column(column) hbox.pack_start(tw, False, False, 0) tw.show() tw.connect('cursor-changed', self.on_cursor_changed) tw.set_cursor((0,)) for idx, s in enumerate(self.g_liststore): if s[0].decode("utf-8") == default_profile: tw.set_cursor((idx, )) # chk = gu.nCheckButton("app", "noprofilemanager", _("D_on't ask at startup")) vbox.pack_start(chk, False, False, 0) self.show_all()
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()