Home > database >  how to correctly disable tkinter button
how to correctly disable tkinter button

Time:12-08

I have assigned a function to my ttk button and I'm trying to disable the button before do_something_else() runs:

def do_something():

    button.config(state='disabled')
    do_something_else()


button = ttk.Button(mainframe, text="Click Me", command=do_something, state="normal")

The above doesn't disable the button until do_something_else() is finished. How do I disable correctly? The behavior I want to achieve is to disable the button -> run do_something_else() - > re-enable the button.

CodePudding user response:

You can call button.update_idletasks() to force tkinter to refresh the display.

  • Related