pythonevent-handlingwxpython

How do I disable a button after it's clicked in wxpython?


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!


Solution

  • Use the button's Enable and Disable methods in the appropriate event handlers. There's a sample available at the link below:

    wxPython Button Demo

    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.