Reputation: 725
I'm working on a project that has a glade GUI.
I need the main window to have 2 section, divided by a gtk.Hpaned widget (horizontal panes).
The left pane would have a tool-bar like layout of buttons, maybe 3 or more.
What I need is a way to create different windows and display them on the right pane of the main window. This way, when I click button 1, subwindow1 will appear in the right pane. Click button2, subwindow2 will appear on the right pane.
Instead of having windows pop-up left and right, I want to reparent them to the right pane of this gtk.Hpaned widged.
How do you do this in python with pygtk?
Upvotes: 2
Views: 1868
Reputation: 377
I would recommend using boxes for your panes. Start with a horizonatal Box that will essentially act as your main window:
hboxMain = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=1)
then two vertical boxes for your panes:
vbox0 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=1)
vbox1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=1)
btn0 = Gtk.Button()
btn1 = Gtk.Button()
btn2 = Gtk.Button()
vbox0.pack_start(btn0, False, False, 1)
vbox0.pack_start(btn1, False, False, 1)
vbox0.pack_start(btn2, False, False, 1)
hboxMain.pack_start(vbox0, False, False, 1)
hboxMain.pack_start(vbox1, False, False, 1)
win = Gtk.Window(title="Home")
win.add(hboxMain)
win.show_all()
It sounds like you want to add window widgets to the right-hand box. I can't answer if that is possible as I assume Window is more regarded as a higher level Container. I imagine it would make more sense to pack into the right side box some text boxes, etc. Not sure why you would want to add a Window widget. Go ahead and give it a try.
Upvotes: 0
Reputation: 2510
Instead of creating windows you could put a notebook in the right pane. Then create all the previous windows as pages. Click on the button can then show the appropriate page in the notebook.
Upvotes: 0
Reputation: 6117
Do you try this?
gtk.Widget.reparent(new_parent)
The reparent() method moves a widget from one gtk.Container to another.
Upvotes: 2