运行效果图:


Python代码:

#!/usr/bin/env python
# -*- encoding:utf-8 -*-
'Create Button Example'

import wx

class MyFrame(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'Create Button',pos=(300,200),size=(300,200))
        panel=wx.Panel(self)
        button=wx.Button(panel,label='Exit',pos=(120,10),size=(60,60))
        self.Bind(wx.EVT_BUTTON,self.closebutton,button)
        self.Bind(wx.EVT_CLOSE,self.closewindow)

    def closebutton(self,event):
        self.Close(True)

    def closewindow(self,event):
        self.Destroy()

if __name__=='__main__':
    app=wx.PySimpleApp()
    myframe=MyFrame(parent=None,id=-1)
    myframe.Show(True)
    app.MainLoop()


Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