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: object

Activity 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

  • format (str) – See format

  • style (str) – prompt-toolkit style

  • extend_width (bool) – Whether to maximize horizontally

property active

Whether text is continuously updated and callback called

Note

This updates text in an asynchronous task. If you try to set this attribute outside of an asynchronous context, you get RuntimeError: no running event loop.

enable()[source]

Calling this method sets active to True

disable()[source]

Calling this method sets active to False

property format

Format string

{indicator} is replaced with the current state in states.

property text

Formatted format string

class upsies.uis.tui.widgets.CheckList(options=(), question=None, focused=None, autodetected_indexes=(), on_accepted=None)[source]

Bases: object

List 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 str or 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.HLabel(text, content, group=None, style='')[source]

Bases: object

class upsies.uis.tui.widgets.Image(bytes=b'', width=None, height=None)[source]

Bases: object

class upsies.uis.tui.widgets.InputField(text='', *, width=None, extend_width=True, read_only=False, on_accepted=None, on_changed=None, style='')[source]

Bases: object

Single line of user-editable text

property is_loading

Whether an activity indicator is displayed

class upsies.uis.tui.widgets.ProgressBar(text='', width=None)[source]

Bases: object

class upsies.uis.tui.widgets.RadioList(options=(), question=None, focused=None, autodetected_index=None, on_accepted=None)[source]

Bases: object

List 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 str or 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

class upsies.uis.tui.widgets.TextField(text='', *, width=None, height=1, extend_width=True, style='')[source]

Bases: object

Single line of non-editable text

property is_loading

Whether an activity indicator is displayed

class upsies.uis.tui.widgets.VLabel(text, content, style='')[source]

Bases: object