A minimal progress bar for Python.
Make sure you are using Python 3.3 and your terminal supports ANSI Escape Codes.
pip install loadig
(Yes, loading was taken.)
from loadig import Bar
Pass the total value (your 100%). You can pass a message to display above the bar. shutil
is used to get the number of columns in your terminal. If you know what you want in life, you can also pass a number of columns to use.
bar = Bar(total=100)
bar = Bar(100, message="Loading...")
bar = Bar(100, columns=80)
Pass a number or string to update the bar or message, respectively. If nothing is passed, the value -not percentage- is inceremented by one.
bar.update() # Increment by one
bar.update(23) # Set values explicitly
bar.update("Damn, still loading...") # Update the message
The cursor is always kept under the bar so you don't have to worry about going to a new line before you... well, do other things. Anyway, you can get rid of it.
bar.clear()