Python Tkinter GUI Progressbar Widget with Animation Indicator Full Tutorial For Beginners

Python Tkinter GUI Progressbar Widget with Animation Indicator Full Tutorial For Beginners

 

Welcome folks today in this blog post we will be making a progressbar widget with animation indicator in tkinter using python. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to install the following library using the pip command as shown below

 

pip install tkinter

 

After installing this library make an app.py file and copy paste the following code

 

With Determinate Mode

 

app.py

 

# 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()

 

See also  Python 3 Script to Count the Number of Vowels in a String Full Project For Beginners

Now if you execute the python script by typing the below command as shown below

 

python app.py

 

 

 

 

Indeterminate Mode

 

See also  Python 3 Tkinter Displaying Multiple Items in Listbox Widget With Scrollbar GUI Desktop App Full Project For Beginners

 

app.py

 

 

# 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()

 

See also  Python 3 Script to Check Whether a Number given by User is Prime or Not Full Tutorial For Beginners

 

 

Leave a Reply