I am writing a function that should put one character every .2 seconds into a tkinter Text widget. Unfortunately when I run this function the program hangs for every character all at once and then inserts the entire string instead of iterating normally.
def put(win, text):
#win is a tkinter Text object
#text is a string of text
#split text to an array of characters
output = list(text)
for i in range(len(output)):
sleep(0.2)
win.insert(END, output[i], )
EDIT: this does not work either, results are the same
def put(win, text):
#win is a tkinter TExt object
#text is a string of text
for char in text:
win.after(200, win.insert(END, char))
EDIT 2: this just hangs
def put(win, text):
#win is a tkinter TExt object
#text is a string of text
def place(win, char):
win.insert(END, char)
for char in text:
win.after(200,lambda: put(win, 'z'))