我试图创造这个:
|---------------------------------------------|
| Panel 1a | Panel 2a | Panel 3 |
| | | |
| | | |
|-----------------------------------| |
| Panel 1b | Panel 2b | |
| | | |
|---------------------------------------------|
到目前为止,我只能创建它:
|---------------------------------------------|
| Panel 1a | Panel 2a | Panel 3 |
| | | |
| | | |
|---------------------------------------------|
如何将面板1a和面板2a分成两半?用分离器?
我的代码如下:
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()
答案 0 :(得分:0)
布局管理的基本概念是容器和小部件。在容器中,您可以放置其他容器和小部件。要完成给定的布局,您必须以巧妙的方式在层次结构中组织容器和小部件。由于您提供的代码仍然不完整,我将不会为您提供完整的解决方案,而是回答您如何拆分两个面板的问题。
panel1
,panel2
和panel3
。看来你到目前为止已经到了。BoxSizer
)panel1a
和panel1b
,其中panel1
为父级。将小部件放在这两个面板中。panel2a
和panel2b
,其中panel2
为父级。将小部件放在这两个面板中。Splitter
(仅当您希望使其可调整大小时。在这种情况下,panel1
和panel2
将被拆分器替换。阅读{{ 3}}了解详情)可视化:
+ mainframe (horizontal layout)
|
+-panel1 (vertical layout)
| +-panel1a
| +-panel1b
|
+-panel2 (vertical layout)
| +panel2a
| +panel2b
|
+-panel3