progressbar package¶
Subpackages¶
- progressbar.terminal package
- Subpackages
- Submodules
- progressbar.terminal.base module
CLEAR_LINE
CLEAR_LINE_ALL
CLEAR_LINE_LEFT
CLEAR_LINE_RIGHT
CLEAR_SCREEN
CLEAR_SCREEN_ALL
CLEAR_SCREEN_ALL_AND_HISTORY
CLEAR_SCREEN_TILL_END
CLEAR_SCREEN_TILL_START
COLUMN
CSI
CSINoArg
CUP
Color
ColorBase
ColorGradient
Colors
DOWN
DummyColor
HIDE_CURSOR
HSL
LEFT
NEXT_LINE
PREVIOUS_LINE
RESTORE_CURSOR
RGB
RIGHT
SAVE_CURSOR
SCROLL_UP
SGR
SGRColor
UP
WindowsColor
WindowsColors
apply_colors()
clear_line()
get_color()
- progressbar.terminal.colors module
- progressbar.terminal.stream module
- progressbar.terminal.base module
- Module contents
- Subpackages
Submodules¶
- progressbar.bar module
ProgressBarMixinBase
ProgressBarMixinBase.term_width
ProgressBarMixinBase.widgets
ProgressBarMixinBase.max_error
ProgressBarMixinBase.prefix
ProgressBarMixinBase.suffix
ProgressBarMixinBase.left_justify
ProgressBarMixinBase.widget_kwargs
ProgressBarMixinBase.custom_len
ProgressBarMixinBase.initial_start_time
ProgressBarMixinBase.poll_interval
ProgressBarMixinBase.min_poll_interval
ProgressBarMixinBase.num_intervals
ProgressBarMixinBase.next_update
ProgressBarMixinBase.value
ProgressBarMixinBase.previous_value
ProgressBarMixinBase.min_value
ProgressBarMixinBase.max_value
ProgressBarMixinBase.end_time
ProgressBarMixinBase.start_time
ProgressBarMixinBase.seconds_elapsed
ProgressBarMixinBase.extra
ProgressBarMixinBase.get_last_update_time()
ProgressBarMixinBase.set_last_update_time()
ProgressBarMixinBase.last_update_time
ProgressBarMixinBase.start()
ProgressBarMixinBase.update()
ProgressBarMixinBase.finish()
ProgressBarMixinBase.data()
ProgressBarMixinBase.started()
ProgressBarMixinBase.finished()
ProgressBarBase
DefaultFdMixin
ResizableMixin
StdRedirectMixin
ProgressBar
ProgressBar.paused
ProgressBar.min_value
ProgressBar.max_value
ProgressBar.max_error
ProgressBar.widgets
ProgressBar.prefix
ProgressBar.suffix
ProgressBar.widget_kwargs
ProgressBar.left_justify
ProgressBar.value
ProgressBar.custom_len
ProgressBar.initial_start_time
ProgressBar.poll_interval
ProgressBar.min_poll_interval
ProgressBar.dynamic_messages
ProgressBar.init()
ProgressBar.percentage
ProgressBar.data()
ProgressBar.default_widgets()
ProgressBar.next()
ProgressBar.increment()
ProgressBar.update()
ProgressBar.stdout
ProgressBar.stderr
ProgressBar.is_terminal
ProgressBar.previous_value
ProgressBar.end_time
ProgressBar.start_time
ProgressBar.seconds_elapsed
ProgressBar.extra
ProgressBar.start()
ProgressBar.finish()
ProgressBar.currval
DataTransferBar
NullBar
- progressbar.base module
- progressbar.multi module
MultiBar
MultiBar.append_label
MultiBar.fd
MultiBar.finished_format
MultiBar.flush()
MultiBar.get_sorted_bars()
MultiBar.initial_format
MultiBar.join()
MultiBar.label_format
MultiBar.prepend_label
MultiBar.print()
MultiBar.progressbar_kwargs
MultiBar.remove_finished
MultiBar.render()
MultiBar.run()
MultiBar.sort_keyfunc
MultiBar.start()
MultiBar.stop()
MultiBar.update_interval
SortKey
- progressbar.shortcuts module
- progressbar.utils module
AttributeDict
StreamWrapper
StreamWrapper.capturing
StreamWrapper.excepthook()
StreamWrapper.flush()
StreamWrapper.listeners
StreamWrapper.needs_clear()
StreamWrapper.original_excepthook
StreamWrapper.start_capturing()
StreamWrapper.stderr
StreamWrapper.stdout
StreamWrapper.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_excepthook
StreamWrapper.wrapped_stderr
StreamWrapper.wrapped_stdout
WrappingIO
WrappingIO.buffer
WrappingIO.capturing
WrappingIO.close()
WrappingIO.fileno()
WrappingIO.flush()
WrappingIO.flush_target()
WrappingIO.isatty()
WrappingIO.listeners
WrappingIO.needs_clear
WrappingIO.read()
WrappingIO.readable()
WrappingIO.readline()
WrappingIO.readlines()
WrappingIO.seek()
WrappingIO.seekable()
WrappingIO.target
WrappingIO.tell()
WrappingIO.truncate()
WrappingIO.writable()
WrappingIO.write()
WrappingIO.writelines()
deltas_to_seconds()
len_color()
no_color()
- progressbar.widgets module
AbsoluteETA
AdaptiveETA
AdaptiveTransferSpeed
AnimatedMarker
AutoWidthWidgetBase
Bar
BouncingBar
ColoredMixin
Counter
CurrentTime
DataSize
DynamicMessage
ETA
FileTransferSpeed
FormatCustomText
FormatLabel
FormatLabelBar
FormatWidgetMixin
GranularBar
GranularMarkers
JobStatusBar
MultiProgressBar
MultiRangeBar
Percentage
PercentageLabelBar
ReverseBar
RotatingMarker
SamplesMixin
SimpleProgress
SmoothingETA
TFixedColors
TGradientColors
TimeSensitiveWidgetBase
Timer
Variable
VariableMixin
WidgetBase
WidthWidgetMixin
create_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:
ETA
Widget which attempts to estimate the absolute time of arrival.
- class progressbar.AdaptiveETA(exponential_smoothing=True, exponential_smoothing_factor=0.1, **kwargs)[source]¶
Bases:
ETA
,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.AdaptiveTransferSpeed(**kwargs: Any)[source]¶
Bases:
FileTransferSpeed
,SamplesMixin
Widget 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:
TimeSensitiveWidgetBase
An 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:
AutoWidthWidgetBase
A 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
,TimeSensitiveWidgetBase
A bar which has a marker which bounces from side to side.
- INTERVAL = datetime.timedelta(microseconds=100000)¶
- class progressbar.Counter(format='%(value)d', **kwargs: Any)[source]¶
Bases:
FormatWidgetMixin
,WidgetBase
Displays the current count.
- class progressbar.CurrentTime(format='Current Time: %(current_time)s', microseconds=False, **kwargs)[source]¶
Bases:
FormatWidgetMixin
,TimeSensitiveWidgetBase
Widget 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
,WidgetBase
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.DataTransferBar(min_value: float = 0, max_value: float | 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:
ProgressBar
A 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:
SmoothingAlgorithm
The 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:
Variable
Kept 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:
Timer
WidgetBase which attempts to estimate the time of arrival.
- class progressbar.ExponentialMovingAverage(alpha: float = 0.5)[source]¶
Bases:
SmoothingAlgorithm
The 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
,TimeSensitiveWidgetBase
Widget 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: Any)[source]¶
Bases:
FormatWidgetMixin
,WidgetBase
Displays 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: Any)[source]¶
Bases:
FormatLabel
,Bar
A bar which has a formatted label in the center.
- class progressbar.GranularBar(markers=' ▏▎▍▌▋▊▉█', left='|', right='|', **kwargs)[source]¶
Bases:
AutoWidthWidgetBase
A 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
,VariableMixin
Widget 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: str = '{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: ~typing.Any)[source]¶
Bases:
dict
[str
,ProgressBar
]- print(*args: Any, end: str = '\n', offset: int | None = None, flush: bool = True, clear: bool = True, **kwargs: Any)[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
- render(flush: bool = True, force: bool = False) None [source]¶
Render the multibar to the given stream.
- run(join: bool = True) None [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: Any)[source]¶
Bases:
Bar
,VariableMixin
A 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 | 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:
ProgressBar
Progress 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: Any)[source]¶
Bases:
FormatWidgetMixin
,ColoredMixin
,WidgetBase
Displays 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: Any)[source]¶
Bases:
Percentage
,FormatLabelBar
A bar which displays the current percentage in the center.
- class progressbar.ProgressBar(min_value: float = 0, max_value: float | 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
,ProgressBarBase
The 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:
Bar
A 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: Any)[source]¶
Bases:
FormatWidgetMixin
,ColoredMixin
,WidgetBase
Returns 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:
ETA
WidgetBase 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: Any)[source]¶
Bases:
FormatLabel
,TimeSensitiveWidgetBase
WidgetBase 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
,WidgetBase
Displays a custom variable.
- class progressbar.VariableMixin(name, **kwargs: Any)[source]¶
Bases:
object
Mixin to display a custom user variable.
- progressbar.len_color(value: str | bytes) int [source]¶
Return the length of value without ANSI escape codes.
>>> len_color(b'[1234]abc') 3 >>> len_color('[1234]abc') 3 >>> len_color('[1234]abc') 3
- progressbar.progressbar(iterator: ~typing.Iterator[~progressbar.shortcuts.T], min_value: float = 0, max_value: float | type[<class 'progressbar.base.UnknownLength'>] | None = None, widgets: ~typing.Sequence[~progressbar.widgets.WidgetBase | str] | None = None, prefix: str | None = None, suffix: str | None = None, **kwargs: ~typing.Any) Generator[T, None, None] [source]¶