Reputation: 1006
I'm trying to align some controls in my wxPython app to bottom of a panel. Here's sample of my code:
def __DoLayout(self):
vsizer = wx.BoxSizer(wx.VERTICAL)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
hsizer.Add(self.prog, 0, wx.ALL|wx.EXPAND, 5)
hsizer2.Add(self.text, 0, wx.ALL|wx.EXPAND, 5)
#hsizer.Add(self.timer, 0, wx.EXPAND|wx.ALIGN_RIGHT)
vsizer.Add(hsizer2, 0, wx.EXPAND)
vsizer.Add(hsizer, 0, wx.ALIGN_BOTTOM|wx.EXPAND)
self.SetSizer(vsizer)
I would like the bottom horizontal sizer (hsizer) to stretch to bottom, or the top one to stretch placing bottom sizer on the bottom (that would actually be better).
[EDIT: Proposed sulution description]
The proportion parameter defines the ratio of how will the widgets change in the defined orientation. Let's assume we have three buttons with the proportions 0, 1, and 2. They are added into a horizontal wx.BoxSizer. Button with proportion 0 will not change at all. Button with proportion 2 will change twice more than the one with proportion 1 in the horizontal dimension.
From zetcode Solution proposed by Renae Lider
Upvotes: 3
Views: 1627
Reputation: 22443
With reluctance, but as @renae-lider who answered the question has not posted an answer.
Change the 0 to 1 in this line :
vsizer.Add(hsizer2, 1, wx.EXPAND)
This is the proportion
parameter.
The proportion parameter defines the ratio of how will the widgets change in the defined orientation.
Let's assume we have three buttons with the proportions 0, 1, and 2. They are added into a horizontal wx.BoxSizer. Button with proportion 0 will not change at all. Button with proportion 2 will change twice more than the one with proportion 1 in the horizontal dimension.
Upvotes: 2