FormScreen
Base classes
| Name |
Children |
Inherits |
ModalScreen textual.screen A screen with bindings that take precedence over the App's key bindings. |
|
|
⋔ Inheritance diagram
graph TD
1911187555["view.FormScreen"]
1923423225["screen.ModalScreen"]
642899982["screen.Screen"]
3481597255["typing.Generic"]
2751680898["builtins.object"]
4188532303["widget.Widget"]
3946681048["dom.DOMNode"]
53685856["message_pump.MessagePump"]
1923423225 --> 1911187555
642899982 --> 1923423225
3481597255 --> 642899982
2751680898 --> 3481597255
4188532303 --> 642899982
3946681048 --> 4188532303
53685856 --> 3946681048
2751680898 --> 53685856
🛈 DocStrings
Bases: ModalScreen[Any]
A modal form; dismisses with the validated result, or None when cancelled.
Source code in src/promptantic/textual/view.py
| class FormScreen(ModalScreen[Any]):
"""A modal form; dismisses with the validated result, or ``None`` when cancelled."""
DEFAULT_CSS = """
FormScreen { align: center middle; }
FormScreen > FormPanel {
width: 90%; max-width: 110; max-height: 90%;
border: thick $accent; background: $surface; padding: 0 1;
}
"""
BINDINGS: ClassVar = [
Binding("ctrl+s", "submit", "Submit", priority=True),
Binding("escape", "cancel", "Cancel"),
]
def __init__(
self,
target: FormTarget[Any] | type[Any] | Mapping[str, Any],
*,
title: str | None = None,
initial: Mapping[str, Any] | None = None,
) -> None:
super().__init__()
self.panel = FormPanel(_as_target(target), title=title, initial=initial)
def compose(self) -> ComposeResult:
yield self.panel
def action_submit(self) -> None:
self.panel.form.submit()
def action_cancel(self) -> None:
self.dismiss(None)
def on_form_view_submitted(self, event: FormView.Submitted) -> None:
self.dismiss(event.result)
def on_form_view_cancelled(self, _event: FormView.Cancelled) -> None:
self.dismiss(None)
|
:fa-brands-github: Show source on GitHub