Why is the progressbar starting after the print-commands?
I want to start the progressbar first. And wenn the 2nd print command ("After the sleep statement") was excecuted, I want to stop the progressbar. Any ideas?
from tkinter import Tk
from tkinter.ttk import Progressbar
import time
# root window
root = Tk()
root.geometry('300x120')
root.title('Progressbar Demo')
root.grid()
# progressbar
pb = Progressbar(
root,
orient='horizontal',
mode='indeterminate',
length=280 )
# place the progressbar
pb.grid(column=0, row=0, columnspan=2, padx=10, pady=20)
pb.start()
print("Before the sleep statement")
time.sleep(5)
print("After the sleep statement")
# pb.stop()
root.mainloop()
The current problem is that the progressbar is only started after time.sleep command.