progressbar.widgets module

class progressbar.widgets.AbsoluteETA(format_not_started=u'Estimated finish time: ----/--/-- --:--:--', format_finished=u'Finished at: %(elapsed)s', format=u'Estimated finish time: %(eta)s', **kwargs)[source]

Bases: progressbar.widgets.ETA

Widget which attempts to estimate the absolute time of arrival.

class progressbar.widgets.AdaptiveETA(**kwargs)[source]

Bases: progressbar.widgets.ETA, progressbar.widgets.SamplesMixin

WidgetBase which attempts to estimate the time of arrival.

Uses a sampled average of the speed based on the 10 last updates. Very convenient for resuming the progress halfway.

class progressbar.widgets.AdaptiveTransferSpeed(**kwargs)[source]

Bases: progressbar.widgets.FileTransferSpeed, progressbar.widgets.SamplesMixin

WidgetBase for showing the transfer speed, based on the last X samples

class progressbar.widgets.AnimatedMarker(markers=u'|/-\', default=None, **kwargs)[source]

Bases: progressbar.widgets.WidgetBase

An animated marker for the progress bar which defaults to appear as if it were rotating.

class progressbar.widgets.AutoWidthWidgetBase(**kwargs)[source]

Bases: progressbar.widgets.WidgetBase

The base class for all variable width widgets.

This widget is much like the hfill command in TeX, 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.

class progressbar.widgets.Bar(marker=u'#', left=u'|', right=u'|', fill=u' ', fill_left=True, **kwargs)[source]

Bases: progressbar.widgets.AutoWidthWidgetBase

A progress bar which stretches to fill the line.

class progressbar.widgets.BouncingBar(marker=u'#', left=u'|', right=u'|', fill=u' ', fill_left=True, **kwargs)[source]

Bases: progressbar.widgets.Bar, progressbar.widgets.TimeSensitiveWidgetBase

A bar which has a marker which bounces from side to side.

INTERVAL = datetime.timedelta(0, 0, 100000)
class progressbar.widgets.Counter(format=u'%(value)d', **kwargs)[source]

Bases: progressbar.widgets.FormatWidgetMixin, progressbar.widgets.WidgetBase

Displays the current count

class progressbar.widgets.CurrentTime(format=u'Current Time: %(current_time)s', microseconds=False, **kwargs)[source]

Bases: progressbar.widgets.FormatWidgetMixin, progressbar.widgets.TimeSensitiveWidgetBase

Widget which displays the current (date)time with seconds resolution.

INTERVAL = datetime.timedelta(0, 1)
current_datetime()[source]
current_time()[source]
class progressbar.widgets.DataSize(variable=u'value', format=u'%(scaled)5.1f %(prefix)s%(unit)s', unit=u'B', prefixes=(u'', u'Ki', u'Mi', u'Gi', u'Ti', u'Pi', u'Ei', u'Zi', u'Yi'), **kwargs)[source]

Bases: progressbar.widgets.FormatWidgetMixin

Widget for showing an amount of data transferred/processed.

Automatically formats the value (assumed to be a count of bytes) with an appropriate sized unit, based on the IEC binary prefixes (powers of 1024).

class progressbar.widgets.DynamicMessage(name)[source]

Bases: progressbar.widgets.FormatWidgetMixin, progressbar.widgets.WidgetBase

Displays a custom variable.

class progressbar.widgets.ETA(format_not_started=u'ETA: --:--:--', format_finished=u'Time: %(elapsed)s', format=u'ETA: %(eta)s', format_zero=u'ETA: 0:00:00', format_NA=u'ETA: N/A', **kwargs)[source]

Bases: progressbar.widgets.Timer

WidgetBase which attempts to estimate the time of arrival.

class progressbar.widgets.FileTransferSpeed(format=u'%(scaled)5.1f %(prefix)s%(unit)-s/s', inverse_format=u'%(scaled)5.1f s/%(prefix)s%(unit)-s', unit=u'B', prefixes=(u'', u'Ki', u'Mi', u'Gi', u'Ti', u'Pi', u'Ei', u'Zi', u'Yi'), **kwargs)[source]

Bases: progressbar.widgets.FormatWidgetMixin, progressbar.widgets.TimeSensitiveWidgetBase

WidgetBase for showing the transfer speed (useful for file transfers).

class progressbar.widgets.FormatCustomText(format, mapping={}, **kwargs)[source]

Bases: progressbar.widgets.FormatWidgetMixin, progressbar.widgets.WidthWidgetMixin

mapping = {}
update_mapping(**mapping)[source]
class progressbar.widgets.FormatLabel(format, **kwargs)[source]

Bases: progressbar.widgets.FormatWidgetMixin, progressbar.widgets.WidthWidgetMixin

Displays a formatted label

>>> label = FormatLabel('%(value)s', min_width=5, max_width=10)
>>> class Progress(object):
...     pass
>>> Progress.term_width = 0
>>> str(label(Progress, dict(value='test')))
''
>>> Progress.term_width = 5
>>> str(label(Progress, dict(value='test')))
'test'
>>> Progress.term_width = 10
>>> str(label(Progress, dict(value='test')))
'test'
>>> Progress.term_width = 11
>>> str(label(Progress, dict(value='test')))
''
mapping = {u'seconds': (u'seconds_elapsed', None), u'max': (u'max_value', None), u'value': (u'value', None), u'elapsed': (u'total_seconds_elapsed', <function format_time>), u'start': (u'start_time', None), u'finished': (u'end_time', None), u'last_update': (u'last_update_time', None)}
class progressbar.widgets.FormatWidgetMixin(format, **kwargs)[source]

Bases: object

Mixin to format widgets using a formatstring

Variables available:
  • max_value: The maximum value (can be None with iterators)
  • value: The current value
  • total_seconds_elapsed: The seconds since the bar started
  • seconds_elapsed: The seconds since the bar started modulo 60
  • minutes_elapsed: The minutes since the bar started modulo 60
  • hours_elapsed: The hours since the bar started modulo 24
  • days_elapsed: The hours since the bar started
  • time_elapsed: Shortcut for HH:MM:SS time since the bar started including days
  • percentage: Percentage as a float
required_values = []
class progressbar.widgets.Percentage(format=u'%(percentage)3d%%', **kwargs)[source]

Bases: progressbar.widgets.FormatWidgetMixin, progressbar.widgets.WidgetBase

Displays the current percentage as a number with a percent sign.

class progressbar.widgets.ReverseBar(marker=u'#', left=u'|', right=u'|', fill=u' ', fill_left=False, **kwargs)[source]

Bases: progressbar.widgets.Bar

A bar which has a marker that goes from right to left

progressbar.widgets.RotatingMarker

alias of AnimatedMarker

class progressbar.widgets.SamplesMixin(samples=10, key_prefix=None, **kwargs)[source]

Bases: object

get_sample_times(progress, data)[source]
get_sample_values(progress, data)[source]
class progressbar.widgets.SimpleProgress(format=u'%(value_s)s of %(max_value_s)s', max_width=None, **kwargs)[source]

Bases: progressbar.widgets.FormatWidgetMixin, progressbar.widgets.WidgetBase

Returns progress as a count of the total (e.g.: “5 of 47”)

DEFAULT_FORMAT = u'%(value_s)s of %(max_value_s)s'
class progressbar.widgets.TimeSensitiveWidgetBase(**kwargs)[source]

Bases: progressbar.widgets.WidgetBase

The base class for all time sensitive widgets.

Some widgets like timers would become out of date unless updated at least every INTERVAL

INTERVAL = datetime.timedelta(0, 0, 100000)
class progressbar.widgets.Timer(format=u'Elapsed Time: %(elapsed)s', **kwargs)[source]

Bases: progressbar.widgets.FormatLabel, progressbar.widgets.TimeSensitiveWidgetBase

WidgetBase which displays the elapsed seconds.

static format_time(time, precision=datetime.timedelta(0, 1))

Formats timedelta/datetime/seconds

>>> format_time('1')
'0:00:01'
>>> format_time(1.234)
'0:00:01'
>>> format_time(1)
'0:00:01'
>>> format_time(datetime.datetime(2000, 1, 2, 3, 4, 5, 6))
'2000-01-02 03:04:05'
>>> format_time(datetime.date(2000, 1, 2))
'2000-01-02'
>>> format_time(datetime.timedelta(seconds=3661))
'1:01:01'
>>> format_time(None)
'--:--:--'
>>> format_time(format_time)  
Traceback (most recent call last):
    ...
TypeError: Unknown type ...
class progressbar.widgets.WidgetBase(**kwargs)[source]

Bases: object

class progressbar.widgets.WidthWidgetMixin(min_width=None, max_width=None, **kwargs)[source]

Bases: object

Mixing to make sure widgets are only visible if the screen is within a specified size range so the progressbar fits on both large and small screens..

check_size(progress)[source]
progressbar.widgets.create_marker(marker)[source]
progressbar.widgets.string_or_lambda(input_)[source]