refactor email viewer app
This commit is contained in:
26
maildir_gtd/screens/CreateTask.py
Normal file
26
maildir_gtd/screens/CreateTask.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from textual import on
|
||||
from textual.app import ComposeResult, Screen
|
||||
from textual.widgets import Input, Label
|
||||
from textual.containers import Horizontal
|
||||
|
||||
|
||||
class CreateTaskScreen(Screen[str]):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Horizontal(
|
||||
Label("$>", id="task_prompt"),
|
||||
Label("task add ", id="task_prompt_label"),
|
||||
Input(placeholder="arguments", id="task_input")
|
||||
)
|
||||
|
||||
@on(Input.Submitted)
|
||||
def handle_task_args(self) -> None:
|
||||
input_widget = self.query_one("#task_input", Input)
|
||||
self.disabled = True
|
||||
self.loading = True
|
||||
task_args = input_widget.value
|
||||
self.dismiss(task_args)
|
||||
|
||||
@on(Input._on_key)
|
||||
def handle_close(self, event) -> None:
|
||||
if (event.key == "escape" or event.key == "ctrl+c"):
|
||||
self.dismiss()
|
||||
Reference in New Issue
Block a user