Skip to main content

revolution

Supported Versions PyPI Version GitHub Workflow Status codecov License

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')

Metadata

Release files for revolution 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for revolution 0.3.0
File Size Uploaded
revolution-0.3.0.tar.gz 14.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for revolution 0.3.0
File Interpreter ABI Platform
revolution-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.9 kB

Release files / revolution-0.3.0.tar.gz

Download URL revolution-0.3.0.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b8f0f9c08977e80265ff216e8c294d67b7a1ca818ac1dc37b2a513f8d03df077
BLAKE2b-256 checksum
How to use checksums
48a28687166756b44db24624bd3dfc48bf841c29e7fb5cbbfbb5a03cf0bb2291
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.9.1

Release files / revolution-0.3.0-py3-none-any.whl

Download URL revolution-0.3.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
569fa841cb209a68436c8ecc4d3786aafc316b12556626557b9ba6a396c77df5
BLAKE2b-256 checksum
How to use checksums
57b8f67c0f711ceddcd66f22abf7e26700e4a2293b67d845d89aac95cc95df3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.9.1

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page