upsies.uis.tui.widgets
Custom TUI widgets
Classes
- class upsies.uis.tui.widgets.ActivityIndicator(*, callback=None, states=('⠷', '⠯', '⠟', '⠻', '⠽', '⠾'), interval=0.3, format='{indicator}', style='', extend_width=False)[source]
Bases:
objectActivity indicator that cycles through a sequence of strings
- Parameters:
callback (callable) – Callable that receives a single string from states as a positional argument
states – Sequence of strings that are cycled through and passed to callback individually
interval (float) – Delay between calls to callback
style (str) – prompt-toolkit style
extend_width (bool) – Whether to maximize horizontally
- property active
Whether
textis continuously updated and callback calledNote
This updates
textin an asynchronous task. If you try to set this attribute outside of an asynchronous context, you getRuntimeError: no running event loop.
- property format
Format string
{indicator}is replaced with the current state in states.
- class upsies.uis.tui.widgets.CheckList(options=(), question=None, focused=None, autodetected_indexes=(), on_accepted=None)[source]
Bases:
objectList of options from which the user can select multiple
- Parameters:
options – Sequence of options the user can make
question – Text that is displayed above the options or any falsy value
focused – Focused index or option or None to focus the first option
on_accepted – Callback that gets the ticked options
Each option item must be a
stror a sequence with one or more items. The first item is presented to the user. on_accepted gets the complete option item.- property marked_options
Currently marked items in
options
- class upsies.uis.tui.widgets.InputField(text='', *, width=None, extend_width=True, read_only=False, on_accepted=None, on_changed=None, style='')[source]
Bases:
objectSingle line of user-editable text
- property is_loading
Whether an activity indicator is displayed
- class upsies.uis.tui.widgets.RadioList(options=(), question=None, focused=None, autodetected_index=None, on_accepted=None)[source]
Bases:
objectList of options from which the user can select one
- Parameters:
options – Sequence of options the user can make
question – Text that is displayed above the options or any falsy value
focused – Focused index or option or None to focus the first option
on_accepted – Callback that gets the user choice
Each option item must be a
stror a sequence with one or more items. The first item is presented to the user. on_accepted gets the complete option item.- property focused_option
Currently focused item in
options