From 2f5a6a682eee5a8659a781ac03deb1ea815895ad Mon Sep 17 00:00:00 2001 From: Vincent Hanewinkel Date: Thu, 14 Aug 2025 21:50:16 +0200 Subject: [PATCH] try fix --- Controll.py | 27 ++++++++++++++++----------- GUI.py | 1 + 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Controll.py b/Controll.py index 9a09213..66deb57 100644 --- a/Controll.py +++ b/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,12 +59,18 @@ 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() diff --git a/GUI.py b/GUI.py index ffd5078..f7d939e 100644 --- a/GUI.py +++ b/GUI.py @@ -51,6 +51,7 @@ class MainWindow(QWidget): item.setSizeHint(widget.sizeHint()) self.list_widget.addItem(item) self.list_widget.setItemWidget(item, widget) + return widget # Die Aktionen, die beim Klick ausgeführt werden sollen def handle_start(self, index):