Skip to main content

Beautiful terminal spinners in Python

Project description


halo

Build Status Build status Coverage Status PyPI awesome

Beautiful spinners for terminal, IPython and Jupyter

halo

Install

$ pip install halo

Usage

from halo import Halo

spinner = Halo(text='Loading', spinner='dots')
spinner.start()

# Run time consuming work here
# You can also change properties for spinner as and when you want

spinner.stop()

Alternatively, you can use halo with Python's with statement:

from halo import Halo

with Halo(text='Loading', spinner='dots'):
    # Run time consuming work here

Finally, you can use halo as a decorator:

from halo import Halo

@Halo(text='Loading', spinner='dots')
def long_running_function():
    # Run time consuming work here
    pass

long_running_function()

API

Halo([text|spinner|animation|placement|color|interval|stream|enabled])

text

Type: str

Text shown along with spinner.

spinner

Type: str|dict

If string, it should be one of the spinners listed in the given json file. If a dict is passed, it should define interval and frames. Something like:

{
    'interval': 100,
    'frames': ['-', '+', '*', '+', '-']
}

Defaults to dots spinner. For Windows users, it defaults to line spinner.

animation

Type: str Values: bounce, marquee

Animation to apply to the text if it's too large and doesn't fit in the terminal. If no animation is defined, the text will be ellipsed.

placement

Type: str Values: left, right

Which side of the text the spinner should be displayed. Defaults to left

color

Type: str Values: grey, red, green, yellow, blue, magenta, cyan, white

Color of the spinner. Defaults to cyan.

interval

Type: float

Interval between each frame. Defaults to spinner interval (recommended).

stream

Type: file

Stream to write the output. Defaults to sys.stdout.

enabled

Type: bool

Enable or disable the spinner. Defaults to True.

Methods

Following are the methods available:

spinner.start([text])

Starts the spinner. If text is passed, it is set as spinner text. Returns the instance.

spinner.stop()

Stops and clears the spinner. Returns the instance.

spinner.clear()

Clears the spinner. Returns the instance.

spinner.render()

Manually renders a new frame. Returns the instance.

spinner.frame()

Returns next frame to be rendered.

spinner.succeed([text])

text: Type: str

Stops the spinner and changes symbol to . If text is provided, it is persisted else current text is persisted. Returns the instance.

spinner.fail([text])

text: Type: str

Stops the spinner and changes symbol to . If text is provided, it is persisted else current text is persisted. Returns the instance.

spinner.warn([text])

text: Type: str

Stops the spinner and changes symbol to . If text is provided, it is persisted else current text is persisted. Returns the instance.

spinner.info([text])

text: Type: str

Stops the spinner and changes symbol to . If text is provided, it is persisted else current text is persisted. Returns the instance.

spinner.stop_and_persist([symbol|text])

Stops the spinner and changes symbol and text. Returns the instance.

symbol

Type: str

Symbol to replace the spinner with. Defaults to ' '.

text

Type: str

Text to be persisted. Defaults to instance text.

Persist spin

spinner.text

Change the text of spinner.

spinner.color

Change the color of spinner

spinner.spinner

Change the spinner itself.

How to contribute?

Please see Contributing guidelines for more information.

Like it?

:star2: this repo to show support. Let me know you liked it on Twitter. Also, share the project.

Related

  • py-spinners - Spinners in Python
  • py-log-symbols - Log Symbols in Python
  • ora - Elegant terminal spinners in JavaScript (inspiration behind this project)

License

MIT © Manraj Singh

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

halo-0.0.19.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

halo-0.0.19-py2-none-any.whl (9.9 kB view details)

Uploaded Python 2

File details

Details for the file halo-0.0.19.tar.gz.

File metadata

  • Download URL: halo-0.0.19.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.14

File hashes

Hashes for halo-0.0.19.tar.gz
Algorithm Hash digest
SHA256 f0844556cb815ddd66889ccb5f17a2bb2f96bb475c4978cf0ffef2490ca95098
MD5 0e45e66f32b9dba501de836f4f02dd81
BLAKE2b-256 3d034d619b9aceaaa773f4feb5977dd602075eb5baf894aeffae34074c71059c

See more details on using hashes here.

File details

Details for the file halo-0.0.19-py2-none-any.whl.

File metadata

  • Download URL: halo-0.0.19-py2-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.14

File hashes

Hashes for halo-0.0.19-py2-none-any.whl
Algorithm Hash digest
SHA256 e19bf9f2588275a629c7d5c66a8a1a4874d846a67bcc499a2df7914f0832264b
MD5 aa12f3f1acd27866854fc95ba8fd3945
BLAKE2b-256 e8419b5a8461b78e3b30f838c1ea83946e209bf7203c36819d4d5ad97a4c8120

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