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 a static text lable:
label1 = wx.StaticText(self, label="Input Box:")
## add a text control:
self.inTextControl = wx.TextCtrl(self)
## add another button:
theButton2 = wx.Button(self, label="GetData")
theButton2.Bind(wx.EVT_BUTTON, self.onGetData)
## add a static text lable:
label2 = wx.StaticText(self, label="Output Box:")
## and another text control:
self.outTextControl = wx.TextCtrl(self, style=wx.TE_READONLY)
## do the layout
buttonSizer = wx.BoxSizer(wx.VERTICAL)
buttonSizer.Add(theButton1, 0, wx.GROW | wx.ALL, 4)
buttonSizer.Add(label1, 0, wx.ALIGN_LEFT | wx.TOP, 4)
buttonSizer.Add(self.inTextControl, 0, wx.GROW | wx.ALL, 4)
buttonSizer.Add((150, 10))
buttonSizer.Add(theButton2, 0, wx.GROW | wx.ALL, 4)
buttonSizer.Add(label2, 0, wx.ALIGN_LEFT | wx.TOP, 4)
buttonSizer.Add(self.outTextControl, 0, wx.GROW | wx.ALL, 4)
## 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.ALIGN_TOP) # the sizer with the buttons in it
mainSizer.Add((1,1), 1) # stretchable space
self.SetSizer(mainSizer)
评论列表
文章目录