Search code examples
pythonwxpythonfillsizer

What makes a wxpython TextCtrl fill horizontally


I have a TextCtrl in a horizontal BoxSizer. It is added with a weight of 1 (next to a button with a weight of 0). When I run the program, the TextCtrl will remain at a fixed width with empty space next to it, regardless of the size of the window. Why?

Here is the code:

wxapp = wx.App()
wxFrame = wx.Frame(None, -1 , 'Switch Time Zones', (0,0),(340,64))
wxFrame.Centre()
mainBox = wx.BoxSizer(wx.VERTICAL)
wxFrame.SetSizer(mainBox)

...#A few things are added to mainBox

outputBox = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(outputBox, 1, wx.ALIGN_BOTTOM)

...#A few things are added to other boxes

submitButton = wx.Button(wxFrame,label='solve:')
outputBox.Add(submitButton,0)
outputText = wx.TextCtrl(wxFrame)
outputText.SetEditable(False)
outputBox.Add(outputText,1)

wxFrame.Show()
wxapp.MainLoop()

Solution

  • mainBox.Add(outputBox, 1, wx.ALIGN_BOTTOM|wx.EXPAND)