I have this simple program just for my understanding, and when I press "0" I enter into the "def func", it should change the background of the button to red, then wait 3 seconds and print "hello", but when I run it and I press "0", the program first sleeps 3 seconds, and then changes the background and then prints "hello", why?? It should first change the background and then execute the other lines. You can try copying my code:
import time
from tkinter import *
window = Tk()
window.geometry("500x300")
def func(event):
button.configure(bg="Red")
time.sleep(3)
print("hello")
button= Button(window,text= "Hello", font= ('Helvetica 20 '),width=5,height=1,bg="#008BC7")
window.bind("0", func)
button.pack()