本文主要是介绍wxpython 添加一个button,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
转载请注出处 http://blog.csdn.net/ssihc0
显示一个自定义的Frame,里面一个close button
Bind 邦定事件
下面 看实现在代码,
import wx;
class InsertFrame(wx.Frame):def __init__(self,parent,id):wx.Frame.__init__(self,parent,id,'Frame With Button',size=(300,100));panel=wx.Panel(self);button=wx.Button(panel,label='Close',pos=(125,10),size=(50,50));self.Bind(wx.EVT_BUTTON,self.OnCloseMe,button);self.Bind(wx.EVT_CLOSE,self.OnCloseWindow);def OnCloseMe(self,event):self.Close(True);def OnCloseWindow(self,event):self.Destroy();
if __name__ == '__main__':app=wx.PySimpleApp();frame=InsertFrame(parent=None,id=-1);frame.Show();app.MainLoop();
这篇关于wxpython 添加一个button的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!