progressbar.multi module¶
- class progressbar.multi.MultiBar(bars: ~collections.abc.Mapping[str, ~progressbar.bar.ProgressBar] | ~collections.abc.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: ~collections.abc.Callable[[~progressbar.bar.ProgressBar], ~typing.Any] | None = None, *, join_timeout: ~datetime.timedelta | float | None = None, **progressbar_kwargs: ~typing.Any)[source]¶
Bases:
dict[str,ProgressBar]Render and manage multiple progressbars from background threads.
On a clean context-manager exit the multibar waits for its render thread via
join(). By default (join_timeout=None) that wait is unbounded, so a bar that never finishes blocks the program forever. Passjoin_timeout(seconds, or adatetime.timedelta) to bound that wait: once it elapses any still-unfinished bars are abandoned and the render thread – a daemon – is left running so the program can exit. The default preserves the historical wait-forever behavior.- get_sorted_bars() list[ProgressBar][source]¶
- 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.multi.SortKey(*values)[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'¶