Package mbdyn :: Package bindings :: Module progressbar :: Class ProgressBar
[hide private]

Class ProgressBar

source code

object --+
         |
        ProgressBar

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:

Instance Methods [hide private]
 
__init__(self, maxval=100, widgets=default_widgets, term_width=None, fd=sys.stderr)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
handle_resize(self, signum, frame) source code
 
percentage(self)
Returns the percentage of the progress.
source code
 
_format_widgets(self) source code
 
_format_line(self) source code
 
_need_update(self) source code
 
update(self, value)
Updates the progress bar to a new value.
source code
 
stand_by(self, value) source code
 
restart(self, value) source code
 
start(self)
Start measuring time, and prints the bar at 0%.
source code
 
finish(self)
Used to tell the progress is finished.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, maxval=100, widgets=default_widgets, term_width=None, fd=sys.stderr)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

start(self)

source code 

Start measuring time, and prints the bar at 0%.

It returns self so you can use it like this: >>> pbar = ProgressBar().start() >>> for i in xrange(100): ... # do something ... pbar.update(i+1) ... >>> pbar.finish()