Beautiful terminal spinners in Python
$ pip install halo
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()
If a string is given, it will be treated as text for spinner.
A dictionary defining various available settings.
Type: str
Text shown along with 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.
Type: str
Values: grey
, red
, green
, yellow
, blue
, magenta
, cyan
, white
Color of the spinner. Defaults to cyan
.
Type: float
Interval between each frame. Defaults to spinner interval (recommended).
Type: file
Stream to write the output. Defaults to sys.stdout
.
Type: bool
Enable or disable the spinner. Defaults to True
.
Following are the methods available:
Starts the spinner. If text
is passed, it is set as spinner text. Returns the instance.
Stops and clears the spinner. Returns the instance.
Clears the spinner. Returns the instance.
Manually renders a new frame. Returns the instance.
Returns next frame to be rendered.
Stops the spinner and changes symbol to ✔
. If text is provided, it is persisted else current text is persisted. Returns the instance.
Stops the spinner and changes symbol to ✖
. If text is provided, it is persisted else current text is persisted. Returns the instance.
Stops the spinner and changes symbol to ⚠
. If text is provided, it is persisted else current text is persisted. Returns the instance.
Stops the spinner and changes symbol to ℹ
. If text is provided, it is persisted else current text is persisted. Returns the instance.
Stops the spinner and changes symbol and text. Returns the instance.
Type: str
Symbol to replace the spinner with. Defaults to ' '.
Type: str
Text to be persisted. Defaults to instance text.
Change the text of spinner.
Change the color of spinner
Change the spinner itself.
🌟 this repo to show support. Let me know you liked it on Twitter. Also, share the project.
MIT © Manraj Singh