I cannot figure out why my hierarchical layout is not doing as I expect in wxPython.
The basic idea is as follows:
+- Win1 ------+ +- Win2 -----+ +- Win3 ----------+ | | | | | | +-------------+ +------------+ +-----------------+ +- Win4 ----------+ +- Win5 ---------------------+ | | | | +-----------------+ +----------------------------+ +- Win6 -----------------------------------------+ | | +------------------------------------------------+ I am creating a vertical box layout to handle the three regions {1/2/3, 4/5, 6}. Inside each of those regions is another (horizontal) box layout to handle (in the first region, for example) the {1, 2, 3} sub-regions.
Then, inside each of those sub-regions, I have a static box sizer to give me the border with a multi-line, non-user-editable, text control.
Now the code below has been simplified down to two rows with two columns in the first row and one in the second. Only the first column in the first row is an attempt at drawing the nice-border control, the others are just static text controls.
import wx class MyFrame(wx.Frame): def __init__(self, title): wx.Frame.__init__(self, None, title=title, pos=(150,50), size=(1720,930)) self.Bind(wx.EVT_CLOSE, self.OnClose) self.topPanel = wx.Panel(self, wx.ID_ANY) self.screenPanel = wx.Panel(self.topPanel, wx.ID_ANY) self.spacer0 = wx.StaticText(self.topPanel, wx.ID_ANY, "") self.dummy1 = wx.StaticText(self.topPanel, wx.ID_ANY, "dummy1") self.dummy2 = wx.StaticText(self.topPanel, wx.ID_ANY, "dummy2") self.topSizer = wx.BoxSizer(wx.VERTICAL) self.row1Sizer = wx.BoxSizer(wx.HORIZONTAL) self.row2Sizer = wx.BoxSizer(wx.HORIZONTAL) self.screenSizer = wx.StaticBoxSizer(wx.HORIZONTAL, self.screenPanel, "Screen") self.screen = wx.TextCtrl(self.screenPanel, wx.ID_ANY, "This is the first line\nXYZZY\nPLUGH", wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE | wx.TE_READONLY) self.row1Sizer.Add(self.screenSizer, 0, wx.ALL, 5) self.row1Sizer.Add(self.spacer0, 1, wx.ALL, 5) self.row1Sizer.Add(self.dummy1, 0, wx.ALL, 5) self.row2Sizer.Add(self.dummy2, 0, wx.ALL, 5) self.topSizer.Add(self.row1Sizer, 0, wx.ALL | wx.EXPAND, 5) self.topSizer.Add(self.row2Sizer, 0, wx.ALL | wx.EXPAND, 5) self.screenPanel.SetSizer(self.screenSizer) self.topPanel.SetSizer(self.topSizer) self.topPanel.Layout() def OnClose(self, event): self.Destroy() app = wx.App() top = MyFrame("My") top.Show() app.MainLoop() However, there appears to be some problems which I think may be caused by my confusion over whether sizers or non-sizers should own the resources being controlled, but I cannot get it to behave. The code as it stands gives me:
As you can see, the static box appears to be missing from around the first control, and the sizing appears screwed up. I would have thought the size would be calculated on layout so that it was at least large enough to hold the inner control and border.
Can anyone let me know what I'm doing wrong with this code?
It's also crashing on exit, which may be related. If not, I can handle that as a separate issue.



