Skip to main content

Beautiful terminal spinners in Python

Project description

.. raw:: html

<h1 align="center">

halo

.. raw:: html

</h1>

|Build Status| |Build status| |PyPI| |awesome| > Beautiful terminal
spinners in Python

.. figure:: https://raw.githubusercontent.com/ManrajGrover/halo/master/art/doge_spin.gif
:alt: halo

halo

Install
-------

.. code:: shell

$ pip install halo

Usage
-----

.. code:: py

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

API
---

``Halo([options|text])``
~~~~~~~~~~~~~~~~~~~~~~~~

If a string is given, it will be treated as text for spinner.

``options``
^^^^^^^^^^^

A dictionary defining various available settings.

``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 <https://github.com/sindresorhus/cli-spinners/blob/dac4fc6571059bb9e9bc204711e9dfe8f72e5c6f/spinners.json>`__
file. If a dict is passed, it should define ``interval`` and ``frames``.
Something like:

.. code:: py

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

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

``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([options])``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``options``: *Type*: ``dict``
'''''''''''''''''''''''''''''

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

``options``
'''''''''''

``symbol``


*Type*: ``str``

Symbol to replace the spinner with.

``text``


*Type*: ``str``

Text to be persisted.

.. figure:: https://raw.githubusercontent.com/ManrajGrover/halo/master/art/persist_spin.gif
:alt: Persist spin

Persist spin

``spinner.text``
^^^^^^^^^^^^^^^^

Change the text of spinner.

``spinner.color``
^^^^^^^^^^^^^^^^^

Change the color of spinner

``spinner.spinner``
^^^^^^^^^^^^^^^^^^^

Change the spinner itself.

To Do
-----

- [ ] [Support Windows](https://github.com/ManrajGrover/halo/issues/5)

Like it?
--------

:star2: this repo to show support. Let me know you liked it on
`Twitter <https://twitter.com/manrajsgrover>`__. Also, share the
`project <https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2FManrajGrover%2Fhalo&via=manrajsgrover&text=Checkout%20%23halo%20-%20a%20beautiful%20%23terminal%20%23spinners%20library%20for%20%23python&hashtags=github%2C%20pypi>`__.

Related
-------

- `py-spinners <https://github.com/ManrajGrover/py-spinners>`__
- `py-log-symbols <https://github.com/ManrajGrover/py-log-symbols>`__
- `ora <https://github.com/sindresorhus/ora>`__

License
-------

`MIT <https://github.com/ManrajGrover/halo/blob/master/LICENSE>`__ ©
Manraj Singh

.. |Build Status| image:: https://travis-ci.org/ManrajGrover/halo.svg?branch=master
:target: https://travis-ci.org/ManrajGrover/halo
.. |Build status| image:: https://ci.appveyor.com/api/projects/status/wa6t414gltr403ff?svg=true
:target: https://ci.appveyor.com/project/ManrajGrover/halo
.. |PyPI| image:: https://img.shields.io/pypi/v/halo.svg
:target: https://github.com/ManrajGrover/halo
.. |awesome| image:: https://img.shields.io/badge/awesome-yes-green.svg

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.3.tar.gz (7.2 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: halo-0.0.3.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for halo-0.0.3.tar.gz
Algorithm Hash digest
SHA256 fdd643a17147e6ce02d03c9be7a5ea59cbfc88bc95873733eb830228a0a260f9
MD5 5ea3e20d9ee5501e6e85ecb9457d9858
BLAKE2b-256 fbc9f42ab288b99182913837108298718704c2ffd87a107da1bb2dd2f87711b3

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