Python Codes

Progress Bar in Python


Indian Bloggers

Applications would need a progress bar while the task is in progress. Python has a simple way of doing it using tkinter. Here are the specs this code adheres to:

Python version – 3.4
Front end using – tkinter

Here is how the output looks like:

progress-bar-image

from tkinter import *
import tkinter.ttk as ttk

# Get the Tk instance
root = Tk()

# Set the layout dimension
root.geometry("200x200")

# Title the window
root.title("Progress Bar Demo")

# Prepare the type of Progress bar needed.
# Look out for determinate mode and pick the suitable one
# Other formats of display can be suitably explored
processing_bar = ttk.Progressbar(root, orient='horizontal', mode='indeterminate')

# Place the bar at the centre of the window
processing_bar.place(relx=0.5, rely=0.5, anchor=CENTER)

# Start the bar.
# use processing_bar.stop() to stop it
processing_bar.start(30)

root.mainloop()
Advertisements

Let me Know What you Think!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s