Python gi.repository.Gtk.TreeView() Examples
The following are 30
code examples of gi.repository.Gtk.TreeView().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gi.repository.Gtk
, or try the search function
.
Example #1
Source File: library.py From vimiv with MIT License | 6 votes |
def file_select(self, treeview, path, column, close): """Show image or open directory for activated file in library. Args: treeview: The Gtk.TreeView which emitted the signal. path: Gtk.TreePath that was activated. column: Column that was activated. close: If True close the library when finished. """ # Empty directory if not path: self._app["statusbar"].message("No file to select", "error") return count = path.get_indices()[0] fil = self.files[count] self[os.getcwd()] = fil if os.getcwd() == self._app["tags"].directory: self._tag_select(fil, close) elif os.path.isdir(fil): # Open directory self.move_up(fil) else: self._image_select(fil, close)
Example #2
Source File: file_parser.py From innstereo with GNU General Public License v2.0 | 6 votes |
def create_treeview(self): """ Creates the viewport and adds it to the dialog window. The parsing dialog displays the parsing results in a TreeView. This requires setting up a TreeStore that has enough columns for a typical file to be imported. The TreeViewColumns are set up for text and appended to the TreeView. The TreeView is then added to to the ScrolledWindow defined in Glade. """ self.store = Gtk.ListStore(str, str, str, str, str, str, str, str) self.view = Gtk.TreeView(self.store) for x in range(8): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(str(x), renderer, text=x) column.set_alignment(0.5) column.set_expand(True) self.view.append_column(column) self.scr_win.add(self.view) self.dialog.show_all()
Example #3
Source File: file_parser.py From innstereo with GNU General Public License v2.0 | 6 votes |
def parse_file(self, start_line=0): """ Parses the file according to the settings and updates the TreeView. The old parsing result are cleared from the TreeStore. Then each row of the file is re-iterated and all rows before the starting row are omitted. The rows are passed to the append_data-method. """ self.store.clear() parse_file = open(self.file, "r") for key, line in enumerate(parse_file): if key < start_line: continue else: line = line.rstrip() string_list = re.split(r"[;,]", line) self.append_data(string_list)
Example #4
Source File: custom.py From Dindo-Bot with MIT License | 6 votes |
def __init__(self, model, columns): Gtk.Frame.__init__(self) self.perform_scroll = False self.model = model self.columns = columns self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(self.vbox) ## ScrolledWindow scrolled_window = Gtk.ScrolledWindow() self.vbox.pack_start(scrolled_window, True, True, 0) # TreeView self.tree_view = Gtk.TreeView(model) scrolled_window.add(self.tree_view) for column in columns: self.tree_view.append_column(column) self.tree_view.connect('size-allocate', self.scroll_tree_view) self.selection = self.tree_view.get_selection() self.selection.set_mode(Gtk.SelectionMode.SINGLE)
Example #5
Source File: dataview_classes.py From innstereo with GNU General Public License v2.0 | 6 votes |
def __init__(self, store, redraw_plot, add_feature, settings): """ Initializes the treeview. Requires a model and the main window redraw-function. Sets selection mode to MULTIPLE. Connect the key-press event. """ Gtk.TreeView.__init__(self, model=store) self.store = store self.lyr_obj = None self.redraw = redraw_plot self.add_feature = add_feature self.settings = settings self.select = self.get_selection() self.select.set_mode(Gtk.SelectionMode.MULTIPLE) self.connect("key-press-event", self.on_key_pressed) self.select.connect("changed", self.data_selection_changed)
Example #6
Source File: DescendantCount.py From addons-source with GNU General Public License v2.0 | 6 votes |
def build_gui(self): """ Build the GUI interface. """ tip = _("Click name to change active\n" "Double-click name to edit") self.set_tooltip(tip) top = Gtk.TreeView() top.connect('button-press-event', self._button_press) renderer = Gtk.CellRendererText() renderer.set_property('ellipsize', Pango.EllipsizeMode.END) column = Gtk.TreeViewColumn(_('Person'), renderer, text=0) column.set_expand(True) column.set_resizable(True) column.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE) column.set_sort_column_id(0) top.append_column(column) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_('Descendants'), renderer, text=1) column.set_sort_column_id(1) top.append_column(column) self.model = Gtk.ListStore(str, int, str) top.set_model(self.model) return top
Example #7
Source File: MediaVerify.py From addons-source with GNU General Public License v2.0 | 6 votes |
def create_tab(self, title): """ Create a page in the notebook. """ scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) view = Gtk.TreeView() column = Gtk.TreeViewColumn(_('Files')) view.append_column(column) cell = Gtk.CellRendererText() column.pack_start(cell, True) column.add_attribute(cell, 'text', 0) column.set_sort_column_id(0) column.set_sort_indicator(True) model = Gtk.ListStore(str, str) view.set_model(model) page = self.notebook.get_n_pages() view.connect('button-press-event', self.button_press, page) scrolled_window.add(view) self.models.append(model) self.views.append(view) label = Gtk.Label(title) self.notebook.append_page(scrolled_window, label)
Example #8
Source File: editform.py From addons-source with GNU General Public License v2.0 | 6 votes |
def build_interface(self): """ Builds the interface. """ self.model = Gtk.ListStore(str, str) self.view = Gtk.TreeView(model=self.model) self.selection = self.view.get_selection() renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_('Key'), renderer, text=0) self.view.append_column(column) renderer = Gtk.CellRendererText() renderer.set_property('editable', True) renderer.connect('edited', self.__cell_edited, (self.model, 1)) column = Gtk.TreeViewColumn(_('Value'), renderer, text=1) self.view.append_column(column) scrollwin = Gtk.ScrolledWindow() scrollwin.add(self.view) scrollwin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.pack_start(scrollwin, expand=True, fill=True, padding=0)
Example #9
Source File: Overview.py From addons-source with GNU General Public License v2.0 | 6 votes |
def build_gui(self): """ Build the GUI interface. """ tip = _('Double-click on a row to edit the selected event.') self.set_tooltip(tip) top = Gtk.TreeView() titles = [('', NOSORT, 50,), (_('Type'), 1, 100), (_('Date'), 3, 100), ('', 3, 100), (_('Age'), 4, 35), (_('Where Born'), 5, 160), (_('Condition'), 6, 75), (_('Occupation'), 7, 160), (_('Residence'), 8, 160)] self.model = ListModel(top, titles, event_func=self.edit_event) return top
Example #10
Source File: libtmg.py From addons-source with GNU General Public License v2.0 | 6 votes |
def __init__(self, uistate, data, parent): super().__init__(uistate, [], self) self.window = Gtk.Dialog() self.set_window(self.window, None, _("Database Information")) self.window.set_modal(True) self.ok = self.window.add_button(_('_OK'), Gtk.ResponseType.OK) self.ok.connect('clicked', self.on_ok_clicked) self.window.set_position(Gtk.WindowPosition.CENTER) self.window.set_default_size(600, 400) s = Gtk.ScrolledWindow() titles = [ (_('Setting'), 0, 150), (_('Value'), 1, 400) ] treeview = Gtk.TreeView() model = Gtk.ListModel(treeview, titles) for key, value in sorted(data.items()): model.add((key, str(value),), key) s.add(treeview) self.window.vbox.pack_start(s, True, True, 0) if parent: self.window.set_transient_for(parent) self.show()
Example #11
Source File: cheatsheet_dialog.py From bokken with GNU General Public License v2.0 | 6 votes |
def populate_tree(self, groups): """ Accepts an array of n rows made of 2 elements each, and returns a TreeView.""" store = Gtk.TreeStore(GdkPixbuf.Pixbuf, str, str) for group in groups: #header = '<span background=\"#5a58ff\" foreground=\"white\"><b> ' + group.replace('_', ' ').capitalize() + '\t</b></span>' header = group.replace('_', ' ').capitalize() it = store.append(None, [self.pix, header, '']) for row in eval('self.' + group): store.append(it, [None, row[0], row[1]]) tv = Gtk.TreeView(store) #tv.set_rules_hint(True) #tv.set_enable_tree_lines(True) tv.set_show_expanders(False) tv.set_level_indentation(10) tv.expand_all() return tv
Example #12
Source File: modification_history.py From RAFCON with Eclipse Public License 1.0 | 6 votes |
def __init__(self): View.__init__(self) Gtk.TreeView.__init__(self) foreground = 5 tvcolumn = Gtk.TreeViewColumn('Nr', Gtk.CellRendererText(), text=1, foreground=foreground) tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) self.append_column(tvcolumn) tvcolumn = Gtk.TreeViewColumn('Action', Gtk.CellRendererText(), text=2, foreground=foreground) tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) self.append_column(tvcolumn) tvcolumn = Gtk.TreeViewColumn('Parameters', Gtk.CellRendererText(), text=7, foreground=foreground) tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) self.append_column(tvcolumn) tvcolumn = Gtk.TreeViewColumn('Affects', Gtk.CellRendererText(), text=3, foreground=foreground) tvcolumn.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE) # tvcolumn.set_min_width(150) self.append_column(tvcolumn) self['history_treeview'] = self self.top = 'history_treeview'
Example #13
Source File: pages.py From zim-desktop-wiki with GNU General Public License v2.0 | 6 votes |
def _update_parent_nchildren(self, parentname): # parent n_children needs to be up-to-date when we emit the "deleted" # signal, else Gtk.TreeView sees an inconsistency # We still call update_parent() after the fact to do the rest of the # house keeping row = self._select(parentname) assert row is not None n_children, = self.db.execute( 'SELECT count(*) FROM pages WHERE parent=?', (row['id'],) ).fetchone() self.db.execute( 'UPDATE pages SET n_children=? WHERE id=?', (n_children, row['id']) )
Example #14
Source File: managers.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, treeview, selection_mode=None, cb_delete=None, cb_refresh=None): """ :param treeview: The treeview to wrap and manage. :type treeview: :py:class:`Gtk.TreeView` :param selection_mode: The selection mode to set for the treeview. :type selection_mode: :py:class:`Gtk.SelectionMode` :param cb_delete: An optional callback that can be used to delete entries. :type cb_delete: function """ self.treeview = treeview """The :py:class:`Gtk.TreeView` instance being managed.""" self.cb_delete = cb_delete """An optional callback for deleting entries from the treeview's model.""" self.cb_refresh = cb_refresh """An optional callback for refreshing the data in the treeview's model.""" self.column_titles = collections.OrderedDict() """An ordered dictionary of storage data columns keyed by their respective column titles.""" self.column_views = {} """A dictionary of column treeview's keyed by their column titles.""" self.treeview.connect('key-press-event', self.signal_key_press_event) if selection_mode is None: selection_mode = Gtk.SelectionMode.SINGLE treeview.get_selection().set_mode(selection_mode) self._menu_items = {}
Example #15
Source File: compare_campaigns.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def load_campaigns(self): """Load campaigns from the remote server and populate the :py:class:`Gtk.TreeView`.""" store = self._model store.clear() campaigns = self.application.rpc.graphql_find_file('get_campaigns.graphql') for campaign in campaigns['db']['campaigns']['edges']: campaign = campaign['node'] company = campaign['company']['name'] if campaign['company'] else None created_ts = utilities.datetime_utc_to_local(campaign['created']) created_ts = utilities.format_datetime(created_ts) campaign_type = campaign['campaignType']['name'] if campaign['campaignType'] else None expiration_ts = campaign['expiration'] if expiration_ts is not None: expiration_ts = utilities.datetime_utc_to_local(expiration_ts) expiration_ts = utilities.format_datetime(expiration_ts) store.append(( campaign['id'], False, campaign['name'], company, campaign_type, campaign['user']['name'], created_ts, expiration_ts ))
Example #16
Source File: tableeditor.py From zim-desktop-wiki with GNU General Public License v2.0 | 6 votes |
def _init_treeview(self, model): # Actual gtk table object self.treeview = self.create_treeview(model) # Hook up signals & set options self.treeview.connect('button-press-event', self.on_button_press_event) self.treeview.connect('focus-in-event', self.on_focus_in, self.toolbar) self.treeview.connect('focus-out-event', self.on_focus_out, self.toolbar) self.treeview.connect('move-cursor', self.on_move_cursor) # Set options self.treeview.set_grid_lines(Gtk.TreeViewGridLines.BOTH) self.treeview.set_receives_default(True) self.treeview.set_size_request(-1, -1) self.treeview.set_border_width(2) # disable interactive column search self.treeview.set_enable_search(False) #Gtk.binding_entry_remove(Gtk.TreeView, Gdk.KEY_f, Gdk.ModifierType.CONTROL_MASK) self.treeview.set_search_column(-1)
Example #17
Source File: completions.py From vimiv with MIT License | 6 votes |
def _activate(self, treeview, path, column): """Enter the completion text of the treeview into the commandline. Args: treeview: TreeView that was activated. path: Activated TreePath. column: Activated TreeViewColumn. """ if treeview: count = path.get_indices()[0] self._app["commandline"].grab_focus() else: count = self._tab_position comp_type = self._get_comp_type() row = self._liststores[comp_type][1][count] self._app["commandline"].set_text(":" + self._prefixed_digits + row[0]) self._app["commandline"].set_position(-1)
Example #18
Source File: IconWindow.py From bcloud with GNU General Public License v3.0 | 6 votes |
def on_drag_data_received(self, widget, context, x, y, data, info, time): '''拖放结束''' if not data: return bx, by = self.iconview.convert_widget_to_bin_window_coords(x, y) selected = Gtk.TreeView.get_path_at_pos(self.iconview, bx, by) if not selected: return tree_path = selected[0] if tree_path is None: return target_path = self.liststore[tree_path][PATH_COL] is_dir = self.liststore[tree_path][ISDIR_COL] if not is_dir or info != TargetInfo.PLAIN_TEXT: return filelist_str = data.get_text() filelist = json.loads(filelist_str) for file_item in filelist: if file_item['path'] == target_path: self.app.toast(_('Error: Move folder to itself!')) return for file_item in filelist: file_item['dest'] = target_path gutil.async_call(pcs.move, self.app.cookie, self.app.tokens, filelist, callback=self.parent.reload)
Example #19
Source File: widgets.py From zim-desktop-wiki with GNU General Public License v2.0 | 6 votes |
def do_button_press_event(self, event): # Implement hook for context menu if event.type == Gdk.EventType.BUTTON_PRESS \ and event.button == 3: # Check selection state - item under cursor should be selected # see do_button_release_event for comments x, y = list(map(int, event.get_coords())) info = self.get_path_at_pos(x, y) selection = self.get_selection() if x > 0 and y > 0 and not info is None: path, column, x, y = info if not selection.path_is_selected(path): selection.unselect_all() selection.select_path(path) # else the click was on a already selected path else: # click outside area with items ? selection.unselect_all() # Pop menu menu = self.get_popup() gtk_popup_at_pointer(menu, event) else: return Gtk.TreeView.do_button_press_event(self, event)
Example #20
Source File: bookPanel.py From pychess with GNU General Public License v3.0 | 5 votes |
def query_tooltip(self, treeview, x, y, keyboard_mode, tooltip): # First, find out where the pointer is: path_col_x_y = treeview.get_path_at_pos(x, y) # If we're not pointed at a row, then return FALSE to say # "don't show a tip". if not path_col_x_y: return False # Otherwise, ask the TreeView to set up the tip's area according # to the row's rectangle. path, col, x, y = path_col_x_y if not path: return False treeview.set_tooltip_row(tooltip, path) # And ask the advisor for some text indices = path.get_indices() if indices: text = self.advisors[indices[0]].query_tooltip(path) if text: label = Gtk.Label() label.props.wrap = True label.props.width_chars = 60 label.props.max_width_chars = 60 label.set_text(text) tooltip.set_custom(label) # tooltip.set_markup(text) return True # Show the tip. return False ################################################################################ # StrengthCellRenderer # ################################################################################
Example #21
Source File: widgets.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def ScrolledWindow(widget, hpolicy=Gtk.PolicyType.AUTOMATIC, vpolicy=Gtk.PolicyType.AUTOMATIC, shadow=Gtk.ShadowType.IN): '''Wrap C{widget} in a C{Gtk.ScrolledWindow} and return the resulting widget @param widget: any Gtk widget @param hpolicy: the horizontal scrollbar policy @param vpolicy: the vertical scrollbar policy @param shadow: the shadow type @returns: a C{Gtk.ScrolledWindow} ''' window = Gtk.ScrolledWindow() window.set_policy(hpolicy, vpolicy) window.set_shadow_type(shadow) if isinstance(widget, (Gtk.TextView, Gtk.TreeView, Gtk.Layout)): # Known native-scrolling widgets window.add(widget) else: window.add_with_viewport(widget) if hpolicy == Gtk.PolicyType.NEVER: hsize = -1 # do not set else: hsize = 24 if vpolicy == Gtk.PolicyType.NEVER: vsize = -1 # do not set else: vsize = 24 window.set_size_request(hsize, vsize) # scrolled widgets have at least this size... # by setting this minimum widgets can not "disappear" when # HPaned or VPaned bar is pulled all the way return window
Example #22
Source File: pages.py From zim-desktop-wiki with GNU General Public License v2.0 | 5 votes |
def on_page_row_deleted(self, o, row): # Technically "_deleted_paths" should always be a single path # here, else two things changed at once, and Gtk.TreeView cannot # always deal with that. self.flush_cache() if row['name'] == self._MY_ROOT_NAME: self._MY_ROOT_ID = None else: for treepath in self._deleted_paths: self.emit('row-deleted', treepath) if treepath[-1] == 0 and len(treepath) > 1: self._check_parent_has_child_toggled(treepath, 0) self._deleted_paths = None
Example #23
Source File: mdi.py From hazzy with GNU General Public License v2.0 | 5 votes |
def __init__(self, widget_window): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self.set_hexpand(True) self.set_vexpand(True) # Widget Factories MDI entry widget self.entry = MDIEntry() self.pack_end(self.entry, False, False, 0) # Scrolled window for the MDI history view scrolled = Gtk.ScrolledWindow() self.vadj = scrolled.get_vadjustment() self.pack_start(scrolled, True, True, 0) # MDI history TreeView self.view = Gtk.TreeView(self.entry.model) self.view.set_activate_on_single_click(True) self.view.set_headers_visible(False) scrolled.add(self.view) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Command", renderer, text=0) self.view.append_column(column) self.selection = self.view.get_selection() self.scrolled_to_bottom = False self.view.connect('size-allocate', self.scroll_to_bottom) self.view.connect('row-activated', self.on_view_row_activated) self.view.connect('cursor-changed', self.on_view_cursor_changed) self.entry.connect('activate', self.on_entry_activated) self.entry.connect('focus-in-event', self.on_entry_gets_focus) self.entry.connect('key-press-event', self.on_entry_keypress) # On history item clicked set the cmd in the MDI entry
Example #24
Source File: LecturesPanel.py From pychess with GNU General Public License v3.0 | 5 votes |
def load(self, persp): self.persp = persp self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.tv = Gtk.TreeView() renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_("Title"), renderer, text=1) self.tv.append_column(column) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_("Author"), renderer, text=2) self.tv.append_column(column) self.tv.connect("row-activated", self.row_activated) self.store = Gtk.ListStore(str, str, str) for file_name, title, author in LECTURES: self.store.append([file_name, title, author]) self.tv.set_model(self.store) self.tv.get_selection().set_mode(Gtk.SelectionMode.BROWSE) self.tv.set_cursor(conf.get("learncombo%s" % LECTURE)) scrollwin = Gtk.ScrolledWindow() scrollwin.add(self.tv) scrollwin.show_all() self.box.pack_start(scrollwin, True, True, 0) self.box.show_all() return self.box
Example #25
Source File: recipe-578773.py From code with MIT License | 5 votes |
def on_button_clicked(self, button): # Get the TreeView selected row(s) selection = self.treeview.get_selection() # get_selected_rows() returns a tuple # The first element is a ListStore # The second element is a list of tree paths # of all selected rows model, paths = selection.get_selected_rows() # Get the TreeIter instance for each path for path in paths:
Example #26
Source File: recipe-578773.py From code with MIT License | 5 votes |
def __init__(self): Gtk.Window.__init__(self, title='My Window Title') self.connect('delete-event', Gtk.main_quit) store = Gtk.ListStore(str, str) self.populate_store(store) self.treeview = Gtk.TreeView(model=store) renderer = Gtk.CellRendererText() column_name = Gtk.TreeViewColumn('Song Name', renderer, text=0) column_name.set_sort_column_id(0) self.treeview.append_column(column_name) column_artist = Gtk.TreeViewColumn('Artist', renderer, text=1) column_artist.set_sort_column_id(1) self.treeview.append_column(column_artist) scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy( Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled_window.add(self.treeview) scrolled_window.set_min_content_height(200) button = Gtk.Button('Delete Selected Row') button.connect('clicked', self.on_button_clicked) box = Gtk.Box() box.pack_start(scrolled_window, True, True, 1) box.pack_start(button, False, False, 1) self.add(box) self.show_all()
Example #27
Source File: widgets.py From badKarma with GNU General Public License v3.0 | 5 votes |
def add_note(self, widget): """ add a note to the db """ try: self.scrolledwindow.destroy() except: pass title, id = self.database.add_note(self.host.id, "note "+str(len(self.notes_liststore)), "") # FIXME self.notes_liststore.append([title, id]) self.scrolledwindow = Gtk.ScrolledWindow() self.scrolledwindow.set_hexpand(True) self.scrolledwindow.set_vexpand(True) self.note_box = GtkSource.View() textbuffer = self.note_box.get_buffer() textbuffer.set_text("") self.notestree = Gtk.TreeView(model=self.notes_liststore) self.note_box.set_show_line_numbers(True) self.scrolledwindow.add(self.note_box) self.note_box.show() self.scrolledwindow.show() self.notes_view.add(self.scrolledwindow) self.note_box.connect("move-cursor", self.save_note, id) self.id = id
Example #28
Source File: workspace.py From badKarma with GNU General Public License v3.0 | 5 votes |
def __init__(self, database): builder = Gtk.Builder() # glade builder.add_from_file(os.path.dirname(os.path.abspath(__file__)) + "/../assets/ui/hostlist.glade") self.database = database self.services_search = builder.get_object("hosts_search") self.services_list = builder.get_object("hostlist") self.services_box = builder.get_object("host-box") self.services_search.connect("search-changed", self._search_service) self.services_liststore = Gtk.ListStore(str) #creating the treeview, making it use the filter as a model, and adding the columns self.servicestree = Gtk.TreeView(model=self.services_liststore) #.new_with_model(self.language_filter) for i, column_title in enumerate(["service"]): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(column_title, renderer, text=i) self.servicestree.append_column(column) self.services_list.add(self.servicestree) #self.servicestree.show() self.services_box.show() self.out_of_scope = True self.servicestree.props.activate_on_single_click = True self.refresh(self.database)
Example #29
Source File: commentPanel.py From pychess with GNU General Public License v3.0 | 5 votes |
def load(self, gmwidg): self.gamemodel = gmwidg.board.view.model self.model_cids = [ self.gamemodel.connect_after("game_changed", self.game_changed), self.gamemodel.connect_after("game_started", self.game_started), self.gamemodel.connect_after("moves_undone", self.moves_undone), self.gamemodel.connect_after("game_terminated", self.on_game_terminated), ] scrollwin = Gtk.ScrolledWindow() self.tv = Gtk.TreeView() self.tv.set_headers_visible(False) scrollwin.add(self.tv) scrollwin.show_all() self.store = Gtk.ListStore(str) self.tv.set_model(self.store) self.tv.get_selection().set_mode(Gtk.SelectionMode.BROWSE) uistuff.appendAutowrapColumn(self.tv, "Comment", text=0) self.tv_cid = self.tv.connect('cursor_changed', self.cursorChanged) self.boardview = gmwidg.board.view self.cid = self.boardview.connect("shownChanged", self.shownChanged) return scrollwin
Example #30
Source File: LogDialog.py From pychess with GNU General Public License v3.0 | 5 votes |
def _init(cls): cls.tagToIter = {} cls.tagToPage = {} cls.pathToPage = {} cls.tagToTime = {} cls.window = Gtk.Window() cls.window.set_title(_("PyChess Information Window")) cls.window.set_border_width(12) cls.window.set_icon_name("pychess") uistuff.keepWindowSize("logdialog", cls.window, (640, 480)) mainHBox = Gtk.HBox() mainHBox.set_spacing(6) cls.window.add(mainHBox) sw = Gtk.ScrolledWindow() sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) sw.set_shadow_type(Gtk.ShadowType.IN) mainHBox.pack_start(sw, False, True, 0) cls.treeview = Gtk.TreeView(Gtk.TreeStore(str)) cls.treeview.append_column(Gtk.TreeViewColumn("", Gtk.CellRendererText(), text=0)) cls.treeview.set_headers_visible(False) cls.treeview.get_selection().set_mode(Gtk.SelectionMode.BROWSE) sw.add(cls.treeview) cls.pages = Gtk.Notebook() cls.pages.set_show_tabs(False) cls.pages.set_show_border(False) mainHBox.pack_start(cls.pages, True, True, 0) mainHBox.show_all() def selectionChanged(selection): treestore, iter = selection.get_selected() if iter: child = cls.pathToPage[treestore.get_path(iter).to_string()][ "child"] cls.pages.set_current_page(cls.pages.page_num(child)) cls.treeview.get_selection().connect("changed", selectionChanged)