1
我試圖創建一個面板,其中包含一些數據的四個框。這四個框應該有一個預定義的靜態大小。到目前爲止,我所擁有的四個框在某種程度上是重疊的。wxPython。用四個靜態大小的盒子創建一個面板
任何想法?
代碼:
import wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.pl = wx.Panel(self)
self.SetSize((500, 350))
sb = wx.StaticBox(self.pl, -1, 'BOX0', size=(180, 150))
sat = wx.CheckBox(self.pl, -1, 'Satellite')
gsm = wx.CheckBox(self.pl, -1, 'GSM')
wlan = wx.CheckBox(self.pl, -1, 'WLAN')
sb2 = wx.StaticBox(self.pl, -1, 'BOX1', size=(180, 150))
nm2 = wx.StaticText(self.pl, -1, 'default1')
sb3 = wx.StaticBox(self.pl, -1, 'BOX2', size=(180, 150))
nm3 = wx.StaticText(self.pl, -1, 'default2')
sb4 = wx.StaticBox(self.pl, -1, 'BOX3', size=(180, 150))
nm4 = wx.StaticText(self.pl, -1, 'default3')
box = wx.StaticBoxSizer(sb, wx.VERTICAL)
box.Add(sat, 0, wx.ALL, 5)
box.Add(gsm, 0, wx.ALL, 5)
box.Add(wlan, 0, wx.ALL, 5)
box2 = wx.StaticBoxSizer(sb2)
box2.Add(nm2, 0, wx.ALL, 5)
box3 = wx.StaticBoxSizer(sb3)
box3.Add(nm3, 0, wx.ALL, 5)
box4 = wx.StaticBoxSizer(sb4)
box4.Add(nm4, 0, wx.ALL, 5)
gs = wx.BoxSizer(wx.HORIZONTAL)
gs.Add(box)
gs.Add(box2)
gss = wx.BoxSizer(wx.HORIZONTAL)
gss.Add(box3)
gss.Add(box4)
gt = wx.BoxSizer(wx.VERTICAL)
gt.Add(gs)
gt.Add(gss)
self.pl.SetSizer(gt)
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, '08_gridsizer.py')
frame.Show()
self.SetTopWindow(frame)
return 1
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()