1
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title,size=(250, 250))
panel1 = wx.Panel(self, -1,pos=(0,100),size=(100,100))
button1 = wx.Button(panel1, -1, label="click me")
panel2 = wx.Panel(self, -1,pos=(0,200))
button2 = wx.Button(panel2, -1, label="click me")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(panel1,0,wx.EXPAND|wx.ALL,border=10)
sizer.Add(panel2,0,wx.EXPAND|wx.ALL,border=10)
self.SetSizer(sizer)
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'frame')
frame.Show(True)
return True
app = MyApp(0)
app.MainLoop()
我想在wxpython中测试两个面板布局,我更改pos(x,y)但它不起作用。所以 如何布局只是使用boxsizer和面板?wxpython两个面板布局
**如果您使用sizer,那么您不能提供x/y坐标来定位小部件**这是我没有注意到的问题,谢谢!无论如何,我学习Python与您的博客~~ – shch1289 2012-03-07 03:56:35
添加两种不同的颜色清楚其中的两个面板是^^ 'panel1.SetBackgroundColour(“#6f8089”)' – 2013-11-30 04:55:21
没错,就是检查面板定位的好方法之一。另一个是使用Widget检测工具。 – 2013-12-02 14:43:32