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()
|
||||
25
maildir_gtd/screens/OpenMessage.py
Normal file
25
maildir_gtd/screens/OpenMessage.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from textual import on
|
||||
from textual.app import ComposeResult, Screen
|
||||
from textual.widgets import Input, Label, Button
|
||||
from textual.containers import Horizontal
|
||||
|
||||
class OpenMessageScreen(Screen[int]):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Horizontal(
|
||||
Label("📨", id="message_label"),
|
||||
Input(placeholder="Enter message ID (integer only)", type="integer", id="open_message_input"),
|
||||
Button("Open", variant="primary", id="open_message_button")
|
||||
)
|
||||
|
||||
@on(Input.Submitted)
|
||||
def handle_message_id(self) -> None:
|
||||
input_widget = self.query_one("#open_message_input", Input)
|
||||
self.disabled = True
|
||||
self.loading = True
|
||||
message_id = int(input_widget.value)
|
||||
self.dismiss(message_id)
|
||||
|
||||
@on(Input._on_key)
|
||||
def handle_close(self, event) -> None:
|
||||
if (event.key == "escape" or event.key == "ctrl+c"):
|
||||
self.dismiss()
|
||||
1
maildir_gtd/screens/__init__.py
Normal file
1
maildir_gtd/screens/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# Initialize the screens subpackage
|
||||
BIN
maildir_gtd/screens/__pycache__/CreateTask.cpython-311.pyc
Normal file
BIN
maildir_gtd/screens/__pycache__/CreateTask.cpython-311.pyc
Normal file
Binary file not shown.
BIN
maildir_gtd/screens/__pycache__/OpenMessage.cpython-311.pyc
Normal file
BIN
maildir_gtd/screens/__pycache__/OpenMessage.cpython-311.pyc
Normal file
Binary file not shown.
BIN
maildir_gtd/screens/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
maildir_gtd/screens/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
Reference in New Issue
Block a user