wxpython,一对一,事件源、事件类型、事件处理

import wx

class MyFrame(wx.Frame):
    def __init__(self):
        super().__init__(parent=None,title="yiduiyi",size=(300,400),pos=(100,100))
        self.Center()
        panel = wx.Panel(parent=self)
        self.statictext = wx.StaticText(parent=panel,pos=(100,10))
        b=wx.Button(parent=panel,label='OK',pos=(10,10))
        self.Bind(wx.EVT_BUTTON,self.on_click,b)	#wx.EVT_BUTTON是按钮单击事件类型,self.on_click是事件处理,b是事件源
    def on_click(self,event):
        print(event)
        self.statictext.SetLabel("shanghai_life")
class App(wx.App):
    def OnInit(self):
        frame = MyFrame()
        frame.Show()
        return True
    def OnExit(self):
        print("tuichu")
        return 0

if __name__ == '__main__':
    app=App()
    app.MainLoop()

wxpython 绑定事件
wxpython 绑定事件

相关文章:

  • 2020-01-20
  • 2022-12-23
  • 2022-02-09
  • 2021-10-13
  • 2018-04-14
  • 2022-12-23
  • 2021-12-28
猜你喜欢
  • 2022-03-02
  • 2021-07-24
  • 2021-12-17
  • 2021-06-08
  • 2021-06-25
相关资源
相似解决方案