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.
views:
16answers:
1
+2
A:
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.TreeViewColumn
object. If you don't initialize the columns in code, you can use gtk.TreeView.get_column
to get these objects.
If you only need notifications when the treeview changes its size, you can use its "size-allocate" signal instead.
AndiDog
2010-10-22 17:20:30
see [my answer here](http://stackoverflow.com/questions/3992602/add-gtk-treeview-columns-to-a-size-group/3999457#3999457) for a hax way to use size-allocate for the columns... but I like this way better =)
Claudiu
2010-10-22 17:43:41
nice, it works. thanks for the links, wouldn't have figured it out w/out them. also change notifications seem pretty useful
Claudiu
2010-10-22 17:53:09
@Claudiu: PyGTK is a nice API but you really need the reference manual to get to know it better. I recommend you to download it so that you can quickly look things up - that actually helped me a lot. The documentation is contained in the [PyGTK sources](http://ftp.gnome.org/pub/GNOME/sources/pygtk/).
AndiDog
2010-10-22 17:59:22
Thanks for the tips! I realized I always look at the ref manual actually.. whenever i'm coding i google `gtk.Container` or `gtk.TreeView` and always look at the ref manual pages. it's still easy to miss stuff like change notifications, though.
Claudiu
2010-10-22 18:03:57