我在面板中创建了3个按钮,它们都有相同的onclick事件,现在我必须找到哪个按钮调用onclick事件及其ID
k=5
j=400
for i in range(k):
j=j+20
self.Bind(wx.EVT_BUTTON,self.OnButton2Button,id=j)
def OnButton2Button(self,event):
#what should i code here to get id or name of button which raised click event
答案 0 :(得分:1)
对象本身怎么样?
button = event.GetEventObject()
然后,您可以拨打GetId()
,GetName()
,GetLabel()
...