wx.SplitterWindow(parent=self, id=-1, style=wx.SP_LIVE_UPDATE | wx.SP_NOBORDER)进行左右分割
self.right_panel = wx.Notebook(self.swindow) # 右边主界面
self.left_panel = wx.Panel(parent=self.swindow) # 左边界面
self.swindow.SplitVertically(self.left_panel, self.right_panel, 100) # 实现布局分割
import wx
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, size=(400, 500))
self.Center()
# 创建一个GridSizer布局参数(rows, cols, vgap, hgap) 行数、列数、垂直间隔、水平间隔
self.swindow = wx.SplitterWindow(parent=self, id=-1, style=wx.SP_LIVE_UPDATE | wx.SP_NOBORDER)
self.right_panel = wx.Notebook(self.swindow) # 右边主界面
self.right_panel.SetBackgroundColour('white')
self.left_panel = wx.Panel(parent=self.swindow) # 左边界面
self.left_panel.SetBackgroundColour('white')
self.swindow.SplitVertically(self.left_panel, self.right_panel, 100)
self.swindow.SetMinimumPaneSize(0)
self.Left_OnClick()
def Left_OnClick(self):
button1 = wx.Button(self.left_panel, -1, '按钮1', size=(50, 50))
button2 = wx.Button(self.left_panel, -1, '按钮2', size=(50, 50))
button1.Bind(wx.EVT_BUTTON, self.Right_OnClick_1)
button2.Bind(wx.EVT_BUTTON, self.Right_OnClick_2)
vsizer_all = wx.BoxSizer(wx.VERTICAL)
vsizer_all.Add(button1, proportion=0, flag=wx.CENTER | wx.TOP) # , flag=wx.CENTER | wx.TOP
vsizer_all.Add(button2, proportion=0, flag=wx.CENTER | wx.TOP)
self.left_panel.SetSizer(vsizer_all)
self.title2 = wx.StaticText(self.right_panel, -1, '按钮二界面', pos=(165, 40))
def Right_OnClick_1(self, evt):
self.title1 = wx.StaticText(self.right_panel, -1, 'qweqweqwe', style=wx.ALIGN_CENTER, pos=(50, 50))
self.title1.SetForegroundColour('#414956') # 修改字体颜色
self.title2.Hide()
def Right_OnClick_2(self, evt):
self.title2 = wx.StaticText(self.right_panel, -1, '按钮二界面', pos=(165, 40))
self.title1.Hide()
class MyAPP(wx.App):
def OnInit(self):
frame = MyFrame()
frame.Show(True)
return True
if __name__ == '__main__':
app = MyAPP()
app.MainLoop()