progressbar.widgets module

class progressbar.widgets.AbsoluteETA(format_not_started='Estimated finish time: ----/--/-- --:--:--', format_finished='Finished at: %(elapsed)s', format='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='|/-\', 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='#', left='|', right='|', fill=' ', fill_left=True, **kwargs)[source]

Bases: progressbar.widgets.AutoWidthWidgetBase

A progress bar which stretches to fill the line.

class progressbar.widgets.BouncingBar(marker='#', left='|', right='|', fill=' ', 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(microseconds=100000)
class progressbar.widgets.Counter(format='%(value)d', **kwargs)[source]

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

Displays the current count

class progressbar.widgets.CurrentTime(format='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(seconds=1)
class progressbar.widgets.DataSize(variable='value', format='%(scaled)5.1f %(prefix)s%(unit)s', unit='B', prefixes=('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', '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='ETA: --:--:--', format_finished='Time: %(elapsed)8s', format='ETA: %(eta)8s', format_zero='ETA: 00:00:00', format_NA='ETA: N/A', **kwargs)[source]

Bases: progressbar.widgets.Timer

WidgetBase which attempts to estimate the time of arrival.

class progressbar.widgets.FileTransferSpeed(format='%(scaled)5.1f %(prefix)s%(unit)-s/s', inverse_format='%(scaled)5.1f s/%(prefix)s%(unit)-s', unit='B', prefixes=('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', '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 = {}
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')))
>>> Progress.term_width = 10
>>> str(label(Progress, dict(value='test')))
>>> Progress.term_width = 11
>>> str(label(Progress, dict(value='test')))
>>> label = FormatLabel('{value} :: {value:^6}', new_style=True)
>>> str(label(Progress, dict(value='test')))
'test ::  test '
mapping = {'elapsed': ('total_seconds_elapsed', <function format_time>), 'finished': ('end_time', None), 'last_update': ('last_update_time', None), 'max': ('max_value', None), 'seconds': ('seconds_elapsed', None), 'start': ('start_time', None), 'value': ('value', None)}
class progressbar.widgets.FormatWidgetMixin(format, new_style=False, **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='%(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='#', left='|', right='|', fill=' ', fill_left=False, **kwargs)[source]

Bases: progressbar.widgets.Bar

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


alias of progressbar.widgets.AnimatedMarker

class progressbar.widgets.SamplesMixin(samples=datetime.timedelta(seconds=2), key_prefix=None, **kwargs)[source]

Bases: progressbar.widgets.TimeSensitiveWidgetBase

Mixing for widgets that average multiple measurements

Note that samples can be either an integer or a timedelta to indicate a certain amount of time

>>> class progress:
...     last_update_time =
...     value = 1
...     extra = dict()
>>> samples = SamplesMixin(samples=2)
>>> samples(progress, None, True)
(None, None)
>>> progress.last_update_time += datetime.timedelta(seconds=1)
>>> samples(progress, None, True) == (datetime.timedelta(seconds=1), 0)
>>> progress.last_update_time += datetime.timedelta(seconds=1)
>>> samples(progress, None, True) == (datetime.timedelta(seconds=1), 0)
>>> samples = SamplesMixin(samples=datetime.timedelta(seconds=1))
>>> _, value = samples(progress, None)
>>> value
[1, 1]
>>> samples(progress, None, True) == (datetime.timedelta(seconds=1), 0)
get_sample_times(progress, data)[source]
get_sample_values(progress, data)[source]
class progressbar.widgets.SimpleProgress(format='%(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 = '%(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(microseconds=100000)
class progressbar.widgets.Timer(format='Elapsed Time: %(elapsed)s', **kwargs)[source]

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

WidgetBase which displays the elapsed seconds.

static format_time(timestamp, precision=datetime.timedelta(seconds=1))

Formats timedelta/datetime/seconds

>>> format_time('1')
>>> format_time(1.234)
>>> format_time(1)
>>> format_time(datetime.datetime(2000, 1, 2, 3, 4, 5, 6))
'2000-01-02 03:04:05'
>>> format_time(, 1, 2))
>>> format_time(datetime.timedelta(seconds=3661))
>>> format_time(None)
>>> format_time(format_time)  # doctest: +ELLIPSIS
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..