I use this answer to display progress bar:
The methods used:
def startProgress(title):
global progress_x
sys.stdout.write(title + ": [" + "-"*50 + "]" + chr(8)*51)
sys.stdout.flush()
progress_x = 0
def progress(x):
global progress_x
x = int(x * 50 // 100)
sys.stdout.write("#" * (x - progress_x))
sys.stdout.flush()
progress_x = x
def endProgress():
sys.stdout.write("#" * (50 - progress_x) + "]\n")
sys.stdout.flush()
An example of use:
import time
import sys
startProgress("Test")
for i in range(500):
progress(i * 100 / 500)
time.sleep(.1)
endProgress()
The progress will look like this with the #
moving at the same time of the progress:
