Skip to main content

An assortment of spinners to use while your Python programs run.

Project description

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

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

revolution-0.3.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

revolution-0.3.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file revolution-0.3.0.tar.gz.

File metadata

  • Download URL: revolution-0.3.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for revolution-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b8f0f9c08977e80265ff216e8c294d67b7a1ca818ac1dc37b2a513f8d03df077
MD5 eb9648fb6fdfe82fc1a690a549e2d8f1
BLAKE2b-256 48a28687166756b44db24624bd3dfc48bf841c29e7fb5cbbfbb5a03cf0bb2291

See more details on using hashes here.

File details

Details for the file revolution-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: revolution-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for revolution-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 569fa841cb209a68436c8ecc4d3786aafc316b12556626557b9ba6a396c77df5
MD5 b66cd4050bd26c7fd5a83967b9ea724b
BLAKE2b-256 57b8f67c0f711ceddcd66f22abf7e26700e4a2293b67d845d89aac95cc95df3b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page