Placing elements (panels) within a wx.GridBagSizer
Posted
by
JHarris
on Stack Overflow
See other posts from Stack Overflow
or by JHarris
Published on 2011-01-15T17:16:35Z
Indexed on
2011/01/15
17:53 UTC
Read the original article
Hit count: 118
I'm using a gridbagsizer to place two panels within a frame.
control_panel = wx.Panel(self, id=ID_CONTROL_PANEL)
main_panel = wx.Panel(self, id=ID_MAIN_PANEL)
frame_sizer = wx.GridBagSizer(1, 1)
frame_sizer.Add(control_panel, (0, 0), (2, 5), flag=wx.EXPAND)
frame_sizer.Add(main_panel, (2, 0), (5, 5), flag=wx.EXPAND)
frame_sizer.AddGrowableRow(0)
frame_sizer.AddGrowableCol(0)
self.SetSizer(frame_sizer)
I want the control_panel to be above the main_panel (as you can see above). However this is the output I get:
I don't know why the top panel is so much larger than the bottom panel, when I've specified the opposite. (2, 5) for the top and (5, 5) for the bottom. It also has a strange behaviour when I resize it smaller, it basically gives me what I want (see image below), but I don't know how to maintain the ratio when I make it larger again.
However when you start resizing larger (even by a small amount) you can see (below) the shapes and ratio change dramatically in the other direction (with the bottom becoming much smaller and the top much larger).
Still trying to learn this sizers and can't really find this problem with any of the examples I've seen. Also tried experimenting with all the parameters and doing some tests and I can't figure out what's going on here. Any help would be much appreciated.
© Stack Overflow or respective owner