- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to connect a progress bar to a function in Tkinter?
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.
- Related Articles
- How to create a download progress bar in Tkinter?
- How to create a progress bar in HTML?
- How to change progress bar progress color in Android?
- How to create a progress bar using JavaFX?
- How to write Progress Bar in PowerShell?
- How to create progress bar in ReactJS?
- How to connect a variable to the Tkinter Entry widget?
- How to display progress bar while loading a url to webView in Android?
- How To Make a Circle Custom Progress Bar in Android using Kotlin?
- How To Make Circle Custom Progress Bar in Android?
- Animate a striped progress bar in Bootstrap
- How to create progress bar in different colors in Bootstrap
- Create a progress bar with Bootstrap
- Create a striped Bootstrap progress bar