AnimatedMarker¶
AnimatedMarker cycles through characters to show a spinner.
Reach for it for indeterminate work where there is nothing to measure a
percentage against, just a signal that the process is still alive.
Unlike Bar, it does not grow or fill: it replaces one character each
redraw. markers sets the cycle of characters (default |/-\).
- class progressbar.widgets.AnimatedMarker(markers: str = '|/-\\', default: str | None = None, fill: str = '', marker_wrap: str | tuple[str | None, str | None] | None = None, fill_wrap: str | tuple[str | None, str | None] | None = None, **kwargs: Any)[source]
Bases:
TimeSensitiveWidgetBaseAn animated marker that defaults to appearing as if it were rotating.
Create an AnimatedMarker.
- Parameters:
markers – Sequence of single-character frames cycled through on every redraw.
default – Frame shown once finished when fill is unset; defaults to markers[0].
fill – Marker character/callable used to pad the frame to width (see create_marker). Unset means no filling.
marker_wrap – Begin/end strings or template wrapped around the marker frame (see create_wrapper).
fill_wrap – Same as marker_wrap, for the fill.
**kwargs – Forwarded to the next class in the cooperative __init__ chain.
Example¶
"""``AnimatedMarker`` cycles through characters to show a spinner.
Reach for it for indeterminate work where there is nothing to measure a
percentage against -- just a signal that the process is still alive.
Unlike ``Bar``, it does not grow or fill; it only replaces one character
each redraw.
"""
import time
import progressbar
STEPS = 24
def main() -> None:
widgets = ['Working: ', progressbar.AnimatedMarker()]
with progressbar.ProgressBar(max_value=STEPS, widgets=widgets) as bar:
for step in range(STEPS):
bar.update(step + 1)
time.sleep(0.005)
if __name__ == '__main__':
main()
See also¶
Bar: a fill bar, for when a total is known.
BouncingBar: a full-width bouncing marker, also indeterminate.
RotatingMarker: the legacy name for this same widget.