最近在学习使用wxpython,想通过panel来分出不同的区块来进行单独布局
却发现,当我在panel中嵌套了一个panel,在这个嵌套的panel中使用boxsizer进行布局没有效果
代码如下:
import wx
app = wx.App()
frame = wx.Frame(None,wx.ID_ANY, 'simple.py')
panel = wx.Panel(frame,wx.ID_ANY)
boxsizer = wx.BoxSizer(wx.VERTICAL)
panel.SetSizer(boxsizer)
button1 = wx.Button(panel,wx.ID_ANY,'aaaaa')
button2 = wx.Button(panel,wx.ID_ANY,'bbbbb')
boxsizer.Add(button1)
boxsizer.Add(button2)
panel2 = wx.Panel(panel,wx.ID_ANY,style=wx.BORDER_DOUBLE,size = wx.Size(300,300))
panel2.SetBackgroundColour('#00ff00')
boxsizer.Add(panel2)
boxsizer2 = wx.BoxSizer(wx.VERTICAL)
panel2.SetSizer(boxsizer)
button3 = wx.Button(panel2,wx.ID_ANY,'ccccc')
button4 = wx.Button(panel2,