Im Trying to create this:
|---------------------------------------------|
| Panel 1a | Panel 2a | Panel 3 |
| | | |
| | | |
|-----------------------------------| |
| Panel 1b | Panel 2b | |
| | | |
|---------------------------------------------|
So far I can only create this:
|---------------------------------------------|
| Panel 1a | Panel 2a | Panel 3 |
| | | |
| | | |
|---------------------------------------------|
How can I split panel 1a and Panel 2a in half? with a splitter?
My code is as follows:
import wx
class TestSashWindow(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
winids = []
leftwin1 = wx.SashLayoutWindow(self, -1, wx.DefaultPosition, (200, 30), wx.NO_BORDER|wx.SW_3D)
leftwin1.SetDefaultSize((120, 1000))
leftwin1.SetOrientation(wx.LAYOUT_VERTICAL)
leftwin1.SetAlignment(wx.LAYOUT_RIGHT)
leftwin1.SetSashVisible(wx.SASH_LEFT, True)
self.leftWindow1 = leftwin1
winids.append(leftwin1.GetId())
self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)
leftwin2 = wx.SashLayoutWindow(self, -1, wx.DefaultPosition, (200, 30), wx.NO_BORDER|wx.SW_3D)
leftwin2.SetDefaultSize((120, 1000))
leftwin2.SetOrientation(wx.LAYOUT_VERTICAL)
leftwin2.SetAlignment(wx.LAYOUT_LEFT)
leftwin2.SetSashVisible(wx.SASH_RIGHT, True)
self.leftWindow2 = leftwin2
winids.append(leftwin2.GetId())
self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)
self.Bind(wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag,id=min(winids), id2=max(winids))
self.Bind(wx.EVT_SIZE, self.OnSize)
slw = leftwin1
x = wx.Notebook(slw, -1)
for i in xrange(2):
x.AddPage(wx.Panel(x, -1), str(i))
class mainframe(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, size=(400,300), title="sash test")
self.a = TestSashWindow(self)
if __name__ == '__main__':
a = wx.App(0)
b = mainframe()
b.Show(1)
a.MainLoop()
The generell concept of layout management are containers and widgets. In containers you can place other containers and widgets. To accomplish the given layout, you have to organize your containers and widgets in a hierarchy in a clever way. Since your supplied code is still incomplete, I’ll won’t provide you with a full solution, but rather answer your question how you can split both panels.
panel1,panel2andpanel3. It seems you’ve gotten so far.BoxSizer)panel1aandpanel1bwithpanel1as parent. Place widgets in these two panels as wanted.panel2aandpanel2bwithpanel2as parent. Place widgets in these two panels as wanted.Splitter(only if you wish to make them resizable. In that case,panel1andpanel2are replaced by splitters. Read this example for details)Visualization: