Python progress bars and colors in a terminal


Text-based progress bars

If you ever need to create a progress bar in a Python script or terminal application there is nifty little library called progress. I especially like the wrapper around iterables:

1
2
3
4
5
from progress.bar import Bar

for item in Bar('Processing').iter(items):
  # Process the item
  your_processing_function(item)

which will show a nice, text-based progress bar:

Processing |#############                   | 42/100

Terminal colors

And if you want to add colors to your Python output, colorama is the way to go. Here is a usage-example from their docs:

1
2
3
4
5
6
7
from colorama import Fore, Back, Style

print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')

It also


See also