Verstehst du diese Sackgasse?
Ich benutze wxPython für meine GUI. In demAppLogic
Klasse Ich habe einen Worker-Thread, der in einer Methode dieser Klasse ausgeführt wird.
Dies ist dasGUI
Klasse:
<code>class GUI: _wx_app = None _main_window = None _app_logic = None def start(self): # bla bla bla self._main_window.Show() self._app_logic.begin() self._wx_app.MainLoop() def _cancel_listener(self): """Called from MainWindow, if the user has clicked the cancel button.""" print("I'm leaving this scope.") self._app_logic.cancel() # Should cancel the task done in # a second thread. def _status_listener(self, status_text): """Called often by the worker thread.""" print("Here I am again.") if self._main_window.status.GetLabel() != status_text: self._main_window.status.SetLabel(status_text) </code>
Hier ist die Abbruchmethode von derAppLogic
Klasse, die von aufgerufen wird_cancel_listener
von oben:
<code> def cancel(self): self._shall_abort = True self._thread.join(self._some_time_out) assert self._thread.isAlive() == False </code>
Irgendwie gibt es eine Sackgasse mitjoin
undGetLabel
(und somitMainLoop
?) beteiligt, aber ich verstehe nicht wirklich, was los ist. Hat jemand mehr Einblick in das? Das wäre toll!