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:
PromptPick 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:
objectBase 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
parametersto 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
resultproperty. 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
resultproperty
- property result
Input from the user
- class upsies.uis.prompts.RadioListPrompt(*, callbacks=(), options, question=None, focused=None)[source]
Bases:
PromptPick 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