Using Python Progress Bar Libraries: Progress, tqdm, alive‑progress, and PySimpleGUI
This article demonstrates how to add simple yet effective progress bars to Python command‑line scripts and GUI applications using four popular libraries—Progress, tqdm, alive‑progress, and PySimpleGUI—providing code examples, visual screenshots, and documentation links.
Many developers think progress bars add unnecessary complexity, but they can be added with just a few lines of Python code.
The article introduces four popular Python progress‑bar libraries—Progress, tqdm, alive‑progress, and PySimpleGUI—showing how to integrate them into command‑line scripts and graphical interfaces.
Progress example:
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()tqdm example:
import time
from tqdm import tqdm
mylist = [1,2,3,4,5,6,7,8]
for i in tqdm(mylist):
time.sleep(1)alive‑progress example:
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)PySimpleGUI graphical progress‑meter example:
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='-KEY-')
time.sleep(1)Each library offers different visual styles and configuration options, and the article provides links to their official documentation for further exploration.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.