timeout_setting = obs_websocket_pane.timeout
self._query_api("connect", host=host_setting, port=port_setting, password=password_setting, timeout=timeout_setting)
if api.is_connected:
- obs_websocket_pane.disabled = True
+ obs_websocket_pane.disable_contents()
@on(RecordControls.OBSWSDisconnected, "#record_controls")
obs_websocket_pane = self.query_exactly_one("#obs_websocket_pane")
self._query_api("disconnect")
if not api.is_connected:
- obs_websocket_pane.disabled = False
+ obs_websocket_pane.enable_contents()
def _query_api(self, query: str, *args, **kwargs):
super().__init__(control, _log_me=_log_me)
self.value = value
+class PaneBase(TabPane):
+ def disable_contents(self):
+ container: ScrollableContainer = self.query_exactly_one(".--container")
+ container.disabled = True
+
+ def enable_contents(self):
+ container: ScrollableContainer = self.query_exactly_one(".--container")
+ container.disabled = False
+
class SettingsType(Enum):
"""(widget_class, setting type, listener message, widget-expected type)"""
STRING = (partial(Input, compact=True), str, Input.Submitted, str)
return self.value[3]
-def make_pane_subclass(cls_name: str, settings_list: list, settings_type_list: list, defaults_list) -> TabPane:
+def make_pane_subclass(cls_name: str, settings_list: list, settings_type_list: list, defaults_list) -> PaneBase:
"""Creates a new TabPane subclass with cls_name as its name.
settings_list should be a list of names for settings.
def make_compose():
def output_func(self):
- with ScrollableContainer():
+ with ScrollableContainer(classes="--container"):
with Grid():
for setting, control_and_type, setting_default in loop_list:
ctrl_id = f"{setting_type.widget.func.__name__.lower()}_{setting}"
new_dict["compose"] = make_compose()
# Construct the actual class and return it
- new_pane = type(cls_name, (TabPane,), new_dict)
+ new_pane = type(cls_name, (PaneBase,), new_dict)
return new_pane
def snake_to_camel(string: str):
port = self.ws_port if port is None else port
password = self.ws_password if password is None else password
timeout = self.ws_timeout if timeout is None else timeout
+ self.ws_host = host
+ self.ws_port = port
+ self.ws_password = password
+ self.ws_timeout = timeout
try:
logger.info(f"Connecting to OBS WebSocket at {host}:{port}")
self.request_client = obs.ReqClient(
password=password,
timeout=timeout
)
- except ConnectionRefusedError as err:
+ except (ConnectionRefusedError, TimeoutError) as err:
logger.debug(err)
else:
self.is_connected = True