views:

61

answers:

1

When I try to scroll down to the end of my TreeView, which is inside a ScrolledWindow, it doesn't scroll where it should but one or two lines before.

I tried several methods and they all provide the same behavior :

self.wTree.get_widget("tree_last_log").scroll_to_cell((self.number_results-1,))
# or 
self.wTree.get_widget("tree_last_log").set_cursor((self.number_results-1,))
# or 
adj = self.wTree.get_widget("scrolledwindow1").get_vadjustment()
adj.set_value(adj.get_property('upper'))
self.wTree.get_widget("scrolledwindow1").set_vadjustment(adj)
# or 
self.wTree.get_widget("scrolledwindow1").emit('scroll-child', gtk.SCROLL_END, False)

Where is the problem ?

+1  A: 

The C API docs may be helpful: http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#gtk-tree-view-scroll-to-cell

You can see there are arguments there that would mess things up, depending on how pygtk defaults them. You might try specifying explicitly all the args.

One trick to TreeView and TextView is that they do asynchronous layout so the "upper" on the adjustment may well just be zero if row heights haven't been computed yet.

if messing with the adjustment, there's no need to set it back, though it should be harmless.

'scroll-child' signal is not what you want, that's a keybinding signal used to bind keys to.

Havoc P