Package glue :: Module text_progress_bar :: Class ProgressBar
[hide private]
[frames] | no frames]

Class ProgressBar

source code

Display a text progress bar.

A final line feed is printed when the ProgressBar is garbage collected. Explicitly deleting the object can force a line feed when desired. As an alternative, using the ProgressBar as a context manager will ensure a final line feed is printed when the code block within which the ProgressBar is being used exits.

Example:

>>> with ProgressBar(max=3) as pb:
...    pb.update(1)
...    pb.update(2)
...    pb.update(3)
...
Instance Methods [hide private]
 
__del__(self) source code
 
__enter__(self) source code
 
__exit__(self, exc_type, exc_value, tb) source code
 
__init__(self, text=u'Working', max=1, value=0, textwidth=24, fid=None, theme=None) source code
 
increment(self, delta=1, text=None)
Redraw the progress bar, incrementing the value by delta (default=1) and optionally changing the text.
source code
 
iterate(self, iterable, format=u'%s', print_every=1)
Use as a target of a for-loop to issue a progress update for every iteration.
source code
 
linefeed(self) source code
 
show(self)
Redraw the text progress bar.
source code
 
update(self, value=None, text=None)
Redraw the progress bar, optionally changing the value and text and return the (possibly new) value.
source code
Method Details [hide private]

increment(self, delta=1, text=None)

source code 

Redraw the progress bar, incrementing the value by delta (default=1) and optionally changing the text. Returns the ProgressBar's new value. See also .update().

iterate(self, iterable, format=u'%s', print_every=1)

source code 
Use as a target of a for-loop to issue a progress update for every
iteration. For example:

progress = ProgressBar()
for text in progress.iterate(["foo", "bar", "bat"]):
    ...

update(self, value=None, text=None)

source code 

Redraw the progress bar, optionally changing the value and text and return the (possibly new) value. For I/O performance, the progress bar might not be written to the terminal if the text does not change and the value changes by too little. Use .show() to force a redraw.