我已经做了一个小例子来说明我想要实现的是一个 StaticBoxSizer,它有一个可以设置的固定边框宽度。以下示例显示了几个静态框对象,但是,您如何调整它们的边框宽度/厚度?
任何其他sizer可以做同样的工作吗?即在他们的孩子周围提供可调节宽度的边框?
import wx
class mypanel(wx.Panel):
def __init__ (self, parent):
wx.Panel.__init__(self, parent, size=(-1, -1))
mysizer4 = wx.BoxSizer(orient=wx.HORIZONTAL)
box1 = wx.StaticBox(self, size=(-1,-1), style=wx.SUNKEN_BORDER)
box2 = wx.StaticBox(self, size=(-1,-1), style=wx.SUNKEN_BORDER)
box3 = wx.StaticBox(self, size=(-1,-1), style=wx.SUNKEN_BORDER)
mysizer = wx.StaticBoxSizer(box1, orient=wx.HORIZONTAL)
mysizer2 = wx.StaticBoxSizer(box2, orient=wx.VERTICAL)
mysizer3 = wx.StaticBoxSizer(box3, orient=wx.HORIZONTAL)
mybutton = wx.Button(self, size=(-1,-1), label="hello")
mybutton2 = wx.Button(self, size=(-1,-1), label="hello")
mybutton3 = wx.Button(self, size=(-1,-1), label="hello")
mytext1 = wx.StaticText(self, label="hello")
mytext2 = wx.StaticText(self, label="bye")
mytext3 = wx.StaticText(self, label="hello")
mytext4 = wx.StaticText(self, label="bye")
mytext5 = wx.StaticText(self, label="hello")
mytext6 = wx.StaticText(self, label="bye")
mysizer.Add(mybutton, flag=wx.EXPAND)
mysizer.Add(mytext1, flag=wx.EXPAND)
mysizer.Add(mytext2, flag=wx.EXPAND)
mysizer2.Add(mybutton2, flag=wx.EXPAND)
mysizer2.Add(mytext3, flag=wx.EXPAND)
mysizer2.Add(mytext4, flag=wx.EXPAND)
mysizer3.Add(mybutton3, flag=wx.EXPAND)
mysizer3.Add(mytext5, flag=wx.EXPAND)
mysizer3.Add(mytext6, flag=wx.EXPAND)
mysizer4.Add(mysizer)
mysizer4.Add(mysizer2)
mysizer4.Add(mysizer3)
self.SetSizer(mysizer4)
class myframe(wx.Frame):
def __init__(self):
"Constructor. No arguments"
wx.Frame.__init__(self, None, size=(-1,-1))
sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
mydiag = mypanel(self)
sizer.Add(mydiag)
self.SetSizer(sizer)
if __name__ == "__main__":
app = wx.App()
region = myframe()
region.Show()
app.MainLoop()