Refactor a bit to update lines only via poll

Model-View-Controller thing, don't edit UI when UI value changed
zotino-tec
atse 2023-08-29 11:12:04 +08:00
parent 6014dce158
commit 744a472566
1 changed files with 2 additions and 11 deletions

View File

@ -625,17 +625,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
for inner_param, change, data in changes:
if change == 'value':
if inner_param.opts.get("commands", None) is not None:
ch = param.value()
match inner_param.name():
case 'Control Method':
pid_enabled = data
getattr(self, f'ch{ch}_t_line').setVisible(pid_enabled)
if pid_enabled:
getattr(self, f'ch{ch}_t_line').setValue(inner_param.child('Set Temperature').value())
else:
return
case 'Set Temperature':
getattr(self, f'ch{ch}_t_line').setValue(data)
if inner_param.name() == 'Control Method' and not data:
return
await asyncio.gather(*[self.client._command(x.format(value=data)) for x in inner_param.opts["commands"]])
elif inner_param.opts.get("param", None) is not None:
await asyncio.gather(*[self.client.set_param(*x, data) for x in inner_param.opts["param"]])