From 99e180f49c01d14e92426c3d897af6fe1928339a Mon Sep 17 00:00:00 2001 From: sbkelley Date: Sun, 7 Dec 2025 14:37:20 -0500 Subject: [PATCH] add "warning" property to BoolControl --- src/obs_ctl/interface/element/bool_control.py | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/obs_ctl/interface/element/bool_control.py b/src/obs_ctl/interface/element/bool_control.py index d65b3b5..b3e5b56 100644 --- a/src/obs_ctl/interface/element/bool_control.py +++ b/src/obs_ctl/interface/element/bool_control.py @@ -40,11 +40,20 @@ class BoolControl(containers.Container): bool_control--buttonbox (Center) """ DEFAULT_CSS = """ - RadioButton { - min-width:16 !important; - text-align:center !important; + .bool_control--light{ + min-width:16; + text-align: center; + } + .-warning { + # background:$warning; + .bool_control--light{ + .toggle--button { + color:$text-warning; + } + } } """ + COMPONENT_CLASSES = { "bool_control--light", "bool_control--true_button", @@ -53,6 +62,8 @@ class BoolControl(containers.Container): "bool_control--light_box", "bool_control--buttons_box", } + warning: reactive[bool] = reactive(False) + """Updates color from whatever it is to yellow""" value: reactive[bool] = reactive(False) """Updates the control's value; turns on or off the light.""" label: reactive[str] = reactive("Status") @@ -148,12 +159,16 @@ class BoolControl(containers.Container): @on(Button.Pressed, "#false") - def false_pressed(self, event: Button.Pressed): + def false_pressed(self, event: Button.Pressed, _debug=False): + if _debug: + self.value = False self.post_message(self.SetFalse(self)) @on(Button.Pressed, "#true") - def true_pressed(self, event: Button.Pressed): + def true_pressed(self, event: Button.Pressed, _debug=False): + if _debug: + self.value = True self.post_message(self.SetTrue(self)) @@ -191,6 +206,9 @@ class BoolControl(containers.Container): light.compact = value true.compact = value false.compact = value + + def watch_warning(self, value: bool): + self.set_class(value, "-warning") def get_true_button(self): return typing.cast(Button, self.query_exactly_one("#true")) -- 2.47.3