开发者

Rebind button with wxpython

开发者 https://www.devze.com 2023-01-15 07:09 出处:网络
I have this button : self.mybutton= wx.Button(self, -1, label= \"mylabel\", pos=(100,180)) self.Bind(wx.EVT_BUTTON, self.Onbutton, self.mybutton)

I have this button :

 self.mybutton= wx.Button(self, -1, label= "mylabel", pos=(100,180))
 self.Bind(wx.EVT_BUTTON, self.Onbutton, self.mybutton)

and need to Bind it to another function whenspecifc radio butt开发者_JS百科on is choosen for exmaple :

def onRadiobutton(self,event) :

 if choosen radio button :

     bind the mybutton to another function 

How can i do it ?


You can use the Unbind() method to unbind your button from its handler then just bind to what ever other method you want the normal way.

def onButton(self, event):
    if yourRadioButton.GetValue() == True:
        self.Unbind(wx.EVT_BUTTON, handler=self.onButton, source=self.myButton)
        self.Bind(wx.EVT_BUTTON, self.someOtherHandler, self.myButton)
0

精彩评论

暂无评论...
验证码 换一张
取 消