Skip to content

Commit

Permalink
Merge pull request #1526 from SpiNNakerManchester/push_bot_viewer
Browse files Browse the repository at this point in the history
Actually detect window closure
  • Loading branch information
rowleya authored Jan 20, 2025
2 parents 15d2a77 + e182b29 commit 2717a40
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ def __run(self, run_thread):
except Exception: # pylint: disable=broad-except
_logger.exception("unexpected exception in drawing thread")

def __on_close(self, event):
self.__running = False

def run_until_closed(self):
"""
Run the viewer and simulation until the viewer is closed.
"""
run_thread = Thread(target=self.__run_sim_forever)
run_thread.start()
try:
self.__fig.canvas.mpl_connect('close_event', self.__on_close)
self.__run(run_thread)
finally:
self.__sim.external_devices.request_stop()
Expand Down

0 comments on commit 2717a40

Please sign in to comment.