Progressbar widget in Tkinter | Python (original) (raw)
Last Updated : 01 May, 2019
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
from
tkinter
import
*
from
tkinter.ttk
import
*
root
=
Tk()
progress
=
Progressbar(root, orient
=
HORIZONTAL,
`` length
=
100
, mode
=
'determinate'
)
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
)
Button(root, text
=
'Start'
, command
=
bar).pack(pady
=
10
)
mainloop()
Output:
Code #2: In indeterminate mode
from
tkinter
import
*
from
tkinter.ttk
import
*
root
=
Tk()
progress
=
Progressbar(root, orient
=
HORIZONTAL,
`` length
=
100
, mode
=
'indeterminate'
)
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
)
Button(root, text
=
'Start'
, command
=
bar).pack(pady
=
10
)
mainloop()
Output:
Similar Reads
Basic Tkinter Widget
- Python Tkinter - Label Tkinter Label is a widget that is used to implement display boxes where you can place text or images. The text displayed by this widget can be changed by the developer at any time you want. It is also used to perform tasks such as underlining the part of the text and spanning the text across multipl 4 min read
- Python Tkinter - Create Button Widget The Tkinter Button widget is a graphical control element used in Python's Tkinter library to create clickable buttons in a graphical user interface (GUI). It provides a way for users to trigger actions or events when clicked. Note:Â For more reference, you can read our article: What is WidgetsPython 6 min read
- Python Tkinter - Entry Widget Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task.In Python3 Tkinter is come 5 min read
- Python Tkinter - Frame Widget Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applicatio 3 min read
- Python Tkinter - Checkbutton Widget The Checkbutton widget is a standard Tkinter widget that is used to implement on/off selections. Checkbuttons can contain text or images. When the button is pressed, Tkinter calls that function or method. Note:Â For more reference, you can read our article, What is WidgetsPython Tkinter OverviewPytho 5 min read
- RadioButton in Tkinter | Python The Radiobutton is a standard Tkinter widget used to implement one-of-many selections. Radiobuttons can contain text or images, and you can associate a Python function or method with each button. When the button is pressed, Tkinter automatically calls that function or method.Syntax: button = Radiobu 4 min read
- Python Tkinter - ListBox Widget Tkinter is a GUI toolkit used in python to make user-friendly GUIs.Tkinter is the most commonly used and the most basic GUI framework available in python. Tkinter uses an object-oriented approach to make GUIs. Note: For more information, refer to Python GUI – tkinter ListBox widget The ListBox widg 2 min read
- Python-Tkinter Scrollbar Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applicat 3 min read