Loading Progress Bar
Example 1:
import time
import sys
toolbar_width = 40
# setup toolbar
sys.stdout.write("[%s]" % (" " * toolbar_width))
sys.stdout.flush()
sys.stdout.write("\b" * (toolbar_width+1)) # return to start of line, after '['
for i in xrange(toolbar_width):
time.sleep(0.1) # do real work here
# update the bar
sys.stdout.write("-")
sys.stdout.flush()
sys.stdout.write("]\n") # this ends the progress bar
Example 2:
The code below can be adapted to fit your needs by customizing: bar progress symbol '#', bar size, text prefix etc.
Usage:
Output:
Example 3:
Try progress from https://pypi.python.org/pypi/progress.
The result will be a bar like the following:
Example 3:
Try PyProg. PyProg is an open-source library for Python to create super customizable progress indicators & bars.It is currently at version 1.0.2; it is hosted on Github and available on PyPI (Links down below). It is compatible with Python 3 & 2 and it can also be used with Qt Console.
It is really easy to use. The following code:
Output:
You can easily install it with: pip install pyprog.
PyProg Github: https://github.com/Bill13579/pyprog PyPI: https://pypi.python.org/pypi/pyprog/
Last updated
Was this helpful?