70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
from textual.reactive import Reactive
|
|
from textual.app import RenderResult, ComposeResult
|
|
from textual.widgets import Static, Label
|
|
from textual.containers import Vertical, Horizontal, Container, ScrollableContainer
|
|
|
|
class EnvelopeHeader(ScrollableContainer):
|
|
|
|
subject = Reactive("")
|
|
from_ = Reactive("")
|
|
to = Reactive("")
|
|
date = Reactive("")
|
|
cc = Reactive("")
|
|
bcc = Reactive("")
|
|
|
|
"""Header for the email viewer."""
|
|
def on_mount(self) -> None:
|
|
"""Mount the header."""
|
|
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield Horizontal(
|
|
Label("Subject:", classes="header_key"),
|
|
Label(self.subject, classes="header_value", markup=False, id="subject")
|
|
)
|
|
yield Horizontal(
|
|
Label("Date:", classes="header_key"),
|
|
Label(self.date, classes="header_value", markup=False, id="date"),
|
|
)
|
|
# yield Horizontal(
|
|
# Label("From:", classes="header_key"),
|
|
# Label(self.from_, classes="header_value", markup=False, id="from"),
|
|
# )
|
|
# yield Horizontal(
|
|
# Label("To:", classes="header_key"),
|
|
# Label(self.to, classes="header_value", markup=False, id="to"),
|
|
# )
|
|
# yield Horizontal(
|
|
|
|
# )
|
|
# yield Horizontal(
|
|
# Label("CC:", classes="header_key"),
|
|
# Label(self.cc, classes="header_value", markup=False, id="cc"),
|
|
# )
|
|
|
|
|
|
def watch_subject(self, subject: str) -> None:
|
|
"""Watch the subject for changes."""
|
|
self.query_one("#subject").update(subject)
|
|
|
|
# def watch_to(self, to: str) -> None:
|
|
# """Watch the to field for changes."""
|
|
# self.query_one("#to").update(to)
|
|
|
|
# def watch_from(self, from_: str) -> None:
|
|
# """Watch the from field for changes."""
|
|
# self.query_one("#from").update(from_)
|
|
|
|
def watch_date(self, date: str) -> None:
|
|
"""Watch the date for changes."""
|
|
self.query_one("#date").update(date)
|
|
|
|
# def watch_cc(self, cc: str) -> None:
|
|
# """Watch the cc field for changes."""
|
|
# self.query_one("#cc").update(cc)
|
|
|
|
|
|
|
|
|
|
|