运行这段代码,将生成一个简单的左右结果的框架,非常好用,需要wx.aui模块
# -*- coding: cp936 -*- # 2010-04-20 18:40 中国广州天河 # 如何实现动态布局 # source:http://stackoverflow.com/questions/523363/how-do-i-layout-a-3-pane-window-using-wxpython import wx import wx.aui class MyFrame(wx.Frame): def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.mgr = wx.aui.AuiManager(self) leftpanel = wx.Panel(self, -1, size = (200, 150)) rightpanel = wx.Panel(self, -1, size = (200, 150)) bottompanel = wx.Panel(self, -1, size = (200, 150)) self.mgr.AddPane(leftpanel, wx.aui.AuiPaneInfo().Bottom()) self.mgr.AddPane(rightpanel, wx.aui.AuiPaneInfo().Left().Layer(1)) self.mgr.AddPane(bottompanel, wx.aui.AuiPaneInfo().Center().Layer(2)) self.mgr.Update() class MyApp(wx.App): def OnInit(self): frame = MyFrame(None, -1, '使用ax.aui') frame.Show() self.SetTopWindow(frame) return 1 app = MyApp(0) app.MainLoop()