This started out as a fork of the progress bar class which I first hosted on ActiveState Code.
It builds a text progress bar and displays it with the draw()
method.
The methods are showcased below:
from progressBar import progressBar
# Initiates the progessBar
prog = progressBar(maxValue = 50)
# Uses appendAmount to set current value (20).
prog.updateAmount(20)
# Draws the progress bar only if it has changed from previous draw() call.
prog.draw()
# Uses appendAmount to increment the current value (20+2).
prog.appendAmount(2)
# Draws the progress bar only if it has changed from previous draw() call.
prog.draw()
# Uses updatePercentage to set the percentage to the given value (74% of 50).
prog.updatePercentage(74)
# Draws the progress bar only if it has changed from previous draw() call.
prog.draw()
A typical usage would be to give progress information on network operations, such as a file copy. The maxValue would be set to the size of the file to transfer, and since the operation is buffered, the length of the buffered would be added to the value using appendAmount(buffer)
on each iteration.