-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
33 lines (22 loc) · 743 Bytes
/
Copy pathexample.py
File metadata and controls
33 lines (22 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from datetime import datetime
from typing import Annotated
from pydantic import BaseModel
from textual.app import App
from ticklist.form import Form
from ticklist.tick_annotations import Multiline
from ticklist.types import NO_VALUE
class Person(BaseModel):
"""Define a form using a pydantic model."""
name: str
"""Name of the person."""
age: int = 10
notes: Annotated[str, Multiline()]
date_of_birth: datetime
class MyApp(App[None]):
def on_mount(self) -> None:
def handle_form_result(result: Person | None) -> None:
self.exit(message=f"{result=!r}")
frm = Form(Person, NO_VALUE)
self.push_screen(frm, handle_form_result)
if __name__ == "__main__":
MyApp().run()