halo package

Submodules

halo.halo module

Beautiful terminal spinners in Python.

class halo.halo.Halo(text='', color='cyan', text_color=None, spinner=None, animation=None, placement='left', interval=-1, enabled=True, stream=<colorama.ansitowin32.StreamWrapper object>)[source]

Bases: object

Halo library.

CLEAR_LINE

Code to clear the line

Type:str

Constructs the Halo object.

Parameters:
  • text (str, optional) – Text shown along with spinner.
  • text_color (str, optional) – Color of the text to dislpay. Can be grey, red, green, yellow, blue, magenta, cyan, or white. Defaults to None.
  • color (str, optional) – Color of the spinner. Can be grey, red, green, yellow, blue, magenta, cyan, or white. Defaults to cyan.
  • spinner (str|dict, optional) –

    String or dictionary representing spinner. String can be one of 60+ spinners supported. If a dict is passed, it should define interval and frames. Something like:

    {
        'interval': 100,
        'frames': ['-', '+', '*', '+', '-']
    }
    
  • animation (str, optional) – Animation to apply if text is too large. Can be bounce or marquee. If no animation is defined, the text will be ellipsed.
  • placement (str, optional) – Side of the text to place the spinner on. Can be left or right. Defaults to left.
  • interval (int, optional) – Interval between each frame of the spinner in milliseconds. Defaults to spinner interval (recommended).
  • enabled (bool, optional) – Enable or disable the spinner. Defaults to True.
  • stream (io, optional) – Stream to write the output. Defaults to sys.stdout.
CLEAR_LINE = '\x1b[K'
SPINNER_PLACEMENTS = ('left', 'right')
_check_stream()[source]

Returns whether the stream is open, and if applicable, writable

Returns:Whether the stream is open
Return type:bool
_get_spinner(spinner)[source]

Extracts spinner value from options and returns value containing spinner frames and interval, defaults to dots spinner.

Parameters:spinner (dict, str) – Contains spinner value or type of spinner to be used
Returns:Contains frames and interval defining spinner
Return type:dict
_get_text(text)[source]

Creates frames based on the selected animation

Returns:
Return type:self
_hide_cursor()[source]

Disable the user’s blinking cursor

_render_frame()[source]

Renders the frame on the line after clearing it.

_show_cursor()[source]

Re-enable the user’s blinking cursor

_write(s)[source]

Write to the stream, if writable

Parameters:s (str) – Characters to write to the stream
animation

Getter for animation property.

Returns:Spinner animation
Return type:str
clear()[source]

Clears the line and returns cursor to the start of line.

Returns:
Return type:self
color

Getter for color property.

Returns:color value
Return type:str
fail(text=None)[source]

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

Parameters:text (None, optional) – Text to be shown alongside fail symbol.
Returns:
Return type:self
frame()[source]

Builds and returns the frame to be rendered

Returns:
Return type:self
info(text=None)[source]

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

Parameters:text (None, optional) – Text to be shown alongside info symbol.
Returns:
Return type:self
placement

Getter for placement property.

Returns:spinner placement
Return type:str
render()[source]

Runs the render until thread flag is set.

Returns:
Return type:self
spinner

Getter for spinner property.

Returns:spinner value
Return type:dict
spinner_id

Getter for spinner id

Returns:Spinner id value
Return type:str
start(text=None)[source]

Starts the spinner on a separate thread.

Parameters:text (None, optional) – Text to be used alongside spinner
Returns:
Return type:self
stop()[source]

Stops the spinner and clears the line.

Returns:
Return type:self
stop_and_persist(symbol=' ', text=None)[source]

Stops the spinner and changes symbol and text.

Parameters:
  • symbol (str, optional) – Symbol to replace the spinner with. Defaults to ' '.
  • text (str, optional) – Text to be persisted. Defaults to instance text.
https://raw.github.com/manrajgrover/halo/master/art/persist_spin.svg?sanitize=true
Returns:
Return type:self
succeed(text=None)[source]

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

Parameters:text (None, optional) – Text to be shown alongside success symbol.
Returns:
Return type:self
text

Getter for text property.

Returns:text value
Return type:str
text_color

Getter for text color property.

Returns:text color value
Return type:str
text_frame()[source]

Builds and returns the text frame to be rendered

Returns:
Return type:self
warn(text=None)[source]

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

Parameters:text (None, optional) – Text to be shown alongside warn symbol.
Returns:
Return type:self

halo.halo_notebook module

class halo.halo_notebook.HaloNotebook(text='', color='cyan', text_color=None, spinner=None, placement='left', animation=None, interval=-1, enabled=True, stream=<colorama.ansitowin32.StreamWrapper object>)[source]

Bases: halo.halo.Halo

_make_output_widget()[source]
_output(text='')[source]
_render_frame()[source]

Renders the frame on the line after clearing it.

clear()[source]

Clears the line and returns cursor to the start of line.

Returns:
Return type:self
start(text=None)[source]

Starts the spinner on a separate thread.

Parameters:text (None, optional) – Text to be used alongside spinner
Returns:
Return type:self
stop_and_persist(symbol=' ', text=None)[source]

Stops the spinner and persists the final frame to be shown.

Parameters:
  • symbol (str, optional) – Symbol to be shown in final frame
  • text (str, optional) – Text to be shown in final frame
Returns:

Return type:

self

Module contents