Reputation: 559
I have a gui where i would like to use StaticBoxes. But i want them to expand over the whole vertical height of my window. I tried it with StaticBoxSizers, but they wont expand.
What do i need to change?
hbox2 = wx.BoxSizer(wx.HORIZONTAL)
vbox2 = wx.BoxSizer(wx.VERTICAL)
leftPanel = wx.Panel(panel)
box = wx.StaticBox(leftPanel, wx.ID_ANY, "testBox", size=(0,100))
text = wx.StaticText(leftPanel, wx.ID_ANY, "This is a test")
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
boxSizer.Add(text, proportion = 1, flag=wx.ALIGN_CENTER)
box2 = wx.StaticBox(leftPanel, wx.ID_ANY, "testBox", size=(0,100))
text2 = wx.StaticText(leftPanel, wx.ID_ANY, "This is a test")
boxSizer2 = wx.StaticBoxSizer(box2, wx.VERTICAL)
boxSizer2.Add(text2, proportion = 2, flag=wx.ALIGN_CENTER)
vbox2.Add(boxSizer, 50, wx.EXPAND | wx.TOP, 3)
vbox2.Add(boxSizer2, 50, wx.EXPAND | wx.TOP, 3)
leftPanel.SetSizer(vbox2, wx.EXPAND)
hbox2.Add(leftPanel)
Upvotes: 0
Views: 401
Reputation: 22448
You have set the proportion
flag when adding to vbox2
to 50, that is wrong.
Try setting them both to 1.
vbox2.Add(boxSizer, 1, wx.EXPAND | wx.TOP, 3)
vbox2.Add(boxSizer2, 1, wx.EXPAND | wx.TOP, 3)
Add(window, proportion=0, flag=0, border=0, userData=None) Appends a child to the sizer.
Parameters:
window – a window, a spacer or another sizer to be added to the sizer. Its initial size (either set explicitly by the user or calculated internally) is interpreted as the minimal and in many cases also the initial size.
proportion (int) – this parameter is used in wx.BoxSizer to indicate if a child of a sizer can change its size in the main orientation of the wx.BoxSizer - where 0 stands for not changeable and a value of more than zero is interpreted relative to the value of other children of the same wx.BoxSizer. For example, you might have a horizontal wx.BoxSizer with three children, two of which are supposed to change their size with the sizer. Then the two stretchable windows would get a value of 1 each to make them grow and shrink equally with the sizer’s horizontal dimension.
flag (int) – OR-combination of flags affecting sizer’s behaviour.
border (int) – determines the border width, if the flag parameter is set to include any border flag.
userData (object) – allows an extra object to be attached to the sizer item, for use in derived classes when sizing information is more complex than the proportion and flag will allow for.
Return type:
wx.SizerItem
Upvotes: 1