4

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.

gpoo
  • 8,408
  • 3
  • 38
  • 53
Claudiu
  • 224,032
  • 165
  • 485
  • 680

1 Answers1

7

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
  • 68,631
  • 21
  • 159
  • 205
  • 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 Oct 22 '10 at 17:43
  • nice, it works. thanks for the links, wouldn't have figured it out w/out them. also change notifications seem pretty useful – Claudiu Oct 22 '10 at 17:53
  • @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 Oct 22 '10 at 17:59
  • 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 Oct 22 '10 at 18:03