def __init__(self, *args, **kwargs):
wx.Panel.__init__(self, *args, **kwargs)
## add a button:
theButton1 = wx.Button(self, label="Push Me")
theButton1.Bind(wx.EVT_BUTTON, self.onButton)
## add another button:
theButton2 = wx.Button(self, label="Push Me Also")
theButton2.Bind(wx.EVT_BUTTON, self.onButton)
## do the layout
buttonSizer = wx.BoxSizer(wx.VERTICAL)
buttonSizer.Add((1,1), 1) # stretchable space
buttonSizer.Add(theButton1, 0, wx.GROW | wx.ALL, 4)
buttonSizer.Add(theButton2, 0, wx.GROW | wx.ALL, 4)
buttonSizer.Add((1,1), 3) # stretchable space
## need another sizer to get the horizonal placement right:
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
mainSizer.Add((1,1), 1) # stretchable space
mainSizer.Add(buttonSizer, 0, wx.GROW) # the sizer with the buttons in it
mainSizer.Add((1,1), 1) # stretchable space
self.SetSizer(mainSizer)
评论列表
文章目录