consider the following code.
from tkinter import *
root = Tk()
def do_something():
print("hello")
root.after(100,do_something())
root.mainloop()
instead of calling the function do_something() every 100 milliseconds it stops after the first iteration
Is my understanding of root.after() wrong or am I making a mistake?
Any help will be appreciated.
>Solution :
You’re only executing the function once. To make it repeat, you should put root.after(100, do_something) in the function:
from tkinter import *
root = Tk()
def do_something():
print("hello")
root.after(100, do_something) # use do_something instead of do_something()
do_something()
root.mainloop()