TimedProgressBar¶
-
class
urwid_timed_progress.
TimedProgressBar
(normal, complete, done=100, satt=None, units='', label='Progress', label_width=15)¶ Progress bar with label, progress rate, and time remaining displays
TimedProgressBar keeps track of when progress started and computes the
rate
of progress and estimatedremaining_time
ascurrent
progress is updated with theadd_progress()
method.A timed progress bar starts with a current value of 0.
Parameters: - normal – display attribute for incomplete part of progress bar
- complete – display attribute for complete part of progress bar
- done – progress amount at 100%
- satt – display attribute for smoothed part of bar where the
foreground of satt corresponds to the normal part and the
background corresponds to the complete part. If satt is
None
then no smoothing will be done. - units (str or list of tuples) –
units to use. If a string, the units value is taken as a label and is used as is. units can also be a list of tuples such as:
[ ('KB', 1000), ('MB', 1000000), ('GB', 1000000000) ]
With a list of tuples, the timed progress bar selects the most reasonable unit to use for current, done, and rate. 3 KB is more reasonable than .003 MB and 3MB is more reasonable than 3000KB.
Values greater than 1 and less than 1000 are preferred over fractions. So 400 KB is considered more reasonable than .4 MB.
- label – label shown to the left of the progress bar
- label_width – fixed width of label. Can be used to align stacked progress bars. Set label_width to 0 and label to the empty string to omit the label.
-
add_progress
(delta, done=None)¶ Add to the current progress amount
Add delta to the current progress amount. This also updates
rate
andremaining_time
.The
current
progress is never less than 0 or greater thandone
.Parameters: - delta – amount to add, may be negative
- done – new value to use for done
-
current
¶ current progress amount
-
done
¶ progress amount when complete
-
elapsed
¶ time in seconds since the progress bar timer was last started
-
rate
¶ progress rate
-
remaining_time
¶ remaining time (as a timedelta) until complete at current rate