Fix mode panels: Screen → Container with on_show/on_hide lifecycle
Textual's ContentSwitcher expects regular Widget/Container children, not Screen subclasses. Screen's on_mount fires for all children at once regardless of visibility, so demo workers for all 5 modes started simultaneously and competed for the bridge. Container children get proper on_show/on_hide from ContentSwitcher's visibility toggling — only the active panel's worker runs.
This commit is contained in:
parent
64c33985a3
commit
8da486719a
5 changed files with 23 additions and 28 deletions
|
|
@ -10,8 +10,7 @@ import os
|
|||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "tools"))
|
||||
|
||||
from textual.app import ComposeResult
|
||||
from textual.containers import Horizontal, Vertical
|
||||
from textual.screen import Screen
|
||||
from textual.containers import Container, Horizontal, Vertical
|
||||
from textual.widgets import Label, Input, Button, Static, ProgressBar, Checkbox
|
||||
from textual import work
|
||||
from textual.worker import Worker
|
||||
|
|
@ -37,7 +36,7 @@ def _alloc_table(start: float, stop: float) -> str:
|
|||
return "\n".join(lines)
|
||||
|
||||
|
||||
class LBandScreen(Screen):
|
||||
class LBandScreen(Container):
|
||||
"""L-band direct input analyzer with allocation annotations."""
|
||||
|
||||
DEFAULT_CSS = """
|
||||
|
|
@ -130,11 +129,11 @@ class LBandScreen(Screen):
|
|||
yield Button("Sweep", id="lband-sweep-btn", variant="success")
|
||||
yield Button("Stop", id="lband-stop-btn", variant="error")
|
||||
|
||||
def on_mount(self) -> None:
|
||||
if self._bridge.is_demo:
|
||||
def on_show(self) -> None:
|
||||
if self._bridge.is_demo and not self._sweeping:
|
||||
self._start_sweep()
|
||||
|
||||
def on_unmount(self) -> None:
|
||||
def on_hide(self) -> None:
|
||||
self._stop_sweep()
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue