Platforms: Unix, Linux
Module information :
Text progressbar library for python.
This library provides a text mode progressbar. This is tipically used to display the progress of a long running operation, providing a visual clue that processing is underway.
The ProgressBar class manages the progress, and the format of the line is given by a number of widgets. A widget is an object that may display differently depending on the state of the progress.
There are three types of widget:
The progressbar module is very easy to use, yet very powerful. And automatically supports features like auto-resizing when available.
The bar of progress. It will strech to fill the line.
Widget for showing the transfer speed (useful for file transfers).
This is the ProgressBar class, it updates and prints the bar.
The term_width parameter may be an integer. Or None, in which case it will try to guess it, if it fails it will default to 80 columns.
The simple use is like this:
>>> pbar = ProgressBar().start()
>>> for i in xrange(100):
... # do something
... pbar.update(i+1)
...
>>> pbar.finish()
But anything you want to do is possible (well, almost anything). You can supply different widgets of any type in any order. And you can even write your own widgets! There are many widgets already shipped and you should experiment with them.
When implementing a widget update method you may access any attribute or function of the ProgressBar object calling the widget’s update method. The most important attributes you would like to access are: - currval current value of the progress, 0 <= currval <= maxval - maxval maximum (and final) value of the progress - finished True if the bar is have finished (reached 100%), False o/w - start_time first time update() method of ProgressBar was called - seconds_elapsed seconds elapsed since start_time - percentage() percentage of the progress (this is a method)
This is an element of ProgressBar formatting.
The ProgressBar object will call it’s update value when an update is needed. It’s size may change between call, but the results will not be good if the size changes drastically and repeatedly.
This is a variable width element of ProgressBar formatting.
The ProgressBar object will call it’s update value, informing the width this object must the made. This is like TeX hfill, it will expand to fill the line. You can use more than one in the same line, and they will all have the same width, and together will fill the line.
Returns the string representing the widget.
The parameter pbar is a reference to the calling ProgressBar, where one can access attributes of the class for knowing how the update must be made. The parameter width is the total horizontal width the widget must have.
At least this function must be overriden.