FormApp
Base classes
| Name |
Children |
Inherits |
App textual.app The base class for Textual Applications. |
|
|
⋔ Inheritance diagram
graph TD
2344137174["view.FormApp"]
3799205450["app.App"]
3481597255["typing.Generic"]
2751680898["builtins.object"]
3946681048["dom.DOMNode"]
53685856["message_pump.MessagePump"]
3799205450 --> 2344137174
3481597255 --> 3799205450
2751680898 --> 3481597255
3946681048 --> 3799205450
53685856 --> 3946681048
2751680898 --> 53685856
🛈 DocStrings
Bases: App[Any]
A one-form app; :meth:run_async returns the result (None: cancelled).
Source code in src/promptantic/textual/view.py
| class FormApp(App[Any]):
"""A one-form app; :meth:`run_async` returns the result (``None``: cancelled)."""
CSS = "Screen { height: auto; overflow: hidden; } FormPanel { padding: 0 1; }"
BINDINGS: ClassVar = [
Binding("ctrl+s", "submit", "Submit", priority=True),
Binding("escape", "cancel", "Cancel"),
]
def __init__(
self,
target: FormTarget[Any],
*,
title: str | None = None,
initial: Mapping[str, Any] | None = None,
) -> None:
super().__init__()
self.panel = FormPanel(target, title=title, initial=initial)
self.cancelled = False
def compose(self) -> ComposeResult:
yield self.panel
def action_submit(self) -> None:
self.panel.form.submit()
def action_cancel(self) -> None:
self.cancelled = True
self.exit(None)
def on_form_view_submitted(self, event: FormView.Submitted) -> None:
self.exit(event.result)
def on_form_view_cancelled(self, _event: FormView.Cancelled) -> None:
self.action_cancel()
|
:fa-brands-github: Show source on GitHub