Tkinter after method executing immediately

You are using after incorrectly. Consider this line of code:

root.after(3000, CheckStatus())

It is exactly the same as this:

result = CheckStatus()
root.after(3000, result)

See the problem? after requires a callable — a reference to the function.

The solution is to pass a reference to the function:

root.after(3000, CheckStatus)

And even though you didn’t ask, for people who might be wondering how to pass arguments: you can include positional arguments as well:

def example(a,b):
    ...
root.after(3000, example, "this is a", "this is b")

Leave a Comment