Reputation: 4983
There are two buttons in my little program, start and stop. And what I want is to disable the start button after I click it, and when I hit the stop button it should return to normal. How can I do this? I googled for a while and couldn't find the answer, hope you guys can help me out. Thanks!
Upvotes: 2
Views: 8415
Reputation: 13
You typically control the enable and disable properties of a button control like this
class yourForm ( wx.Frame ):
def __init__( self, parent ):
...
...
...
# Connect Events
self.btnStart.Bind( wx.EVT_BUTTON, self.OnButtonClick_btnStart )
self.btnStio.Bind( wx.EVT_BUTTON, self.OnButtonClick_btnStop )
# Virtual event handlers, override them in your derived class
def OnButtonClick_btnStart( self, event):
self.btnStart.Disable();
def OnButtonClick_btnStop( self, event):
self.btnStart.Enable();
Upvotes: 0
Reputation: 123508
Use the button's Enable
and Disable
methods in the appropriate event handlers. There's a sample available at the link below:
In this snippet we are playing around with wxPython's buttons, showing you how to bind the mouse click event, enable and disable, show and hide the buttons. Each button also has a tool-tip (hint) associated with itself.
Upvotes: 3