Mitko Haralanov schrieb:
I have a gtk.ScrolledWindow, which has a gtk.VBox added with a
gtk.Viewport.
What I would like to do is be able to scroll the gtk.ScrolledWindow to
a specific location (one of the gtk.VBox children). I know how to do
the actual scrolling (using the h/vadjustments) but how do I determine
how much to scroll it by so the correct child is in view?

Thanks for the help?

Does this help you:

http://faq.pygtk.org/index.py?req=show&file=faq10.010.htp


     10.10. <http://faq.pygtk.org/index.py?req=show&file=faq10.010.htp>
     How do I adjust a ScrolledWindow to adjust to a given child widget?

One common request is to get a ScrolledWindow to adjust to display one of the widgets it contains -- frequently you'd like to adjust the scrollbar to display the widget that receives focus. This is possible by using the set_value method of the ScrolledWindow's adjustment object in conjunction with the child widget's `focus_in_event' signal. An (untested) example follows:

def focus_in(widget, event, adj):
alloc = widget.get_allocation() if alloc.y < adj.value or alloc.y > adj.value + adj.page_size:
    adj.set_value(min(alloc.y, adj.upper-adj.page_size))

scrolled_window = gtk.ScrolledWindow()
adj = scrolled_window.get_vadjustment()
# ... create child widget
child.connect('focus_in_event', focus_in, adj)

This should make the scrollbar adjust automatically whenever child receives focus.


--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to