gpt4 book ai didi

python - 用wxpython重新绑定(bind)按钮

转载 作者:太空宇宙 更新时间:2023-11-03 23:48:42 25 4
gpt4 key购买 nike

我有这个按钮:

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

并且需要在为示例选择特定单选按钮时将其绑定(bind)到另一个函数:

def onRadiobutton(self,event) :

if choosen radio button :

bind the mybutton to another function

我该怎么做?

最佳答案

您可以使用 Unbind()方法将您的按钮与其处理程序解除绑定(bind),然后只需以正常方式绑定(bind)到您想要的任何其他方法。

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)

关于python - 用wxpython重新绑定(bind)按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3681068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com