WxPython:按钮事件

2024-09-29 19:19:46 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有办法,我可以把两个事件按顺序绑定到一个按钮上。我的意思是:

在本例中,按钮1和2分别绑定到其事件。在

self.button1 = wx.Button(panel, -1, 'BUTTON1')
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1)

self.button2 = wx.Button(panel, -1, 'Button2')
self.button2.Bind(wx.EVT_BUTTON, self.OnButton2)


def OnButton1(self,event):
    a = 1
    b = 3
    print a+b # basically some commands
    # Here I want to execute OnButton2 EVENT - So I use the following LINE
    OnButton2(event)
    # But the above command should not be executed unless the OnButton2 event has processed in the past - (Meaning unless the Button2 event has happen in the past) So How would I solve that problem.
    # It should be like IF CONDITION (BUTTON 2 HAS BEEN PRESSED IN THE PAST) - EXECUTE: SOME BASIC COMMANDS LIKE PRINT "HELLO"

def OnButton2(self,event):
    c = 4
    d = 5
    print c*d

Tags: theselfeventbind事件button按钮evt

热门问题