wxPython, Disabling buttons?

13,646

you can get your object from the event:

def change(self, event):
    myobject = event.GetEventObject()
    myobject.Disable()
Share:
13,646
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    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