wxPython,禁用按钮?
我有一个按钮列表,并且我创建了一个循环来找出按下的按钮,然后在单击时禁用该按钮。
这是代码片段:
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
但是,这将禁用每个小部件,而不仅仅是按下的按钮。我怎样才能只禁用点击的按钮?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以从事件中获取你的对象:
you can get your object from the event: