]> skyeroc.xyz Git - obs-ctl/commitdiff
Reorganize SettingsBlock etc
authorsbkelley <sb24kelley@gmail.com>
Wed, 3 Dec 2025 01:37:09 +0000 (20:37 -0500)
committersbkelley <sb24kelley@gmail.com>
Wed, 3 Dec 2025 01:37:09 +0000 (20:37 -0500)
12 files changed:
src/obs_ctl/app.py
src/obs_ctl/interface/__init__.py
src/obs_ctl/interface/element/bool_control.py
src/obs_ctl/interface/message.py
src/obs_ctl/interface/molecule/__init__.py
src/obs_ctl/interface/molecule/record_controls.py
src/obs_ctl/interface/molecule/settings_block/__init__.py [new file with mode: 0644]
src/obs_ctl/interface/molecule/settings_block/pane/__init__.py [new file with mode: 0644]
src/obs_ctl/interface/molecule/settings_block/pane/obs_settings.py [new file with mode: 0644]
src/obs_ctl/interface/molecule/settings_block/settings_block.py [new file with mode: 0644]
src/obs_ctl/interface/molecule/settings_pane.py [deleted file]
src/obs_ctl/interface/obs/obs.py

index b86a80d91efb6341575c9a377d1129b539dc4115..778898230903a29c99892db0f60805f3888c5020 100644 (file)
@@ -1,14 +1,16 @@
 import importlib.resources
+from logging import getLogger
 
 from textual import on
 from textual.app import App
-from textual.containers import Vertical, Horizontal, ScrollableContainer
-from textual.widgets import Footer, Header, Placeholder, TabbedContent, TabPane
+from textual.containers import Horizontal, ScrollableContainer
+from textual.widgets import Footer, Header
 
-from . import log, data
-from .interface import RecordControls, StatsDisplay, OBSSettingsPane, obs
+# need to import log to initalize logging
+from . import data, log
+from .interface import RecordControls, StatsDisplay, SettingsBlock, obs, settings_block
 
-logger = log.getLogger(__name__)
+logger = getLogger(__name__)
 
 
 class OBSCtlApp(App):
@@ -22,13 +24,7 @@ class OBSCtlApp(App):
         with ScrollableContainer(id="content_container"):
             with Horizontal(id="blocks_h_container1", classes="blocks_h_containers"):
                 yield RecordControls(id="record_controls")
-                with TabbedContent(id="settings_container", classes="blocks"):
-                    with TabPane("OBS Settings", id="settings-tab"):
-                        yield OBSSettingsPane(id="settings-content")
-                    with TabPane("OBS Connection", id="connection-tab"):
-                        yield Placeholder("CONNECTION BLOCK", id="conection-plc")
-                    with TabPane("obs-ctl Settings", id="clients-tab"):
-                        yield Placeholder("CLIENT SETTINGS BLOCK", id="client-plc")
+                yield SettingsBlock(id="settings_container")
             yield StatsDisplay(id="stats_display")
 
 
@@ -82,15 +78,15 @@ class OBSCtlApp(App):
         getattr(api, query)(*args, **kwargs)
 
 
-    @on(OBSSettingsPane.RecordPathChanged, "#settings-content")
-    def on_settings_record_path_changed(self, message: OBSSettingsPane.RecordPathChanged):
+    @on(settings_block.pane.OBSSettings.RecordPathChanged, "#settings-content")
+    def on_settings_record_path_changed(self, message: settings_block.pane.OBSSettings.RecordPathChanged):
         api: obs.API = self.query_exactly_one("#api")
         api.set_record_path(message.record_path)
 
 
     def update_monitors(self, obs_stats: obs.OBSStats):
         record_controls: RecordControls = self.query_exactly_one("#record_controls")
-        obs_settings: OBSSettingsPane = self.query_exactly_one("#settings-content")
+        obs_settings: settings_block.pane.OBSSettings.RecordPathChanged = self.query_exactly_one("#settings-content")
         stats_display: StatsDisplay = self.query_exactly_one("#stats_display")
 
         record_controls.obsws_connected = obs_stats.obsws_connection_active
