try fix
This commit is contained in:
parent
fdff4bf9ef
commit
2f5a6a682e
27
Controll.py
27
Controll.py
@ -13,22 +13,21 @@ class ControllerSignals(QObject):
|
||||
signals = ControllerSignals()
|
||||
|
||||
def make_on_start(ctrl, widget):
|
||||
def _start(_widget=widget, _ctrl=ctrl):
|
||||
# NICHT blockieren: nur anstoßen
|
||||
def _start(checked=False):
|
||||
try:
|
||||
_ctrl.start() # -> startet seine eigenen Threads
|
||||
_widget.set_running(True)
|
||||
ctrl.start() # startet Worker-Threads, blockiert nicht
|
||||
widget.set_running(True)
|
||||
except Exception as e:
|
||||
signals.error.emit(_ctrl.dev.serial, str(e))
|
||||
print(f"Fehler beim Start {ctrl.dev.serial}: {e}")
|
||||
return _start
|
||||
|
||||
def make_on_stop(ctrl, widget):
|
||||
def _stop(_widget=widget, _ctrl=ctrl):
|
||||
def _stop(checked=False):
|
||||
try:
|
||||
_ctrl.stop()
|
||||
_widget.set_running(False)
|
||||
ctrl.stop()
|
||||
widget.set_running(False)
|
||||
except Exception as e:
|
||||
signals.error.emit(_ctrl.dev.serial, str(e))
|
||||
print(f"Fehler beim Stop {ctrl.dev.serial}: {e}")
|
||||
return _stop
|
||||
|
||||
def main():
|
||||
@ -60,13 +59,19 @@ def main():
|
||||
# 3) Liste befüllen (auf der INSTANZ, nicht auf der Klasse!)
|
||||
for i, serial in enumerate(serials):
|
||||
ctrl = controllers[serial]
|
||||
placeholder = lambda checked=False: None
|
||||
widget = win.add_list_item(
|
||||
text=serial,
|
||||
index=i,
|
||||
on_start=lambda w, c=ctrl: make_on_start(c, w)(),
|
||||
on_stop =lambda w, c=ctrl: make_on_stop(c, w)()
|
||||
on_start=make_on_start(ctrl, placeholder), # placeholder siehe unten
|
||||
on_stop=make_on_stop(ctrl, placeholder),
|
||||
)
|
||||
|
||||
widget.btn_start.clicked.disconnect()
|
||||
widget.btn_stop.clicked.disconnect()
|
||||
widget.btn_start.clicked.connect(make_on_start(ctrl, widget))
|
||||
widget.btn_stop.clicked.connect(make_on_stop(ctrl, widget))
|
||||
|
||||
# 4) Start
|
||||
win.show()
|
||||
sys.exit(app.exec_())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user