This commit is contained in:
Vincent Hanewinkel 2025-08-14 21:52:21 +02:00
parent 2f5a6a682e
commit a7d2fb0824

View File

@ -12,24 +12,6 @@ class ControllerSignals(QObject):
signals = ControllerSignals()
def make_on_start(ctrl, widget):
def _start(checked=False):
try:
ctrl.start() # startet Worker-Threads, blockiert nicht
widget.set_running(True)
except Exception as e:
print(f"Fehler beim Start {ctrl.dev.serial}: {e}")
return _start
def make_on_stop(ctrl, widget):
def _stop(checked=False):
try:
ctrl.stop()
widget.set_running(False)
except Exception as e:
print(f"Fehler beim Stop {ctrl.dev.serial}: {e}")
return _stop
def main():
# 1) Geräte einsammeln (pysmu nur hier benutzen)
sess = pysmu.Session()
@ -50,11 +32,23 @@ def main():
win = MainWindow()
# Kleine Helfer, damit die ListItem-Buttons nur Controller.start/stop aufrufen
def make_on_start(ctrl):
return lambda _idx: ctrl.start()
def make_on_start(ctrl, widget):
def _start(checked=False):
try:
ctrl.start() # startet Worker-Threads, blockiert nicht
widget.set_running(True)
except Exception as e:
print(f"Fehler beim Start {ctrl.dev.serial}: {e}")
return _start
def make_on_stop(ctrl):
return lambda _idx: ctrl.stop()
def make_on_stop(ctrl, widget):
def _stop(checked=False):
try:
ctrl.stop()
widget.set_running(False)
except Exception as e:
print(f"Fehler beim Stop {ctrl.dev.serial}: {e}")
return _stop
# 3) Liste befüllen (auf der INSTANZ, nicht auf der Klasse!)
for i, serial in enumerate(serials):
@ -63,8 +57,8 @@ def main():
widget = win.add_list_item(
text=serial,
index=i,
on_start=make_on_start(ctrl, placeholder), # placeholder siehe unten
on_stop=make_on_stop(ctrl, placeholder),
on_start = make_on_start(ctrl, placeholder), # placeholder siehe unten
on_stop = make_on_stop(ctrl, placeholder),
)
widget.btn_start.clicked.disconnect()