I have this code:
from tkinter import * from tkinter.scrolledtext import ScrolledText def do(): global text for i in range(0, 10): time.sleep(0.5) text.insert(INSERT, i) root = Tk() global text text = ScrolledText(root) text.grid() button = Button(root, text = 'insert', command = do) button.grid(row = 1, column = 0) root.mainloop()
It does a simple job. it has to open the root window and add a number to it every second, but it does it all at once and after the loop is done. Strange behavior.
Source: Python Questions