excellent
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from textual.reactive import Reactive
|
||||
from textual.app import RenderResult
|
||||
from textual.app import RenderResult, ComposeResult
|
||||
from textual.widgets import Static, Label
|
||||
from textual.containers import Vertical, Horizontal, Container, ScrollableContainer
|
||||
|
||||
class EnvelopeHeader(Static):
|
||||
class EnvelopeHeader(ScrollableContainer):
|
||||
|
||||
subject = Reactive("")
|
||||
from_ = Reactive("")
|
||||
@@ -15,12 +16,51 @@ class EnvelopeHeader(Static):
|
||||
def on_mount(self) -> None:
|
||||
"""Mount the header."""
|
||||
|
||||
def render(self) -> RenderResult:
|
||||
return f"[b]{self.subject}[/b] [dim]({self.date})[/] \r\n" \
|
||||
f"[dim]From:[/dim] {self.from_} [dim]To:[/dim] {self.to} \r\n" \
|
||||
f"[dim]Date:[/dim] {self.date} \r\n" \
|
||||
f"[dim]CC:[/dim] {self.cc} \r\n" \
|
||||
f"[dim]BCC:[/dim] {self.bcc} \r\n" \
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Horizontal(
|
||||
Label("Subject:", classes="header_key"),
|
||||
Label(self.subject, classes="header_value", markup=False, id="subject"),
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user