From 233fa09f0a8fd861cd15e67fd4365e3e472380f8 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Thu, 21 Sep 2017 11:21:38 +0100 Subject: [PATCH] Close all spawned matplotlib plots when exiting main window Re #84 --- mantidimaging/gui/main_window/mw_view.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mantidimaging/gui/main_window/mw_view.py b/mantidimaging/gui/main_window/mw_view.py index 3c65652de09..860bb950aa2 100644 --- a/mantidimaging/gui/main_window/mw_view.py +++ b/mantidimaging/gui/main_window/mw_view.py @@ -1,7 +1,8 @@ from __future__ import absolute_import, division, print_function +import matplotlib + from logging import getLogger -from PyQt5 import Qt, QtCore from PyQt5 import Qt, QtCore, QtWidgets from mantidimaging.core.algorithms import gui_compile_ui @@ -104,3 +105,12 @@ def show_error_dialog(self, msg=""): :param msg: Error message string """ QtWidgets.QMessageBox.critical(self, "Error", msg) + + def closeEvent(self, event): + """ + Close all matplotlib PyPlot windows when exiting. + + :param event: Unused + """ + getLogger(__name__).debug("Closing all PyPlot windows") + matplotlib.pyplot.close("all")