The progressbar is a common GUI element which is used to show the progress of certain task. In tis article we will see how to create a progressbar using the Python tkinter GUI library.
In the below program we have imported the progressbar sub-module of tkinter.ttk module. Then used the style object to create the style options and supply the value for the length of the button as well as value of the progress.
Example
import tkinter as tk from tkinter.ttk import Progressbar from tkinter import ttk canv = tk.Tk() canv.title("Tkinter Progressbar") canv.geometry('250x100') style = ttk.Style() style.theme_use('default') style.configure("grey.Horizontal.TProgressbar", background='blue') bar = Progressbar(canv, length=180, style='grey.Horizontal.TProgressbar') bar['value'] = 50 bar.grid(column=0, row=0) canv.mainloop()
Output
Running the above code gives us the following result −