WxPython; Disable buttons?

I have a list of buttons, and I did a loop to find out which button is pressed, then disable this button when pressed.

Here is the code snippet:

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 each widget, not just the button that is pressed. How can I disable only the pressed button?

thanks

+4
source share
1 answer

you can get your object from an event:

 def change(self, event): myobject = event.GetEventObject() myobject.Disable() 
+11
source

Source: https://habr.com/ru/post/1382148/


All Articles