Fundamentals 6 min read

Using Python Progress Bar Libraries: Progress, tqdm, alive‑progress, and PySimpleGUI

This article demonstrates how to add simple yet powerful progress bars to Python command‑line scripts and graphical interfaces using four popular libraries—Progress, tqdm, alive‑progress, and PySimpleGUI—providing code examples, visual output, and links to documentation.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Using Python Progress Bar Libraries: Progress, tqdm, alive‑progress, and PySimpleGUI

Many developers think progress bars add unnecessary complexity, but they can be implemented with just a few lines of code in both command‑line scripts and GUI applications.

Below we explore four commonly used Python progress‑bar libraries and show how to integrate them into CLI scripts and a PySimpleGUI UI.

Progress

The first library introduced is Progress . You only need to define the number of iterations, choose a bar type, and update the bar on each iteration.

<code>import time
from progress.bar import IncrementalBar
mylist = [1,2,3,4,5,6,7,8]
bar = IncrementalBar('Countdown', max=len(mylist))
for item in mylist:
    bar.next()
    time.sleep(1)
    bar.finish()
</code>

The resulting bar displays an incremental progress indicator, and the library also supports several other bar styles, as documented at https://pypi.org/project/progress/1.5/ .

tqdm

The next library is tqdm , which offers a very similar usage pattern with a slightly different API.

<code>import time
from tqdm import tqdm
mylist = [1,2,3,4,5,6,7,8]
for i in tqdm(mylist):
    time.sleep(1)
</code>

tqdm produces a sleek progress bar in the terminal and provides several optional parameters for customization. Documentation is available at https://tqdm.github.io/ .

alive‑progress

As the name suggests, alive‑progress adds animated effects to make the progress bar more lively.

<code>from alive_progress import alive_bar
import time
mylist = [1,2,3,4,5,6,7,8]
with alive_bar(len(mylist)) as bar:
    for i in mylist:
        bar()
        time.sleep(1)
</code>

The visual output includes animated elements, and the project’s features are detailed on its GitHub page: https://github.com/rsalmei/alive-progress .

PySimpleGUI

Finally, PySimpleGUI allows you to create a graphical progress meter with just a single line of code inside a loop.

<code>import PySimpleGUI as sg
import time
mylist = [1,2,3,4,5,6,7,8]
for i, item in enumerate(mylist):
    sg.one_line_progress_meter('This is my progress meter!', i+1, len(mylist), '-key-')
    time.sleep(1)
</code>

A more elaborate example builds a window with a progress bar widget, an output area, and start/cancel buttons, demonstrating how to update the bar in real time. The code shows that integrating a progress bar into a Python GUI is straightforward and requires only a few lines.

In summary, adding a progress bar to a Python script is simple and does not add significant complexity; it provides immediate visual feedback on script execution.

For further learning, scan the QR code below to receive a free Python public‑course package containing e‑books, tutorials, projects, and source code.

CLIPythonprogress bartqdmProgressPySimpleGUIalive-progress
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.