Kevin Horton wrote:
I'm having trouble trying to make a StaticBox grow vertically to fill
the space at the bottom. I'm building the GUI for an application that
will have a series of StaticBoxes at the bottom of the display to
separate different parts of the interface. While the content inside the
StaticBoxes will be of differing height, I want all the boxes to expand
downwards as required so they all end up being the same height. I could
possibly find the height of the tallest box, and then force all the
others to be the same, but I was hoping to avoid that complication.How can I get the StaticBox at the lower left to expand downwards to so
its bottom matches the one on the right?=======================
#!/usr/local/bin/pythonwimport wx
class Frame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title,
size=(800, 600))
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)# Set up top and bottom panels
panel1 = wx.Panel(self, -1)
panel2 = wx.Panel(self, -1)# set up main sizer, to control panel1 and panel2
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(mainSizer)
mainSizer.Add(panel1, proportion=1, flag=wx.EXPAND)
mainSizer.Add(panel2, proportion=0, flag=wx.EXPAND)# create elements in panel2, at bottom of display
# Strip Charts Check Boxes
panelStripCharts, StripChartSizer = self.createBottomPanel(panel2,
'Strip Charts')stripChartData = ('Basic',
'Flight',
'Engine',
'GPS')for item in stripChartData:
checkBox = wx.CheckBox(panel2, -1, item)
StripChartSizer.Add(checkBox, proportion=0, flag=wx.EXPAND)StripChartSizer.Add((0,0), proportion=1, flag=wx.EXPAND)
# Next panel, simulated here to just take up space
panelTimeSlice, TimeSliceSizer = self.createBottomPanel(panel2,
'Time Slice Control')
TimeSliceSizer.Add((100,100))
# set up bottom sizer, to control items in panel2
bottomSizer = wx.BoxSizer(wx.HORIZONTAL)
panel2.SetSizer(bottomSizer)
bottomSizer.Add(panelStripCharts)
bottomSizer.Add(panelTimeSlice)
try this:
bottomSizer.Add(panelStripCharts, 0, wx.EXPAND)
bottomSizer.Add(panelTimeSlice, 0, wx.EXPAND)
def createBottomPanel(self, parent, title):
panel = wx.Panel(parent, -1)
staticBox = wx.StaticBox(panel, -1, title)sizer = wx.StaticBoxSizer(staticBox, wx.VERTICAL)
panel.SetSizer(sizer)return panel, sizer
def OnCloseWindow(self, event):
self.Destroy()class App(wx.App):
def OnInit(self):
self.frame = Frame(parent=None, id=-1, title='Flight Test Data
Review')
self.frame.Show()
self.SetTopWindow(self.frame)
return Trueif __name__ == '__main__':
app = App(redirect=False)
app.MainLoop()
Christian