tickers - Wait tickers for long-running processes
- Purpose:
This module provides a wait tickers for long-running processes in your program.
- Platform:
Linux/Windows | Python 3.6+
- Developer:
J Berendt
- Email:
- Comments:
The idea for this code was taken from:
- Example:
For usage examples, refer to the following class docstrings:
# pylint: disable=super-with-arguments # For Py35 compatibility.
- _GenericWait.stop(err: bool = False)[source]
Stop the ticker.
- Parameters:
err (bool, optional) – If the ticker’s processing is stopped under error, passing
True
will clear the output line rather than printingDone.
to the console. Defaults to False.
- class tickers.Spinner(delay=None)[source]
This class provides a wait spinner for long-running processes.
- Parameters:
delay (float, optional) – The time delay between each spinner tick. Defaults to None.
- Example:
Implement a spinner into your program:
>>> from time import sleep # For demo only. >>> from utils4.tickers import Spinner >>> spinner = Spinner() >>> spinner.start() >>> # Some long running process: >>> for _ in range(50): >>> sleep(0.05) >>> spinner.stop()
The output looks like:
Processing: < spinning > Done.
- class tickers.WaitTicker(charset: str = '.', delay: float = 0.05, nticks: int = 25)[source]
This class features a wait ticker for long-running processes within your program.
- Parameters:
charset (str, optional) – The character(s) to be used as the ticker. Defaults to
.
.delay (float, optional) – The time delay between each tick. Defaults to 0.05.
nticks (int, optional) – The length of the ticker, in characters. Defaults to 25.
- Example:
Implement a ticker into your program:
>>> from time import sleep # For demo only. >>> from utils4.tickers import WaitTicker >>> ticker = WaitTicker(charset='-->', delay=0.05, nticks=25) >>> ticker.start() >>> # Some long running process: >>> for _ in range(75): >>> sleep(0.05) >>> ticker.stop()
The output looks like:
Processing: -->-->-->--> # Expanding and contracting Done.
- __annotations__ = {}