upsies.uis.prompts

Generic user dialogs

Prompts take arbitrary keyword arguments that are used by the user interface to create the dialog.

When the user makes a choice, the user interface must pass it on to the prompt object via set_result(). The prompt object then takes care of passing the result to any callbacks.

Classes

class upsies.uis.prompts.CheckListPrompt(*, callbacks=(), options, question=None, focused=None)[source]

Bases: Prompt

Pick multiple of two or more options

Parameters:
  • options – Sequence of choices

  • question – Question to show alongside the options or None

  • focused – One of the options to focus initially or None to focus the first option

class upsies.uis.prompts.Prompt(*, callbacks=(), **parameters)[source]

Bases: object

Base class of all prompts

Every prompt takes a sequence of callbacks. Any other keyword arguments are specified by the subclass. The user interface can access them as parameters to create UI widgets.

Prompt instances are awaitable. The await will return when the user provided input. The return value of the await call is the same as the result property. Prompts can be awaited multiple times at any time.

property parameters

Keyword arguments from instantiation (except for callbacks)

async wait()[source]

Block until set_result() is called

on_result(callback)[source]

Schedule callback to be called when set_result() is called

set_result(result)[source]

Take the result from the user dialog and make it available to callbacks and via the result property

property result

Input from the user

class upsies.uis.prompts.RadioListPrompt(*, callbacks=(), options, question=None, focused=None)[source]

Bases: Prompt

Pick one of two or more options

Parameters:
  • options – Sequence of choices

  • question – Question to show alongside the options or None

  • focused – One of the options to focus initially or None to focus the first option

class upsies.uis.prompts.TextPrompt(*, callbacks=(), question=None, text='')[source]

Bases: Prompt

Input of arbitrary text

Parameters:
  • question – Question to show alongside the options or None

  • text – Prefilled text the user can delete or edit