参考地址:
http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.SplitterWindow.html#SetSashPosition
https://wiki.wxwidgets.org/WxSplitterWindow
如上图,SplitterWindow 的子元素必须是Window的一个实例,或者继承实现了Window,例如Panel控件
SplitterWindow 案例代码如下(部分代码省略):
splitter = wx.SplitterWindow(self.frame, wx.ID_ANY)
panel1 = wx.Panel(splitter, wx.ID_ANY)
b = wx.BoxSizer(wx.HORIZONTAL)
self.text = wx.TextCtrl(panel1,size=(500,wx.EXPAND), style=(wx.TE_MULTILINE | wx.TE_BESTWRAP | wx.TE_WORDWRAP))
b.Add(self.text, 1, wx.EXPAND)
panel2 = wx.Panel(splitter, wx.ID_ANY)
languages = ['C', 'C++', 'Java', 'Python', 'Perl','JavaScript', 'PHP', 'VB.NET', 'C#']
lst = wx.ListBox(panel2, choices=languages)
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
hbox1.Add(lst, 1)
panel2.SetSizer(hbox1)
splitter.SplitVertically(panel2, panel1)
splitter.SetSashPosition(200) #设置水平分割的位置
运行结果如下: