progressbar package¶
Subpackages¶
- progressbar.terminal package
- Subpackages
- Submodules
- progressbar.terminal.base module
CLEAR_LINECLEAR_LINE_ALLCLEAR_LINE_LEFTCLEAR_LINE_RIGHTCLEAR_SCREENCLEAR_SCREEN_ALLCLEAR_SCREEN_ALL_AND_HISTORYCLEAR_SCREEN_TILL_ENDCLEAR_SCREEN_TILL_STARTCOLUMNCSICSINoArgCUPColorColorBaseColorGradientColorsDOWNDummyColorHIDE_CURSORHSLLEFTNEXT_LINEPREVIOUS_LINERESTORE_CURSORRGBRIGHTSAVE_CURSORSCROLL_UPSGRSGRColorUPWindowsColorWindowsColorsapply_colors()clear_line()get_color()
- progressbar.terminal.colors module
- progressbar.terminal.stream module
- progressbar.terminal.base module
- Module contents
- Subpackages
Submodules¶
- progressbar.bar module
ProgressBarMixinBaseProgressBarMixinBase.term_widthProgressBarMixinBase.widgetsProgressBarMixinBase.max_errorProgressBarMixinBase.prefixProgressBarMixinBase.suffixProgressBarMixinBase.left_justifyProgressBarMixinBase.widget_kwargsProgressBarMixinBase.custom_lenProgressBarMixinBase.initial_start_timeProgressBarMixinBase.poll_intervalProgressBarMixinBase.min_poll_intervalProgressBarMixinBase.num_intervalsProgressBarMixinBase.next_updateProgressBarMixinBase.valueProgressBarMixinBase.previous_valueProgressBarMixinBase.min_valueProgressBarMixinBase.max_valueProgressBarMixinBase.end_timeProgressBarMixinBase.start_timeProgressBarMixinBase.seconds_elapsedProgressBarMixinBase.extraProgressBarMixinBase.get_last_update_time()ProgressBarMixinBase.set_last_update_time()ProgressBarMixinBase.last_update_timeProgressBarMixinBase.start()ProgressBarMixinBase.update()ProgressBarMixinBase.finish()ProgressBarMixinBase.data()ProgressBarMixinBase.started()ProgressBarMixinBase.finished()
ProgressBarBaseDefaultFdMixinResizableMixinStdRedirectMixinProgressBarProgressBar.pausedProgressBar.min_valueProgressBar.max_valueProgressBar.max_errorProgressBar.widgetsProgressBar.prefixProgressBar.suffixProgressBar.widget_kwargsProgressBar.left_justifyProgressBar.valueProgressBar.custom_lenProgressBar.initial_start_timeProgressBar.poll_intervalProgressBar.min_poll_intervalProgressBar.dynamic_messagesProgressBar.init()ProgressBar.percentageProgressBar.data()ProgressBar.default_widgets()ProgressBar.next()ProgressBar.increment()ProgressBar.update()ProgressBar.stdoutProgressBar.stderrProgressBar.is_terminalProgressBar.previous_valueProgressBar.end_timeProgressBar.start_timeProgressBar.seconds_elapsedProgressBar.extraProgressBar.start()ProgressBar.finish()ProgressBar.currval
DataTransferBarNullBar
- progressbar.base module
- progressbar.multi module
MultiBarMultiBar.append_labelMultiBar.fdMultiBar.finished_formatMultiBar.flush()MultiBar.get_sorted_bars()MultiBar.initial_formatMultiBar.join()MultiBar.label_formatMultiBar.prepend_labelMultiBar.print()MultiBar.progressbar_kwargsMultiBar.remove_finishedMultiBar.render()MultiBar.run()MultiBar.sort_keyfuncMultiBar.start()MultiBar.stop()MultiBar.update_interval
SortKey
- progressbar.shortcuts module
- progressbar.utils module
AttributeDictStreamWrapperStreamWrapper.capturingStreamWrapper.excepthook()StreamWrapper.flush()StreamWrapper.listenersStreamWrapper.needs_clear()StreamWrapper.original_excepthookStreamWrapper.start_capturing()StreamWrapper.stderrStreamWrapper.stdoutStreamWrapper.stop_capturing()StreamWrapper.unwrap()StreamWrapper.unwrap_excepthook()StreamWrapper.unwrap_stderr()StreamWrapper.unwrap_stdout()StreamWrapper.update_capturing()StreamWrapper.wrap()StreamWrapper.wrap_excepthook()StreamWrapper.wrap_stderr()StreamWrapper.wrap_stdout()StreamWrapper.wrapped_excepthookStreamWrapper.wrapped_stderrStreamWrapper.wrapped_stdout
WrappingIOWrappingIO.bufferWrappingIO.capturingWrappingIO.close()WrappingIO.fileno()WrappingIO.flush()WrappingIO.flush_target()WrappingIO.isatty()WrappingIO.listenersWrappingIO.needs_clearWrappingIO.read()WrappingIO.readable()WrappingIO.readline()WrappingIO.readlines()WrappingIO.seek()WrappingIO.seekable()WrappingIO.targetWrappingIO.tell()WrappingIO.truncate()WrappingIO.writable()WrappingIO.write()WrappingIO.writelines()
deltas_to_seconds()len_color()no_color()
- progressbar.widgets module
AbsoluteETAAdaptiveETAAdaptiveTransferSpeedAnimatedMarkerAutoWidthWidgetBaseBarBouncingBarColoredMixinCounterCurrentTimeDataSizeDynamicMessageETAFileTransferSpeedFormatCustomTextFormatLabelFormatLabelBarFormatWidgetMixinGranularBarGranularMarkersJobStatusBarMultiProgressBarMultiRangeBarPercentagePercentageLabelBarReverseBarRotatingMarkerSamplesMixinSimpleProgressSmoothingETATFixedColorsTGradientColorsTimeSensitiveWidgetBaseTimerVariableVariableMixinWidgetBaseWidthWidgetMixincreate_marker()create_wrapper()string_or_lambda()wrapper()
Module contents¶
- class progressbar.AbsoluteETA(format_not_started='Estimated finish time: ----/--/-- --:--:--', format_finished='Finished at: %(elapsed)s', format='Estimated finish time: %(eta)s', **kwargs)[source]¶
Bases:
ETAWidget which attempts to estimate the absolute time of arrival.
- class progressbar.AdaptiveETA(exponential_smoothing=True, exponential_smoothing_factor=0.1, **kwargs)[source]¶
Bases:
ETA,SamplesMixinWidgetBase 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.AdaptiveTransferSpeed(**kwargs)[source]¶
Bases:
FileTransferSpeed,SamplesMixinWidget for showing the transfer speed based on the last X samples.
- class progressbar.AnimatedMarker(markers='|/-\\', default=None, fill='', marker_wrap=None, fill_wrap=None, **kwargs)[source]¶
Bases:
TimeSensitiveWidgetBaseAn animated marker for the progress bar which defaults to appear as if it were rotating.
- class progressbar.Bar(marker='#', left='|', right='|', fill=' ', fill_left=True, marker_wrap=None, **kwargs)[source]¶
Bases:
AutoWidthWidgetBaseA progress bar which stretches to fill the line.
- bg: Color | ColorGradient | None = None¶
- fg: Color | ColorGradient | None = <progressbar.terminal.base.ColorGradient object>¶
- class progressbar.BouncingBar(marker='#', left='|', right='|', fill=' ', fill_left=True, marker_wrap=None, **kwargs)[source]¶
Bases:
Bar,TimeSensitiveWidgetBaseA bar which has a marker which bounces from side to side.
- INTERVAL = datetime.timedelta(microseconds=100000)¶
- class progressbar.Counter(format='%(value)d', **kwargs)[source]¶
Bases:
FormatWidgetMixin,WidgetBaseDisplays the current count.
- class progressbar.CurrentTime(format='Current Time: %(current_time)s', microseconds=False, **kwargs)[source]¶
Bases:
FormatWidgetMixin,TimeSensitiveWidgetBaseWidget which displays the current (date)time with seconds resolution.
- INTERVAL = datetime.timedelta(seconds=1)¶
- class progressbar.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:
FormatWidgetMixin,WidgetBaseWidget 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.DataTransferBar(min_value: float = 0, max_value: float | ~typing.Type[<class 'progressbar.base.UnknownLength'>] | None = None, widgets: ~typing.Sequence[~progressbar.widgets.WidgetBase | str] | None = None, left_justify: bool = True, initial_value: float = 0, poll_interval: float | None = None, widget_kwargs: ~typing.Dict[str, ~typing.Any] | None = None, custom_len: ~typing.Callable[[str], int] = <function len_color>, max_error=True, prefix=None, suffix=None, variables=None, min_poll_interval=None, **kwargs)[source]¶
Bases:
ProgressBarA progress bar with sensible defaults for downloads etc.
This assumes that the values its given are numbers of bytes.
- class progressbar.DoubleExponentialMovingAverage(alpha: float = 0.5)[source]¶
Bases:
SmoothingAlgorithmThe Double Exponential Moving Average (DEMA) is essentially an EMA of an EMA, which reduces the lag that’s typically associated with a simple EMA. It’s more responsive to recent changes in data.
- class progressbar.DynamicMessage(name, format='{name}: {formatted_value}', width=6, precision=3, **kwargs)[source]¶
Bases:
VariableKept for backwards compatibility, please use Variable instead.
- class progressbar.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:
TimerWidgetBase which attempts to estimate the time of arrival.
- class progressbar.ExponentialMovingAverage(alpha: float = 0.5)[source]¶
Bases:
SmoothingAlgorithmThe Exponential Moving Average (EMA) is an exponentially weighted moving average that reduces the lag that’s typically associated with a simple moving average. It’s more responsive to recent changes in data.
- class progressbar.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:
FormatWidgetMixin,TimeSensitiveWidgetBaseWidget for showing the current transfer speed (useful for file transfers).
- class progressbar.FormatCustomText(format: str, mapping: Dict[str, Any] | None = None, **kwargs)[source]¶
Bases:
FormatWidgetMixin,WidgetBase- copy = False¶
- class progressbar.FormatLabel(format: str, **kwargs)[source]¶
Bases:
FormatWidgetMixin,WidgetBaseDisplays a formatted label.
>>> label = FormatLabel('%(value)s', min_width=5, max_width=10) >>> class Progress: ... pass >>> label = FormatLabel('{value} :: {value:^6}', new_style=True) >>> str(label(Progress, dict(value='test'))) 'test :: test '
- mapping: ClassVar[Dict[str, Tuple[str, Any]]] = {'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.FormatLabelBar(format, **kwargs)[source]¶
Bases:
FormatLabel,BarA bar which has a formatted label in the center.
- class progressbar.GranularBar(markers=' ▏▎▍▌▋▊▉█', left='|', right='|', **kwargs)[source]¶
Bases:
AutoWidthWidgetBaseA progressbar that can display progress at a sub-character granularity by using multiple marker characters.
- Examples of markers:
Smooth: ` ▏▎▍▌▋▊▉█` (default)
Bar: ` ▁▂▃▄▅▆▇█`
Snake: ` ▖▌▛█`
Fade in: ` ░▒▓█`
Dots: ` ⡀⡄⡆⡇⣇⣧⣷⣿`
Growing circles: ` .oO`
The markers can be accessed through GranularMarkers. GranularMarkers.dots for example
- class progressbar.JobStatusBar(name: str, left='|', right='|', fill=' ', fill_left=True, success_fg_color=((0, 128, 0), (120, 100, 25), 'Green', 2), success_bg_color=None, success_marker='█', failure_fg_color=((255, 0, 0), (0, 100, 50), 'Red', 9), failure_bg_color=None, failure_marker='X', **kwargs)[source]¶
Bases:
Bar,VariableMixinWidget which displays the job status as markers on the bar.
The status updates can be given either as a boolean or as a string. If it’s a string, it will be displayed as-is. If it’s a boolean, it will be displayed as a marker (default: ‘█’ for success, ‘X’ for failure) configurable through the success_marker and failure_marker parameters.
- Parameters:
name – The name of the variable to use for the status updates.
left – The left border of the bar.
right – The right border of the bar.
fill – The fill character of the bar.
fill_left – Whether to fill the bar from the left or the right.
success_fg_color – The foreground color to use for successful jobs.
success_bg_color – The background color to use for successful jobs.
success_marker – The marker to use for successful jobs.
failure_fg_color – The foreground color to use for failed jobs.
failure_bg_color – The background color to use for failed jobs.
failure_marker – The marker to use for failed jobs.
- class progressbar.LineOffsetStreamWrapper(lines: int = 0, stream: ~typing.TextIO = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]¶
Bases:
TextIOOutputWrapper- DOWN = '\x1b[B'¶
- UP = '\x1b[F'¶
- class progressbar.MultiBar(bars: ~typing.Iterable[tuple[str, ~progressbar.bar.ProgressBar]] | None = None, fd: ~typing.TextIO = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, prepend_label: bool = True, append_label: bool = False, label_format='{label:20.20} ', initial_format: str | None = '{label:20.20} Not yet started', finished_format: str | None = None, update_interval: float = 0.016666666666666666, show_initial: bool = True, show_finished: bool = True, remove_finished: ~datetime.timedelta | float = datetime.timedelta(seconds=3600), sort_key: str | ~progressbar.multi.SortKey = SortKey.CREATED, sort_reverse: bool = True, sort_keyfunc: ~typing.Callable[[~progressbar.bar.ProgressBar], ~typing.Any] | None = None, **progressbar_kwargs)[source]¶
Bases:
Dict[str,ProgressBar]- print(*args, end='\n', offset=None, flush=True, clear=True, **kwargs)[source]¶
Print to the progressbar stream without overwriting the progressbars.
- Parameters:
end – The string to append to the end of the output
offset – The number of lines to offset the output by. If None, the output will be printed above the progressbars
flush – Whether to flush the output to the stream
clear – If True, the line will be cleared before printing.
**kwargs – Additional keyword arguments to pass to print
- run(join=True)[source]¶
Start the multibar render loop and run the progressbars until they have force _thread_finished.
- sort_keyfunc: Callable[[ProgressBar], Any]¶
The progressbar sorting key function
- class progressbar.MultiProgressBar(name, markers=' ▁▂▃▄▅▆▇█', **kwargs)[source]¶
Bases:
MultiRangeBar- get_values(progress: ProgressBarMixinBase, data: Data)[source]¶
- class progressbar.MultiRangeBar(name, markers, **kwargs)[source]¶
Bases:
Bar,VariableMixinA bar with multiple sub-ranges, each represented by a different symbol.
The various ranges are represented on a user-defined variable, formatted as
[['Symbol1', amount1], ['Symbol2', amount2], ...]
- get_values(progress: ProgressBarMixinBase, data: Data)[source]¶
- class progressbar.NullBar(min_value: float = 0, max_value: float | ~typing.Type[<class 'progressbar.base.UnknownLength'>] | None = None, widgets: ~typing.Sequence[~progressbar.widgets.WidgetBase | str] | None = None, left_justify: bool = True, initial_value: float = 0, poll_interval: float | None = None, widget_kwargs: ~typing.Dict[str, ~typing.Any] | None = None, custom_len: ~typing.Callable[[str], int] = <function len_color>, max_error=True, prefix=None, suffix=None, variables=None, min_poll_interval=None, **kwargs)[source]¶
Bases:
ProgressBarProgress bar that does absolutely nothing. Useful for single verbosity flags.
- finish(*args: Any, **kwargs: Any)[source]¶
Puts the ProgressBar bar in the finished state.
Also flushes and disables output buffering if this was the last progressbar running.
- class progressbar.Percentage(format='%(percentage)3d%%', na='N/A%%', **kwargs)[source]¶
Bases:
FormatWidgetMixin,ColoredMixin,WidgetBaseDisplays the current percentage as a number with a percent sign.
- get_format(progress: ProgressBarMixinBase, data: Data, format=None)[source]¶
- class progressbar.PercentageLabelBar(format='%(percentage)2d%%', na='N/A%%', **kwargs)[source]¶
Bases:
Percentage,FormatLabelBarA bar which displays the current percentage in the center.
- class progressbar.ProgressBar(min_value: float = 0, max_value: float | ~typing.Type[<class 'progressbar.base.UnknownLength'>] | None = None, widgets: ~typing.Sequence[~progressbar.widgets.WidgetBase | str] | None = None, left_justify: bool = True, initial_value: float = 0, poll_interval: float | None = None, widget_kwargs: ~typing.Dict[str, ~typing.Any] | None = None, custom_len: ~typing.Callable[[str], int] = <function len_color>, max_error=True, prefix=None, suffix=None, variables=None, min_poll_interval=None, **kwargs)[source]¶
Bases:
StdRedirectMixin,ResizableMixin,ProgressBarBaseThe ProgressBar class which updates and prints the bar.
- Parameters:
min_value (int) – The minimum/start value for the progress bar
max_value (int) – The maximum/end value for the progress bar. Defaults to _DEFAULT_MAXVAL
widgets (list) – The widgets to render, defaults to the result of default_widget()
left_justify (bool) – Justify to the left if True or the right if False
initial_value (int) – The value to start with
poll_interval (float) – The update interval in seconds. Note that if your widgets include timers or animations, the actual interval may be smaller (faster updates). Also note that updates never happens faster than min_poll_interval which can be used for reduced output in logs
min_poll_interval (float) – The minimum update interval in seconds. The bar will _not_ be updated faster than this, despite changes in the progress, unless force=True. This is limited to be at least _MINIMUM_UPDATE_INTERVAL. If available, it is also bound by the environment variable PROGRESSBAR_MINIMUM_UPDATE_INTERVAL
widget_kwargs (dict) – The default keyword arguments for widgets
custom_len (function) – Method to override how the line width is calculated. When using non-latin characters the width calculation might be off by default
max_error (bool) – When True the progressbar will raise an error if it goes beyond it’s set max_value. Otherwise the max_value is simply raised when needed prefix (str): Prefix the progressbar with the given string suffix (str): Prefix the progressbar with the given string
variables (dict) – User-defined variables variables that can be used from a label using format=’{variables.my_var}’. These values can be updated using bar.update(my_var=’newValue’) This can also be used to set initial values for variables’ widgets
line_offset (int) – The number of lines to offset the progressbar from your current line. This is useful if you have other output or multiple progressbars
A common way of using it is like:
>>> progress = ProgressBar().start() >>> for i in range(100): ... progress.update(i + 1) ... # do something >>> progress.finish()
You can also use a ProgressBar as an iterator:
>>> progress = ProgressBar() >>> some_iterable = range(100) >>> for i in progress(some_iterable): ... # do something ... pass
Since the progress bar is incredibly customizable you can specify different widgets of any type in any order. You can even write your own widgets! However, since there are already a good number of widgets you should probably play around with them before moving on to create your own widgets.
The term_width parameter represents the current terminal width. If the parameter is set to an integer then the progress bar will use that, otherwise it will attempt to determine the terminal width falling back to 80 columns if the width cannot be determined.
When implementing a widget’s update method you are passed a reference to the current progress bar. As a result, you have access to the ProgressBar’s methods and attributes. Although there is nothing preventing you from changing the ProgressBar you should treat it as read only.
- property currval¶
Legacy method to make progressbar-2 compatible with the original progressbar package.
- data() Dict[str, Any][source]¶
- Returns:
max_value: The maximum value (can be None with iterators)
start_time: Start time of the widget
last_update_time: Last update time of the widget
end_time: End time of the widget
value: The current value
previous_value: The previous value
updates: The total update count
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: The raw elapsed datetime.timedelta object
percentage: Percentage as a float or None if no max_value is available
dynamic_messages: Deprecated, use variables instead.
variables: Dictionary of user-defined variables for the
Variable’s.
- Return type:
- property dynamic_messages¶
- finish(end: str = '\n', dirty: bool = False)[source]¶
Puts the ProgressBar bar in the finished state.
Also flushes and disables output buffering if this was the last progressbar running.
- next()¶
- property percentage: float | None¶
Return current percentage, returns None if no max_value is given.
>>> progress = ProgressBar() >>> progress.max_value = 10 >>> progress.min_value = 0 >>> progress.value = 0 >>> progress.percentage 0.0 >>> >>> progress.value = 1 >>> progress.percentage 10.0 >>> progress.value = 10 >>> progress.percentage 100.0 >>> progress.min_value = -10 >>> progress.percentage 100.0 >>> progress.value = 0 >>> progress.percentage 50.0 >>> progress.value = 5 >>> progress.percentage 75.0 >>> progress.value = -5 >>> progress.percentage 25.0 >>> progress.max_value = None >>> progress.percentage
- start(max_value: float | None = None, init: bool = True, *args: Any, **kwargs: Any) ProgressBar[source]¶
Starts measuring time, and prints the bar at 0%.
It returns self so you can use it like this:
- Parameters:
>>> pbar = ProgressBar().start() >>> for i in range(100): ... # do something ... pbar.update(i + 1) >>> pbar.finish()
- class progressbar.ReverseBar(marker='#', left='|', right='|', fill=' ', fill_left=False, **kwargs)[source]¶
Bases:
BarA bar which has a marker that goes from right to left.
- progressbar.RotatingMarker¶
alias of
AnimatedMarker
- class progressbar.SimpleProgress(format='%(value_s)s of %(max_value_s)s', **kwargs)[source]¶
Bases:
FormatWidgetMixin,ColoredMixin,WidgetBaseReturns progress as a count of the total (e.g.: “5 of 47”).
- DEFAULT_FORMAT = '%(value_s)s of %(max_value_s)s'¶
- max_width_cache: dict[str | tuple[NumberT | types.Type[base.UnknownLength] | None, NumberT | types.Type[base.UnknownLength] | None], types.Optional[int]]¶
- class progressbar.SmoothingETA(smoothing_algorithm: type[~progressbar.algorithms.SmoothingAlgorithm] = <class 'progressbar.algorithms.ExponentialMovingAverage'>, smoothing_parameters: dict[str, float] | None = None, **kwargs)[source]¶
Bases:
ETAWidgetBase which attempts to estimate the time of arrival using an exponential moving average (EMA) of the speed.
EMA applies more weight to recent data points and less to older ones, and doesn’t require storing all past values. This approach works well with varying data points and smooths out fluctuations effectively.
- smoothing_algorithm: SmoothingAlgorithm¶
- class progressbar.SortKey(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
-
Sort keys for the MultiBar.
This is a string enum, so you can use any progressbar attribute or property as a sort key.
Note that the multibar defaults to lazily rendering only the changed progressbars. This means that sorting by dynamic attributes such as value might result in more rendering which can have a small performance impact.
- CREATED = 'index'¶
- LABEL = 'label'¶
- PERCENTAGE = 'percentage'¶
- VALUE = 'value'¶
- class progressbar.Timer(format='Elapsed Time: %(elapsed)s', **kwargs)[source]¶
Bases:
FormatLabel,TimeSensitiveWidgetBaseWidgetBase which displays the elapsed seconds.
- static format_time(timestamp: timedelta | date | datetime | str | int | float | None, precision: timedelta = datetime.timedelta(seconds=1)) str¶
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.Variable(name, format='{name}: {formatted_value}', width=6, precision=3, **kwargs)[source]¶
Bases:
FormatWidgetMixin,VariableMixin,WidgetBaseDisplays a custom variable.
- class progressbar.VariableMixin(name, **kwargs)[source]¶
Bases:
objectMixin to display a custom user variable.