From: sbkelley Date: Sun, 30 Nov 2025 05:55:26 +0000 (-0500) Subject: Rename and clean up TextReadout X-Git-Url: https://skyeroc.xyz/gitweb/?a=commitdiff_plain;h=c916ce5699b8e40dcfc156f13de4dab562fbaab7;p=obs-ctl Rename and clean up TextReadout --- diff --git a/src/obs_ctl/__init__.py b/src/obs_ctl/__init__.py index c409d33..6ffced8 100644 --- a/src/obs_ctl/__init__.py +++ b/src/obs_ctl/__init__.py @@ -11,7 +11,7 @@ from textual.widgets import Footer, Header, Label, Placeholder, TabbedContent, T from textual.css.query import NoMatches from . import log, data -from .widget import LabeledLabel, OBSSettingsPane +from .widget import TextReadout, OBSSettingsPane from .widget.element.bool_control import BoolControl @@ -82,14 +82,14 @@ class OBSCtlApp(App): yield Placeholder("CLIENT SETTINGS BLOCK", id="client-plc") with Horizontal(id="blocks_h_container2", classes="blocks_h_containers"): with Grid(id="machine_container", classes="blocks gridblocks"): - yield LabeledLabel("CPU Usage", "-.-%", id="cpu_usage", classes="stats") - yield LabeledLabel("RAM Usage", "-b", id="memory_usage", classes="stats") - yield LabeledLabel("Time 'til Full", "N/A", id="disk_full", classes="stats") + yield TextReadout("CPU Usage", "-.-%", id="cpu_usage", classes="stats") + yield TextReadout("RAM Usage", "-b", id="memory_usage", classes="stats") + yield TextReadout("Time 'til Full", "N/A", id="disk_full", classes="stats") with Grid(id="obs_container", classes="blocks gridblocks"): - yield LabeledLabel("FPS", "--.--", id="fps", classes="stats") - yield LabeledLabel("Netwrk frames dropped", "-/- (-.-%)", id="stream_dropped_frames", classes="stats") - yield LabeledLabel("Render frames dropped", "-/- (-.-%)", id="rendering_lag", classes="stats") - yield LabeledLabel("Encdng frames dropped", "-/- (-.-%)", id="encoding_lag", classes="stats") + yield TextReadout("FPS", "--.--", id="fps", classes="stats") + yield TextReadout("Netwrk frames dropped", "-/- (-.-%)", id="stream_dropped_frames", classes="stats") + yield TextReadout("Render frames dropped", "-/- (-.-%)", id="rendering_lag", classes="stats") + yield TextReadout("Encdng frames dropped", "-/- (-.-%)", id="encoding_lag", classes="stats") @on(BoolControl.SetFalse, "#stream_control") @@ -210,13 +210,13 @@ class OBSCtlApp(App): stream_ctl: BoolControl = self.query_exactly_one("#stream_control") record_ctl: BoolControl = self.query_exactly_one("#record_control") pause_ctl: BoolControl = self.query_exactly_one("#pause_control") - cpu_usage: LabeledLabel = self.query_exactly_one("#cpu_usage") - memory_usage: LabeledLabel = self.query_exactly_one("#memory_usage") - active_fp: LabeledLabel = self.query_exactly_one("#fps") - disk_full: LabeledLabel = self.query_exactly_one("#disk_full") - stream_dropped_frames: LabeledLabel = self.query_exactly_one("#stream_dropped_frames") - rendering_lag: LabeledLabel = self.query_exactly_one("#rendering_lag") - encoding_lag: LabeledLabel = self.query_exactly_one("#encoding_lag") + cpu_usage: TextReadout = self.query_exactly_one("#cpu_usage") + memory_usage: TextReadout = self.query_exactly_one("#memory_usage") + active_fp: TextReadout = self.query_exactly_one("#fps") + disk_full: TextReadout = self.query_exactly_one("#disk_full") + stream_dropped_frames: TextReadout = self.query_exactly_one("#stream_dropped_frames") + rendering_lag: TextReadout = self.query_exactly_one("#rendering_lag") + encoding_lag: TextReadout = self.query_exactly_one("#encoding_lag") obs_settings: OBSSettingsPane = self.query_exactly_one("#settings-content") stream_ctl.status = obs_stats.stream_output_active diff --git a/src/obs_ctl/data/layout.tcss b/src/obs_ctl/data/layout.tcss index b2d87d9..ef7d44e 100644 --- a/src/obs_ctl/data/layout.tcss +++ b/src/obs_ctl/data/layout.tcss @@ -42,15 +42,15 @@ BoolControl { align:center top; } -LabeledLabel { +TextReadout { width:1fr; border:solid $primary; background:$surface; - .labeledlabel--constant { + .text_readout--label { height:1; align:center middle; } - .labeledlabel--variable { + .text_readout--text { align:center middle; } } \ No newline at end of file diff --git a/src/obs_ctl/widget/__init__.py b/src/obs_ctl/widget/__init__.py index cf90886..4d20454 100644 --- a/src/obs_ctl/widget/__init__.py +++ b/src/obs_ctl/widget/__init__.py @@ -53,27 +53,35 @@ class OBSSettingsPane(VerticalScroll): input.value = value -class LabeledLabel(Container): +class TextReadout(Container): COMPONENT_CLASSES = { - "labeledlabel--constant", - "labeledlabel--variable", + "text_readout--label", + "text_readout--text", } - text = reactive("") - def __init__(self, label_one, label_two, *children, layout = "vertical", name = None, id = None, classes = None, disabled = False, markup = True): + text = reactive("Text") + label = reactive("Label") + readout_layout = reactive("vertical") + + def __init__(self, label, text, *children, layout = "vertical", name = None, id = None, classes = None, disabled = False, markup = True): super().__init__(*children, name=name, id=id, classes=classes, disabled=disabled, markup=markup) - self._label_one_param = label_one - self._label_two_param = label_two - self.set_styles(layout=layout) - - # def _on_mount(self): - # self.query_exactly_one("#constant").styles = self.get_component_styles("labeledlabel--constant") - # self.query_exactly_one("#variable").styles = self.get_component_styles("labeledlabel--variable") + self.set_reactive(TextReadout.label, label) + self.set_reactive(TextReadout.text, text) + self.set_reactive(TextReadout.readout_layout, layout) + def compose(self): - yield Container(Label(self._label_one_param, id="constant"), classes="labeledlabel--constant") - yield Container(Label(self._label_two_param, id="variable"), classes="labeledlabel--variable") + yield Container(Label(self.label, id="label"), classes="text_readout--label") + yield Container(Label(self.text, id="text"), classes="text_readout--text") + def watch_text(self, value: str): + text: Label = self.query_exactly_one("#text") + text.update(value) + + + def watch_label(self, value): + label: Label = self.query_exactly_one("#label") + label.update(value) + - def watch_text(self, text: str): - label: Label = self.query_exactly_one("#variable") - label.update(text) \ No newline at end of file + def watch_readout_layout(self, value): + self.set_styles(layout=value) \ No newline at end of file