gtktreeview

Python GTK3 Treeview Move Selection up or down

泄露秘密 提交于 2019-12-12 09:52:04
问题 How do I move a selection up or down in a Treeview? The idea is that I can have an up and down buttons to move the selection up a row or down a row. My Treeview is using a ListStore. Not sure if that matters. 回答1: First off, I will be using C code as that's what I'm familiar with. Should you have problems translating it to Python, then say so, and I will do my best to help. The class you want to use for this is GtkTreeSelection . Basically, what you do is: Get the selection object of the view

PyGTK TreeColumns all exact duplicates

拟墨画扇 提交于 2019-12-11 16:13:14
问题 I wrote a simple PyGTK script to show some basic process information in a TreeView: import gtk import os import pwd import grp class ProcParser: """ Parses the status file of a particular process """ def __init__(self, fname): self.lines = map(lambda x: x[:-1], open(fname).readlines()) def get_by_val(self, val): for line in self.lines: if line.startswith(val): return line.split() return [] class Proc: """ A process in the /proc filesystem This class uses a ProcParser to determine it's own

In Gtk, how do I search a ListStore for the row containing a particular value?

不羁岁月 提交于 2019-12-10 23:07:02
问题 I have a ListStore modeling a list of Tag s. This list may change apart from the ListStore . What I'd like to do is listen to the TagRemoved event in my TagList class, and remove the Tag from the ListStore when the event is triggered. However, I can't seem to find a way to search a ListStore for the row containing a given Tag , so that I can remove it. Is there any way to do this? 回答1: A GtkListStore implements the GtkTreeModel interface, which contains the tree traversal operations you want.

Detect when column in gtk.treeview is resized

自作多情 提交于 2019-12-10 18:56:45
问题 What signal can I catch to detect when a column changes size in a gtk.TreeView ? I can't seem to find it in the docs. 回答1: gtk.TreeViewColumns aren't widgets so they unfortunately don't have a dedicated signal for size changes. But you can register a callback function that receives "width" change notifications: def onColWidthChange(col, width): # Note that "width" is a GParamInt object, not an integer ... col.connect("notify::width", onColWidthChange) In the example, col must be a gtk

How do I get the item (tree node) under the mouse pointer in a TreeView?

☆樱花仙子☆ 提交于 2019-12-10 12:13:58
问题 In a GTK/GTK# TreeView , how do I get the item/node which the mouse pointer is currently hovering over? 回答1: Let's say we want to select items using the right mouse button without using checkboxes. The following ButtonPress event handler does just that - it toggles the selected property of the item we have clicked with the RMB. We then use CellDataFunc s to highlight the selected items. tv is the TreeView, store is the underlying ListStore. [GLib.ConnectBefore] void

Add gtk.TreeView columns to a size group

我的梦境 提交于 2019-12-08 09:25:19
问题 I want to stack two treeviews on each other and have the columns be aligned. I figured the way to do this would be to use a gtk.SizeGroup somehow. However, gtk.TreeViewColumn is not a widget... how can I do this? 回答1: I have two suggestions: Look at how gtk.SizeGroup is implemented and see if you can write your own TreeViewColumnSizeGroup . Connect to notify::width of each column and in the callback set the width of the corresponding column in the other treeview. 回答2: UPDATE: This is the

GtkTreeView's row right click

岁酱吖の 提交于 2019-12-07 05:45:56
问题 How do I do something when user right click in a treeview's row? 回答1: It's really easy, just listen to the "button-press-event" signal and use treeview.get_path_at_pos() to figure the selected row: def button_press_event(treeview, event): if event.button == 3: # right click model, path = treeview.get_path_at_pos(int(event.x), int(event.y)) # do something with the selected path treeview.connect('button-press-event' , button_press_event) 来源: https://stackoverflow.com/questions/4570859

GtkTreeView insert/update performance penalty because of sorting

空扰寡人 提交于 2019-12-07 02:07:26
问题 I'm having performance problems when inserting many rows into a GTK treeview (using PyGTK) - or when modifying many rows. The problem is that the model seems to get resorted after each change (insert/modification). This causes the GUI to hang for multiple seconds. Leaving the model unsorted by commenting out model.set_sort_column_id(SOME_ROW_INDEX, gtk.SORT_ASCENDING) eliminates these problems. Therefore, I would like to disable the sorting while I'm inserting or modifying the model, and re

Python GTK3 Treeview Move Selection up or down

夙愿已清 提交于 2019-12-06 02:10:01
How do I move a selection up or down in a Treeview? The idea is that I can have an up and down buttons to move the selection up a row or down a row. My Treeview is using a ListStore. Not sure if that matters. First off, I will be using C code as that's what I'm familiar with. Should you have problems translating it to Python, then say so, and I will do my best to help. The class you want to use for this is GtkTreeSelection . Basically, what you do is: Get the selection object of the view ( gtk_tree_view_get_selection ) Get the currently selected GtkTreeIter ( gtk_tree_selection_get_selected ).

GtkTreeView's row right click

若如初见. 提交于 2019-12-05 09:06:19
How do I do something when user right click in a treeview's row? Johan Dahlin It's really easy, just listen to the "button-press-event" signal and use treeview.get_path_at_pos() to figure the selected row: def button_press_event(treeview, event): if event.button == 3: # right click model, path = treeview.get_path_at_pos(int(event.x), int(event.y)) # do something with the selected path treeview.connect('button-press-event' , button_press_event) 来源: https://stackoverflow.com/questions/4570859/gtktreeviews-row-right-click