A Progress Bar helps to visualize the state of a running process. We have used and interacted with many progress bars such as getting the status of downloading a file from the internet, Loading a file on the local system, etc.
Let us suppose that we want to create and connect a progress bar in our application. We will create a full-width progress bar by using ProgressBar(win, options) method. It can be configured through a button that enables and disables it.
#Import the required Libraries from tkinter import * from tkinter import ttk import time #Create an instance of tkinter frame win= Tk() #Set the geometry win.geometry("750x250") #Define a function to Show a Progress Bar #Create a ProgressBar in a function def run_progress(): my_progress= ttk.Progressbar(win, orient= HORIZONTAL, length= 500, mode= 'determinate') my_progress['value']+=500 my_progress.pack(pady=40) button.config(state= "disable") #Create a Button button=ttk.Button(win, text= "Run",command= run_progress) button.place(x= 340, y= 100) win.mainloop()
Now run the above code to display a window that contains a progress bar.
In the given output, if we will click the "Run" Button, it will start running the Progress Bar.