I work on Python 3.10.2 and I just start to work with tkinter and I always have a problem with .after() method. For example with this program :
import tkinter as tk
def initialisation(compteur) :
compteur=compteur 1
print(compteur)
root.after(2000,initialisation, compteur)
root=tk.Tk()
initialisation(0)
root.mainloop()
I have this error :
1
invalid command name "1720125185344initialisation"
while executing
"1720125185344initialisation"
("after" script)
2
3
It works but I still have this error 1 time. I have looked for solutions but I don't understand. Thank you in advance for your help.
CodePudding user response:
try adding del root
at the end of the script:
import tkinter as tk
def initialisation(compteur) :
compteur=compteur 1
print(compteur)
root.after(2000,initialisation, compteur)
root=tk.Tk()
initialisation(0)
root.mainloop()
del root