Why does adding a panel and placing widgets on that remove the minimum size constraint. When I place widgets on a panel, rather than the frame, I can resize the frame so small that the widgets are unable to be seen, and the sizers start acting strange (they get ‘greedy’, from regex lingo). For example, I took the second demo here:
http://stackoverflow.com/a/14001332/253127
and changed it just so the widgets are added to a Panel, rather than the Frame. In the original example, the Frame can’t be resized smaller than the contained widgets… but with the Panel, it can be sized much smaller.
import wx
class Frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title='BoxSizer demo (resize the frame)')
self.SetBackgroundColour(wx.WHITE)
self = wx.Panel(self)
layout = wx.StaticBoxSizer(wx.StaticBox(self,label="wx.VERTICAL"),wx.VERTICAL)
# row 1
row = wx.wx.StaticBoxSizer(wx.StaticBox(self,label="wx.HORIZONTAL - proportion=0"),wx.HORIZONTAL)
row.Add(wx.StaticText(self,label="proportion=0",style=wx.BORDER_DOUBLE),0, wx.ALL,10)
row.Add(wx.StaticText(self,label="proportion=1",style=wx.BORDER_DOUBLE),1, wx.ALL,10)
layout.Add(row) # add row 1 without arguments
# row 2
row = wx.StaticBoxSizer(wx.StaticBox(self,label="wx.HORIZONTAL - proportion=1"),wx.HORIZONTAL)
row.Add(wx.StaticText(self,label="proportion=1",style=wx.BORDER_DOUBLE),1, wx.ALL,10)
row.Add(wx.StaticText(self,label="proportion=2, wx.EXPAND",style=wx.BORDER_DOUBLE),2, wx.EXPAND|wx.ALL,10)
layout.Add(row,1) # add row 2 with proportion = 1
# row 3
row = wx.StaticBoxSizer(wx.StaticBox(self,label="wx.HORIZONTAL - proportion=0, wx.EXPAND"),wx.HORIZONTAL)
row.Add(wx.StaticText(self,label="proportion=0",style=wx.BORDER_DOUBLE),0, wx.ALL,10)
row.Add(wx.StaticText(self,label="proportion=1",style=wx.BORDER_DOUBLE),1, wx.ALL,10)
layout.Add(row,0,wx.EXPAND) # add row 3 with proportion = 0 and wx.EXPAND
self.SetSizerAndFit(layout)
app = wx.App(False)
Frame().Show()
app.MainLoop()