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.
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
, orwhite
. Defaults toNone
. - color (str, optional) – Color of the spinner. Can be
grey
,red
,green
,yellow
,blue
,magenta
,cyan
, orwhite
. Defaults tocyan
. - 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
andframes
. Something like:{ 'interval': 100, 'frames': ['-', '+', '*', '+', '-'] }
- animation (str, optional) – Animation to apply if text is too large. Can be
bounce
ormarquee
. 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
orright
. Defaults toleft
. - 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
-
_write
(s)[source]¶ Write to the stream, if writable
Parameters: s (str) – Characters to write to the stream
-
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
-
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
-
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 changes symbol and text.
Parameters: 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