I'm a beginner and want to make a fast reading application with tkinter library. The app consists of a Start Button and speed Entry to show the user text in the Message widget. when Start Button press, an Event handler should run and show words based on given speed on the Message widget but the Message widget not changed until the event handler exit. for e.g. in following code the Message widget not changed until the do_something function end.
import tkinter as tk
import time
def do_something():
msg.configure(text = "changing")
for i in range(20):
time.sleep(1)
print("...")
print("exit of loop")
window = tk.Tk()
window.geometry("8x50")
window.rowconfigure([1,2], weight = 1, minsize = 10)
window.columnconfigure(1, weight = 1, minsize = 10)
global msg
msg = tk.Message(window, bg = 'grey' ,text = 'Hello', width = 50 )
btn = tk.Button(window, text='click me', width = 10, height = 1, command = do_something)
msg.grid(row = 1, column = 1, sticky = 'nswe')
btn.grid(row = 2, column = 1, sticky = 'nswe')
window.mainloop()
Now how can I justify this code to make the change immediately on widgets before event handler ending? Excuse me for my poor english