I want a wx.TextCtrl
to take the entire remaining width of a panel. It is placed with a wx.StaticText
and a wx.Button
in a horizontal wx.BoxSizer
in a vertical wx.BoxSizer
in a wx.lib.scrolledpanel.ScrolledPanel
(which is self
below):
# create TextCtrl
self.fileNameInput = wx.TextCtrl (self, style=wx.TE_PROCESS_ENTER)
# create horizontal sizer with 3 items
self.fileNameSizer = wx.BoxSizer (wx.HORIZONTAL)
self.fileNameSizer.Add (wx.StaticText (self, -1, 'none'), flag=(wx.ALIGN_CENTER_VERTICAL))
self.fileNameSizer.Add (self.fileNameInput, proportion=1, flag=(wx.EXPAND | wx.ALIGN_CENTER_VERTICAL))
self.fileNameSizer.Add (wx.Button (self, label='Button'), flag=(wx.ALIGN_CENTER_VERTICAL))
# create vertical sizer
self.SetSizer (wx.BoxSizer (wx.VERTICAL))
self.GetSizer ().Add (self.fileNameSizer)
Neither proportion
nor wx.EXPAND
help to make the TextCtrl
larger, presumably because the sizer looks at the TextCtrl
s own width. But I did not find any style or flag for the `'TextCtrl' to make it variable-width..?
Thanks for ideas!
EDIT: Replaced "..." by something working
I think that what is wrong is this line:
There should be some of
proportion=1
and/orflag=wx.EXPAND
to make the nested sizer match its master size.Something like this:
BTW: Please stop adding space before
(
in method calls. Also I would recommend object oriented approach so you do not loose access to your GUI objects.