Skip to content

Commit

Permalink
admin - watchex: fix theme change
Browse files Browse the repository at this point in the history
  • Loading branch information
anschweitzer committed Dec 23, 2024
1 parent 01c357c commit 3511dbc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gw_spaceheat/admin/watch/watchex/relays2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from textual.app import ComposeResult
from textual.color import Color
from textual.containers import Vertical
from textual.signal import Signal
from textual.theme import Theme
from textual.widgets import DataTable
from textual.widgets._data_table import CellType # noqa
from textual.widgets._data_table import RowDoesNotExist # noqa
Expand Down Expand Up @@ -54,7 +56,6 @@ def __init__(self, logger: Optional[Logger] = None, **kwargs) -> None:
self._relays = {}
super().__init__(logger, **kwargs)


def compose(self) -> ComposeResult:
with Vertical():
yield MqttState(id="mqtt_state")
Expand Down Expand Up @@ -84,6 +85,10 @@ def on_mount(self) -> None:
message_table.add_columns(
"Time", "Type", "Payload",
)
self.app.theme_changed_signal.subscribe(
self,
self.handle_theme_change_signal
)

def action_energize(self) -> None:
self.query_one("#relays_control_buttons", RelayControlButtons).action_energize()
Expand Down Expand Up @@ -200,7 +205,7 @@ def _update_buttons(self, relay_name: str) -> None:
buttons.energized = relay_info.get_state()
self.refresh_bindings()

def update_table(self):
def handle_theme_change_signal(self, _signal: Signal[Theme]) -> None:
for relay_name in self._relays:
self._update_relay_row(relay_name)

Expand Down

0 comments on commit 3511dbc

Please sign in to comment.