wxpython onclick时改变按钮位置
如题,
button1 = wx.Button(panel, -1, u"yes", pos=(100,500))
self.Bind(wx.EVT_BUTTON, self.OnClick1, button1)
在onClick1方法中实现单击后改变按钮在面板上的位置,如何写代码,谢谢
[解决办法]
wxButton的父类wxWindow有Move, SetPosition等方法,不知道行不行。
[解决办法]
#coding:utf-8#test platform:windows7 32bit+python2.7+wxpython2.8.12.1import wx class myframe(wx.Frame): def __init__(self,parent,id,title): wx.Frame.__init__(self,parent,id,title,size=(300,200)) panel=wx.Panel(self,-1) self.btn1=wx.Button(panel,-1,'button1',pos=(50,50)) self.btn1.Bind(wx.EVT_BUTTON,self.OnClick) def OnClick(self,evt): try: btnpos=self.btn1.GetPosition() if btnpos==wx.Point(50,50): self.btn1.Move(wx.Point(100,100)) else: self.btn1.Move(wx.Point(50,50)) except Exception,ex: print ex if __name__=='__main__': app = wx.PySimpleApp() frame=myframe(None,-1,'title') frame.Show() app.MainLoop()