Reputation:
I have a list of buttons and I have made a loop to find out what button is pressed, then disable that button on click.
Here is the snippet of code:
def change(self,event):
self.Disable()
for i in enumerate(file_pool):
self.button_pool.append(wx.Button(self.sizer, -1, i[1], pos=(20, i[0]*45),size=(200,40))) #this would create the list of buttons
for i in self.button_pool:
i.Bind(wx.EVT_BUTTON, self.change) #bind each button
However, this will Disable every widget, not just the pressed button. How can I only disable the clicked button?
Thanks
Upvotes: 5
Views: 14358
Reputation: 85603
you can get your object from the event:
def change(self, event):
myobject = event.GetEventObject()
myobject.Disable()
Upvotes: 13