[pygtk] Multi-paned window

Luigi Paioro luigi at lambrate.inaf.it
Tue Jan 24 23:58:14 WST 2006


Hi to all!

I'm new to PyGTK programming (I used Tk widgets) and I'd like to know 
whether it exists a way to have a multi-paned window widget. I explain 
better:

I can use a gtk.HPaned() or gtk.VPaned() widget to pane 2 widgets, for 
example:

import pygtk
pygtk.require('2.0')
import gtk, gobject

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
vpaned = gtk.VPaned()
window.add(vpaned)
vpaned.show()
w1 = gtk.TextView()
w2 = gtk.TextView()
vpaned.add1(w1)
w1.show()
vpaned.add2(w2)
w2.show()
window.show()
gtk.main()

But if I have more than 2 widgets I cannot pane them into the same 
window but I have to do something like this:

import pygtk
pygtk.require('2.0')
import gtk, gobject

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
vpaned1 = gtk.VPaned()
vpaned2 = gtk.VPaned()
window.add(vpaned1)
vpaned1.show()
w1 = gtk.TextView()
w2 = gtk.TextView()
w3 = gtk.TextView()
vpaned1.add1(w1)
w1.show()
vpaned1.add2(vpaned2)
vpaned2.show()
vpaned2.add1(w2)
w2.show()
vpaned2.add2(w3)
w3.show()
window.show()
gtk.main()


But this is not what I want, 'cause in this way, if I resize w1 using 
the paned1 separator, then w3 is resized too, but I'd like that w2 is 
resized, letting w3 untouched (in my design, adjacent widgets would be 
resized). Furthermore, for a lot of widgets to pack, the code becomes 
very confused.


Does anybody know a way to make a multi-paned window as I described?

Thanks in advance.

Luigi


More information about the pygtk mailing list