repype.textual.confirm

class repype.textual.confirm.ConfirmScreen(text: str, yes_text: str = 'Yes', no_text: str = 'No', yes_variant: str = 'primary', no_variant: str = 'default', default: Literal['yes', 'no'] | None = None)

Bases: ModalScreen[bool]

A screen that displays a confirmation dialog with a message and two buttons.

Parameters:
  • text – The text to display in the dialog.

  • yes_text – The text to display on the “Yes” button.

  • no_text – The text to display on the “No” button.

  • yes_variant – The variant to use for the “Yes” button.

  • no_variant – The variant to use for the “No” button.

  • default – The button to focus by default.

Raises:

AssertionError – If the default argument is invalid.

can_focus: bool = False

Widget may receive focus.

can_focus_children: bool = True

Widget’s children may receive focus.

compose() Iterator[Widget]

Compose the screen.

Yields:

The components of the screen.

default: Literal['yes', 'no'] | None

The button to focus by default.

no() None

Handle the “No” button being pressed.

Dismisses the dialog with a value of False.

no_text: str

The text to display on the “No” button.

no_variant: str

The variant to use for the “No” button.

on_mount() None

Select the default button when the screen is mounted.

text: str

The text to display in the dialog.

yes() None

Handle the “Yes” button being pressed.

Dismisses the dialog with a value of True.

yes_text: str

The text to display on the “Yes” button.

yes_variant: str

The variant to use for the “Yes” button.

async repype.textual.confirm.confirm(app: App, *args, **kwargs) bool

Display a confirmation dialog and wait for it to be dismissed.

Parameters:
  • app – The application instance.

  • args – The arguments to pass to the ConfirmScreen constructor.

  • kwargs – The keyword arguments to pass to the ConfirmScreen constructor.

Returns:

True if the “Yes” button was pressed, and False otherwise.