| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- # -*- coding: utf-8 -*-
- """
- Titelleiste fuer die Trixy-TUI.
- """
- from textual.reactive import reactive
- from textual.widget import Widget
- from textual.app import RenderResult
- from rich.text import Text
- class TrixyHeader(Widget):
- """
- Titelleiste mit Ansichtstitel und Verbindungsinformation.
- Zeigt z.B.: "Trixy Config > Health [server@localhost:2105]"
- """
- DEFAULT_CSS = """
- TrixyHeader {
- dock: top;
- height: 1;
- background: $accent;
- color: $text;
- content-align: center middle;
- }
- """
- subtitle: reactive[str] = reactive("")
- connection_info: reactive[str] = reactive("")
- def render(self) -> RenderResult:
- """Rendert die Titelleiste."""
- title = Text("Trixy Config", style="bold")
- if self.subtitle:
- title.append(" > ", style="dim")
- title.append(self.subtitle)
- if self.connection_info:
- # Rechtsbuendig mit Padding
- padding = " " * max(1, self.size.width - len(title.plain) - len(self.connection_info) - 4)
- title.append(padding)
- title.append(f"[{self.connection_info}]", style="dim italic")
- return title
|