Tutorial

Build a progress bar that shows how much work is left and keeps printed messages readable. These five steps add one change at a time. Each step includes the complete Python source and an example you can run in your browser.

The recordings below show the output of each step. Scroll a recording horizontally if the terminal is wider than your screen.

1. Turn a loop into a progress bar

See each item move the bar towards 100%, with an elapsed time and an estimate of the time remaining. Wrap your iterable with progressbar.progressbar() to let it track the loop for you.

2. Decide when progress moves

Keep a visible activity indicator even when you don’t know the total. Call bar.update() yourself whenever your work advances.

3. Show how much work is left

Give the bar a max_value to replace the activity indicator with a percentage and an ETA. The same updates now show how close you are to finishing.

4. Choose what your bar shows

Build a shorter display with just a percentage, a bar and an ETA. A widgets list sets the details and their order, including the spaces between them.

5. Print messages above the bar

Keep Reached step messages on their own lines while the bar updates underneath. Add redirect_stdout=True so your loop can print without overwriting the progress display.

After step 5, the how-to guides cover file transfers, several jobs at once and other specific tasks.