An assortment of spinners to use while your Python programs run.
Project description
revolution
An assortment of spinners to use while your Python programs run.
Installation
In order to install revolution
, run the following in your command line:
pip install revolution
Usage
In order to use revolution
in your code, importing it is as simple as:
from revolution import Revolution
Function decorator
revolution
can be used as a function decorator:
import time
from revolution import Revolution
@Revolution
def do_something():
for _ in range(10):
time.sleep(0.1)
do_something()
You can also provide it a description while you wait for your task to finish:
import time
from revolution import Revolution
@Revolution(desc='Just passing time...')
def do_something():
for _ in range(10):
time.sleep(0.1)
do_something()
with statement
Another possible way to implement revolution
is through the use of a with statement:
import time
from revolution import Revolution
with Revolution(desc='Running through numbers') as rev:
for _ in range(100):
time.sleep(0.1)
rev.update(1)
You can also include a visual counter by including a total:
import time
from revolution import Revolution
with Revolution(desc='Counting up to 100', total=100) as rev:
for _ in range(100):
time.sleep(0.1)
rev.update(1)
for loop
If you give a Revolution object a range object or a list, you can then iterate over it:
import time
from revolution import Revolution
total = 0
for i in Revolution(range(100)):
total += i
time.sleep(0.1)
print(total)
Manual
Finally, you can use revolution
by manually controlling when to stop it:
from revolution import Revolution
rev = Revolution(desc='Doing things...')
rev.start()
# ...
rev.stop()
Parameters
These are the available parameters for initializing a Revolution object:
Revolution(func=None, desc='', total=None, style='', color='blue', success=None, safe=True, interval=None)
func
More info
func
: list or range, optional
If this is a list or range object, it will iterate over each of the elements and return them one by one.
The func
parameter should be left blank unless you initialize a Revolution object with a range object or a list.
desc
More info
desc
: str, optional
A string to use in place of the text that displays beside the spinner.
total
More info
total
: int, optional
An integer that indicates the total number of expected iterations.
style
More info
style
: str, optional
A string that indicates which spinner style to use. If style is None or if it doesn't exist, the classic style will be used.
Available options can be viewed by running revolution --example
or revolution -e
in your console.
color
More info
color
: str, optional
A string that indicates which color should be used for the spinner. If a color is not provided, the color will default to 'blue'.
Available options:
* black
* red
* green
* yellow
* blue
* violet
* cyan
* white
success
More info
success
: str, optional
A string that will be displayed beside the spinner when the spinner animation stops.
safe
More info
safe
: bool, optional
If True (default), spinners on Windows machines will always use the 'classic' style (even if a different style is provided).
If you are using a certain spinner style and are unsure as to how it will appear on Windows machines, it is recommended that you leave safe
set to its default value.
interval
More info
interval
: float, optional
A float value that is used to indicate the refresh rate of the entire spinner.
Styles
There are multiple built-in spinner styles that you can take advantage of. However, only the classic spinner will be used on Windows machines unless you set safe=False
when you initialize a Revolution object.
classic
Revolution(style='classic')
- Windows-friendly
- If a Revolution object doesn't contain a specified style, this is the style that it will default to
dots
Revolution(style='dots')
- Windows-friendly
equal
Revolution(style='equal')
- Windows-friendly
braille
Revolution(style='braille')
braille_long
Revolution(style='braille_long')
braille_crawl
Revolution(style='braille_crawl')
braille_bounce
Revolution(style='braille_bounce')
arc
Revolution(style='arc')
clear_quadrants
Revolution(style='clear_quadrants')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for revolution-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56d564025c38bcf16a0c0ea23c797258db9153710389d8a4b33b1d9fee5bb72b |
|
MD5 | 517f74ad033a599a784e1b78d5867f5d |
|
BLAKE2b-256 | ad076af9ddc74644e2e2ad459ae1268b72f7e4ccf2aa9c320a473ffe3beefb93 |