index 71bdecc9b96c079d7bba6a137d9d978240546dfb..fb735f21ec057a2c8bc70823fc02122f46066a7b 100644 (file)
@@ -1,3 +1,4 @@
 """Provides RecordControls, OBSSettingsPane, StatsDisplay, and the obs module"""
-from .molecule import RecordControls, OBSSettingsPane, StatsDisplay
+from .molecule import RecordControls, SettingsBlock, StatsDisplay
+from .molecule import settings_block
 from . import obs
\ No newline at end of file
index e7084e2aa79589114a5ce684f863214b29968a42..776bd70b98c79fcd41ad619ae24ff0d29083691c 100644 (file)
@@ -6,7 +6,7 @@ from textual.reactive import reactive
 from textual.widgets import Button, RadioButton
 
 from ..message import MSGBase
-from ...log import getLogger
+from logging import getLogger
 
 logger = getLogger(__name__)
 
index 583094d6fe7cfbdd681ee487d6f8d23ec9ac06f4..e99cb643e6d902e9546c6af9b1f9213f5a7bc530 100644 (file)
@@ -1,7 +1,7 @@
 from textual.message import Message
 from textual.widget import Widget
 
-from ..log import getLogger
+from logging import getLogger
 
 logger = getLogger(__name__)
 
index f9c5df89b5711890c1b1804982a7b71ef15dea17..a880ff201eb3934bc4213ee3bfb2217ad217933c 100644 (file)
@@ -3,5 +3,6 @@
 Uses obs_ctl.interface.element
 """
 from .record_controls import RecordControls
-from .settings_pane import OBSSettingsPane
-from .stats_display import StatsDisplay
\ No newline at end of file
+from .settings_block import SettingsBlock
+from .stats_display import StatsDisplay
+from .settings_block import pane
\ No newline at end of file
index 9b1c4e2b44e8f3b027e5ed2037839f056382bb6e..ccea563787f2b7bf67c62beb3ceb331ef3fca38f 100644 (file)
@@ -3,7 +3,7 @@ from textual.reactive import reactive
 
 from ..message import MSGBase
 from ..element import BoolControl
-from ...log import getLogger
+from logging import getLogger
 
 logger=getLogger(__name__)
 class RecordControls(ScrollableContainer):
diff --git a/src/obs_ctl/interface/molecule/settings_block/__init__.py b/src/obs_ctl/interface/molecule/settings_block/__init__.py
new file mode 100644 (file)
index 0000000..fc1939d
--- /dev/null
@@ -0,0 +1 @@
+from .settings_block import SettingsBlock
\ No newline at end of file
diff --git a/src/obs_ctl/interface/molecule/settings_block/pane/__init__.py b/src/obs_ctl/interface/molecule/settings_block/pane/__init__.py
new file mode 100644 (file)
index 0000000..df9cf12
--- /dev/null
@@ -0,0 +1 @@
+from .obs_settings import OBSSettings
\ No newline at end of file
diff --git a/src/obs_ctl/interface/molecule/settings_block/pane/obs_settings.py b/src/obs_ctl/interface/molecule/settings_block/pane/obs_settings.py
new file mode 100644 (file)
index 0000000..da897b9
--- /dev/null
@@ -0,0 +1,57 @@
+from textual.containers import VerticalScroll, Grid
+from textual.message import Message
+from textual.reactive import reactive
+from textual.widgets import Label, Input, TabPane
+
+from logging import getLogger
+
+logger = getLogger(__name__)
+
+class OBSSettings(TabPane):
+    DEFAULT_CSS = """
+    .obssettingspane--input {
+        width:1fr;
+    }
+    Grid {
+        grid-size:2 1;
+        grid-columns:21 1fr;
+        Label {
+            width:1fr;
+            text-align:right;
+            padding-right:1;
+        }
+    }
+    """
+    COMPONENT_CLASSES = {
+        "obssettingspane--input",
+    }
+    record_path: reactive[str] = reactive("")
+
+    class RecordPathChanged(Message):
+        control: "OBSSettings" = None
+        record_path: str = None
+        def __init__(self, ctrl, path):
+            super().__init__()
+            self.control = ctrl
+            self.record_path = path
+
+
+    def __init__(self, *args, **kwargs):
+        super().__init__("OBS Settings", *args, **kwargs)
+
+
+    def compose(self):
+        with VerticalScroll():
+            with Grid():
+                yield Label("Record path:")
+                yield Input("path", id="input_record_path", classes="obssettingspane--input", compact=True)
+
+
+    def on_input_submitted(self, event:Input.Submitted):
+        self.set_reactive(OBSSettings.record_path, event.value)
+        if event.control.id == "input_record_path":
+            self.post_message(OBSSettings.RecordPathChanged(self, event.value))
+    
+    def watch_record_path(self, value):
+        input: Input = self.query_exactly_one("#input_record_path")
+        input.value = value
diff --git a/src/obs_ctl/interface/molecule/settings_block/settings_block.py b/src/obs_ctl/interface/molecule/settings_block/settings_block.py
new file mode 100644 (file)
index 0000000..581405e
--- /dev/null
@@ -0,0 +1,15 @@
+from textual.widgets import TabbedContent, TabPane, Placeholder
+from textual.containers import Container
+
+from . import pane
+
+
+class SettingsBlock(Container):
+
+    def compose(self):
+        with TabbedContent(classes="settings_block--tabbed-content"):
+            yield pane.OBSSettings(id="settings-content", classes="settings_block--obs_settings")
+            with TabPane("OBS Connection", id="connection-tab"):
+                yield Placeholder("CONNECTION BLOCK", id="conection-plc")
+            with TabPane("obs-ctl Settings", id="clients-tab"):
+                yield Placeholder("CLIENT SETTINGS BLOCK", id="client-plc")
\ No newline at end of file
diff --git a/src/obs_ctl/interface/molecule/settings_pane.py b/src/obs_ctl/interface/molecule/settings_pane.py
deleted file mode 100644 (file)
index ea9c2b2..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-from textual.containers import VerticalScroll, Grid
-from textual.message import Message
-from textual.reactive import reactive
-from textual.widgets import Label, Input
-
-from ... import log
-
-logger = log.getLogger(__name__)
-
-class OBSSettingsPane(VerticalScroll):
-    DEFAULT_CSS = """
-    .obssettingspane--input {
-        width:1fr;
-    }
-    Grid {
-        grid-size:2 1;
-        grid-columns:21 1fr;
-        Label {
-            width:1fr;
-            text-align:right;
-            padding-right:1;
-        }
-    }
-    """
-    COMPONENT_CLASSES = {
-        "obssettingspane--input",
-    }
-    record_path: reactive[str] = reactive("")
-
-    class RecordPathChanged(Message):
-        control: "OBSSettingsPane" = None
-        record_path: str = None
-        def __init__(self, ctrl, path):
-            super().__init__()
-            self.control = ctrl
-            self.record_path = path
-
-    def compose(self):
-        with Grid():
-            yield Label("Record path:")
-            yield Input("path", id="input_record_path", classes="obssettingspane--input", compact=True)
-    
-    def on_input_submitted(self, event:Input.Submitted):
-        self.set_reactive(OBSSettingsPane.record_path, event.value)
-        if event.control.id == "input_record_path":
-            self.post_message(OBSSettingsPane.RecordPathChanged(self, event.value))
-    
-    def watch_record_path(self, value):
-        input: Input = self.query_exactly_one("#input_record_path")
-        input.value = value
index 92b30bc4c762220d54c6eb065a25add047b3429d..2ae4e248bf8c98eb277e3521f96693fe992572bf 100644 (file)
@@ -12,7 +12,7 @@ from textual.timer import Timer
 from textual.reactive import reactive
 from textual.widgets import Static
 
-from ...log import getLogger
+from logging import getLogger
 from ..message import MSGBase
 
 MS_TO_HOURS = 1 / 1000 / 60 / 60