The purpose of this widget is to reassure the user that something is happening. It can operate in one of two modes –
In determinate mode, the widget shows an indicator that moves from beginning to end under program control.
In indeterminate mode, the widget is animated so the user will believe that something is in progress. In this mode, the indicator bounces back and forth between the ends of the widget.
Syntax:
widget_object = Progressbar(parent, **options)
Code #1 In determinate mode
# importing tkinter module from tkinter import * from tkinter.ttk import * # creating tkinter window root = Tk() # Progress bar widget progress = Progressbar(root, orient = HORIZONTAL, length = 100, mode = 'determinate') # Function responsible for the updation # of the progress bar value def bar(): import time progress['value'] = 20 root.update_idletasks() time.sleep(1) progress['value'] = 40 root.update_idletasks() time.sleep(1) progress['value'] = 50 root.update_idletasks() time.sleep(1) progress['value'] = 60 root.update_idletasks() time.sleep(1) progress['value'] = 80 root.update_idletasks() time.sleep(1) progress['value'] = 100 progress.pack(pady = 10) # This button will initialize # the progress bar Button(root, text = 'Start', command = bar).pack(pady = 10) # infinite loop mainloop() |
Output:
Code #2: In indeterminate mode
# importing tkinter module from tkinter import * from tkinter.ttk import * # creating tkinter window root = Tk() # Progress bar widget progress = Progressbar(root, orient = HORIZONTAL, length = 100, mode = 'indeterminate') # Function responsible for the updation # of the progress bar value def bar(): import time progress['value'] = 20 root.update_idletasks() time.sleep(0.5) progress['value'] = 40 root.update_idletasks() time.sleep(0.5) progress['value'] = 50 root.update_idletasks() time.sleep(0.5) progress['value'] = 60 root.update_idletasks() time.sleep(0.5) progress['value'] = 80 root.update_idletasks() time.sleep(0.5) progress['value'] = 100 root.update_idletasks() time.sleep(0.5) progress['value'] = 80 root.update_idletasks() time.sleep(0.5) progress['value'] = 60 root.update_idletasks() time.sleep(0.5) progress['value'] = 50 root.update_idletasks() time.sleep(0.5) progress['value'] = 40 root.update_idletasks() time.sleep(0.5) progress['value'] = 20 root.update_idletasks() time.sleep(0.5) progress['value'] = 0 progress.pack(pady = 10) # This button will initialize # the progress bar Button(root, text = 'Start', command = bar).pack(pady = 10) # infinite loop mainloop() |
Output:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- Python | Progressbar widget in kivy using .kv file
- Python | Menu widget in Tkinter
- Python | PanedWindow Widget in Tkinter
- Python Tkinter - Toplevel Widget
- Combobox Widget in tkinter | Python
- Python Tkinter - Entry Widget
- Python Tkinter - Checkbutton Widget
- Python Tkinter - ListBox Widget
- Python Tkinter - Scale Widget
- Python Tkinter - Text Widget
- Python Tkinter - Canvas Widget
- Python Tkinter - MessageBox Widget
- Python Tkinter - Menubutton Widget
- Python Tkinter - Frame Widget
- Creating Tabbed Widget With Python-Tkinter
- Python Tkinter - Validating Entry Widget
- Python Tkinter - ScrolledText Widget
- Python - ProgressBar in GTK+ 3
- Tkinter | Adding style to the input text using ttk.Entry widget
- Tkinter - Read only Entry Widget
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
