Objects API Reference

This is the API reference for the objects used for the Prompt API Reference methods.

Prompt Input Objects

ItsPrompt.objects.prompts.type.CompletionDict

A type hint for the dict structure used to represent the completion dictionary.

alias of dict[str, CompletionDict | None]

ItsPrompt.objects.prompts.type.OptionWithId

The OptionWithId tuple is used to store an option, its id and an optional key (for expand prompt).

For all prompts excluding expand(), the tuple is structured as follows

  • The first element is the displayed option

  • The second element is the id of the option

For the expand() prompt, the tuple is structured as follows:

  • The first element is the key of the option

  • The second element is the displayed option

  • The third element is the id of the option

alias of tuple[str, str, str | None]

ItsPrompt.objects.prompts.type.OptionsList

Different types of options that can be used in a prompt.

Can be given by either:

  • A str, which is the displayed option and its id

  • A tuple containing the displayed option, its id and an optional key (for expand prompt)

  • A Separator instance

alias of tuple[str | tuple[str, str, str | None] | Separator, …]

ItsPrompt.objects.prompts.type.TablePromptDict

A type hint for the dict structure used to represent a table prompt.

The keys are the column names and the values are the cells in the column.

alias of dict[str, list[str]]

ItsPrompt.objects.prompts.type.TablePromptList

A type hint for the list structure used to represent a table prompt.

Each inner list represents a row in the table.

The cells are represented by the str type.

alias of list[list[str]]

class ItsPrompt.objects.prompts.separator.Separator(label: str)[source]

Used for creating distinctive sections in the prompt types:

It is purely cosmetic.

Styling Objects

class ItsPrompt.data.style.PromptStyle(question_mark: str = '', question: str = '', option: str = '', selected_option: str = '', tooltip: str = '', error: str = '', text: str = '', grayout: str = '', disabled: str = '', separator: str = '')[source]

The style object used for styling the prompts.

Empty styles will not be styled, so they appear without any styling.

disabled: str = ''
error: str = ''
grayout: str = ''
option: str = ''
question: str = ''
question_mark: str = ''
selected_option: str = ''
separator: str = ''
text: str = ''
tooltip: str = ''
ItsPrompt.data.style.create_from_default() PromptStyle[source]

Returns a copy of the default_style which can be edited without changing the default style.

Returns:

An editable copy of the default style

Return type:

PromptStyle

ItsPrompt.data.style.default_style = PromptStyle(question_mark='fg:ansigreen', question='', option='', selected_option='fg:ansicyan', tooltip='fg:ansibrightblue bg:ansiwhite bold', error='fg:ansiwhite bg:ansired bold', text='', grayout='fg:ansibrightblack', disabled='fg:ansibrightblack', separator='fg:ansibrightgreen')

The default style for the prompts.