wxPython入门第一课--create a panel and a button

我参考的的是youtu上的视频教程 ,这个仅仅作为一个个人的学习笔记作为参考

https://www.youtube.com/watch?v=8v52QIP4L9Y&list=PLejTrt5hn2r1uzZ53GDeUElXRkRFbUmQd&index=3

上面就是链接 

import wx
class bucky(wx.Frame):      

    #结构函数,这样就没必要每次都要单独执行一下
    def __init__(self,parent,id):  
        wx.Frame.__init__(self,parent,id,'Frame aka window',size=(300,200))
    #上面这个就是直接弹出这个框的用的 初始化用的,  这样就是不用 用命令的

        #making a  panel
        panel=wx.Panel(self)   # self
        button=wx.Button(panel,label='exit',pos=(130,10),size=(60,60))
        self.Bind(wx.EVT_BUTTON ,self.closebutton,button)
        #三个参数分别是干嘛的  第一个 表示类型是 按键按一下
                        #第二个 表示的是 做什么事情,这是函数需要自己去写
                        #第三个参数表示的应用在哪个东西上 这里是应用在button上这个按键
        self.Bind(wx.EVT_CLOSE,self.closewindow)
    def closebutton(self,event):
        self.Close(True)
    def closewindow(self,event):
        self.Destroy()  #Detroy  class

if __name__=='__main__':
    app=wx.App()
    frame=bucky(parent=None,id=-1)
    frame.Show()
    app.MainLoop()   #这个是用来执行这个 alpplication 的   

猜你喜欢

转载自blog.csdn.net/weixin_42066185/article/details/81170852
今日推荐