The widget ttk.progress
is useful when dealing with long computations so that the user knows that the program is running. Following, an example updating a progressbar each 0.5 seconds is given:
def progress(currentValue):
progressbar["value"]=currentValue
maxValue=100
progressbar=ttk.Progressbar(master,orient="horizontal",length=300,mode="determinate")
progressbar.pack(side=tk.TOP)
"determinate" mode is used when the progressbar is under control of the program.
currentValue=0
progressbar["value"]=currentValue
progressbar["maximum"]=maxValue
divisions=10
for i in range(divisions):
currentValue=currentValue+10
progressbar.after(500, progress(currentValue))
progressbar.update() # Force an update of the GUI