| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- # -*- coding: utf-8 -*-
- """
- Plugin SubView: Benutzerdefinierter Tab.
- Generischer View fuer plugin-spezifische Inhalte, die vom
- Plugin ueber get_config_tool_tabs() definiert werden.
- """
- from __future__ import annotations
- from textual.app import ComposeResult
- from textual.containers import Vertical
- from textual.widgets import Static
- from trixy_core.tui.views.base import MainView
- class PluginCustomView(MainView):
- """Dynamisch erstellter Tab fuer plugin-spezifische Inhalte."""
- def __init__(
- self,
- tab_title: str,
- tab_id: str,
- tab_data: dict | None = None,
- **kwargs,
- ) -> None:
- super().__init__(**kwargs)
- self.TITLE = tab_title
- self.VIEW_ID = tab_id
- self._plugin_data: dict = {}
- self._tab_data: dict = tab_data or {}
- def set_plugin(self, plugin_data: dict) -> None:
- """Setzt die Plugin-Basisdaten."""
- self._plugin_data = plugin_data
- def compose(self) -> ComposeResult:
- with Vertical(classes="section-box"):
- yield Static(
- f"[bold]{self.TITLE}[/bold]", classes="section-header"
- )
- yield Static(
- "[dim]Dieser Tab wird vom Plugin bereitgestellt.\n"
- "Plugin-spezifische Inhalte werden in zukuenftigen Versionen unterstuetzt.[/dim]",
- id=f"{self.VIEW_ID}-content",
- )
- async def on_activate(self) -> None:
- """Aktiviert den View."""
- content = self.query_one(f"#{self.VIEW_ID}-content", Static)
- tab_desc = self._tab_data.get("description", "")
- if tab_desc:
- content.update(f"[dim]{tab_desc}[/dim]")
|