Public Member Functions | |
def | __init__ (self, maxval=100, widgets=default_widgets, term_width=None, fd=sys.stderr) |
def | handle_resize (self, signum, frame) |
def | percentage (self) |
def | update (self, value) |
def | start (self) |
def | finish (self) |
Public Attributes | |
maxval | |
widgets | |
fd | |
signal_set | |
term_width | |
currval | |
finished | |
prev_percentage | |
start_time | |
seconds_elapsed | |
Private Member Functions | |
def | _format_widgets (self) |
def | _format_line (self) |
def | _need_update (self) |
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)
Definition at line 194 of file progressbar.py.
def progressbar.ProgressBar.__init__ | ( | self, | |
maxval = 100 , |
|||
widgets = default_widgets , |
|||
term_width = None , |
|||
fd = sys.stderr |
|||
) |
Definition at line 225 of file progressbar.py.
|
private |
Definition at line 276 of file progressbar.py.
|
private |
Definition at line 255 of file progressbar.py.
|
private |
Definition at line 279 of file progressbar.py.
def progressbar.ProgressBar.finish | ( | self | ) |
def progressbar.ProgressBar.handle_resize | ( | self, | |
signum, | |||
frame | |||
) |
Definition at line 247 of file progressbar.py.
def progressbar.ProgressBar.percentage | ( | self | ) |
Definition at line 251 of file progressbar.py.
def progressbar.ProgressBar.start | ( | self | ) |
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()
Definition at line 298 of file progressbar.py.
def progressbar.ProgressBar.update | ( | self, | |
value | |||
) |
Definition at line 282 of file progressbar.py.
progressbar.ProgressBar.currval |
Definition at line 241 of file progressbar.py.
progressbar.ProgressBar.fd |
Definition at line 229 of file progressbar.py.
progressbar.ProgressBar.finished |
Definition at line 242 of file progressbar.py.
progressbar.ProgressBar.maxval |
Definition at line 227 of file progressbar.py.
progressbar.ProgressBar.prev_percentage |
Definition at line 243 of file progressbar.py.
progressbar.ProgressBar.seconds_elapsed |
Definition at line 245 of file progressbar.py.
progressbar.ProgressBar.signal_set |
Definition at line 230 of file progressbar.py.
progressbar.ProgressBar.start_time |
Definition at line 244 of file progressbar.py.
progressbar.ProgressBar.term_width |
Definition at line 237 of file progressbar.py.
progressbar.ProgressBar.widgets |
Definition at line 228 of file progressbar.py.