0

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.

EDIT

Accepted answer is correct, for more details refer to Tkinter Button still responds to click after being disabled and updated

0

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

this did not work for me :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.