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):
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")
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
"""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
from textual.widgets import Button, RadioButton
from ..message import MSGBase
-from ...log import getLogger
+from logging import getLogger
logger = getLogger(__name__)
from textual.message import Message
from textual.widget import Widget
-from ..log import getLogger
+from logging import getLogger
logger = getLogger(__name__)
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
from ..message import MSGBase
from ..element import BoolControl
-from ...log import getLogger
+from logging import getLogger
logger=getLogger(__name__)
class RecordControls(ScrollableContainer):
--- /dev/null
+from .settings_block import SettingsBlock
\ No newline at end of file
--- /dev/null
+from .obs_settings import OBSSettings
\ No newline at end of file
--- /dev/null
+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
--- /dev/null
+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
+++ /dev/null
-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
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