Ok so, I'm writing a program out of spite to animate text that is supposed to display letters like so on a loop: T
Th
Tho
Thom
Thoma
Thomas
Thomas s
Thomas su
Thomas suc...
and so on till it resets and then loops again. The problem is, the tkinter mainloop only seems to run once and then quits. Here's the code:
from tkinter import *
import time
def setting():
global thoms
if thoms.get() == "":
thoms.set("T")
return
if thoms.get() == "T":
thoms.set("Th")
return
if thoms.get() == "Th":
thoms.set("Tho")
return
if thoms.get() == "Tho":
thoms.set("Thom")
return
if thoms.get() == "Thom":
thoms.set("Thoma")
return
if thoms.get() == "Thoma":
thoms.set("Thomas")
return
if thoms.get() == "Thomas":
thoms.set("Thomas s")
return
if thoms.get() == "Thomas s":
thoms.set("Thomas su")
return
if thoms.get() == "Thomas su":
thoms.set("Thomas suc")
return
if thoms.get() == "Thomas suc":
thoms.set("Thomas suck")
return
if thoms.get() == "Thomas suck":
thoms.set("Thomas sucks")
return
if thoms.get() == "Thomas sucks":
thoms.set("")
return
window = Tk()
thoms = StringVar()
lbl = Label(window, textvariable=thoms)
lbl.grid(row=1, column=1)
setting()
time.sleep(1)
print("Run")
window.mainloop()
It sets the variable the first time to T and then stops, so I put in the print to see if it was looping, and it only prints to the console a single time. How do I fix this?