self.value = value
class SettingsType(Enum):
- STRING = (partial(Input, compact=True), str, Input.Submitted)
- FLOAT = (partial(Input, compact=True), float, Input.Submitted)
- INT = (partial(Input, compact=True), int, Input.Submitted)
+ """(widget_class, setting type, listener message, widget-expected type)"""
+ STRING = (partial(Input, compact=True), str, Input.Submitted, str)
+ FLOAT = (partial(Input, compact=True), float, Input.Submitted, str)
+ INT = (partial(Input, compact=True), int, Input.Submitted, str)
@property
def widget(self):
@property
def msg(self):
return self.value[2]
+
+ @property
+ def expected_type(self):
+ return self.value[3]
def pane_factory(cls_name: str, settings_list: list, settings_type_list: list, defaults_list) -> TabPane:
def watch_func_factory(watch_id: str):
def watch_func(self, value):
input = self.query_exactly_one(watch_id)
- input.value = value
+ if type(input) is Input:
+ input.value = str(value)
return watch_func
for setting, control_and_type, setting_default in zip(settings_list, settings_type_list, defaults_list):
ctrl_id = f"{settings_type.widget.func.__name__.lower()}_{setting}"
yield Label(setting)
- yield control_and_type.widget(value=setting_default, id=ctrl_id)
+ yield control_and_type.widget(value=control_and_type.expected_type(setting_default), id=ctrl_id)
return output_func
[""]
)
+OBSWebSocketPane = pane.pane_factory(
+ "OBSWebSocketPane",
+ ["host", "port", "password", "timeout"],
+ [pane.SettingsType.STRING, pane.SettingsType.INT, pane.SettingsType.STRING, pane.SettingsType.FLOAT],
+ ["localhost", 4455, "", 1.0]
+)
+
+OBSCTLPane = pane.pane_factory(
+ "OBSCTLPane",
+ ["nothing"],
+ [pane.SettingsType.STRING],
+ ["zilch"]
+)
+
class SettingsBlock(Container):
def compose(self):
with TabbedContent(classes="settings_block--tabbed-content"):
yield OBSSettingsPane("OBS Settings", id="settings-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")
+ yield OBSWebSocketPane("OBS WebSocket", id="websocket-content")
+ yield OBSCTLPane("obs-ctl Settings", id="obs-ctl-content")