Skip to content
Snippets Groups Projects
Commit 394c3767 authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Add FilterEvents to interfaces menu

parent 2af9f74e
No related branches found
No related tags found
No related merge requests found
......@@ -250,13 +250,8 @@ class MainWindow(QMainWindow):
add_actions(self.file_menu, self.file_menu_actions)
add_actions(self.view_menu, self.view_menu_actions)
def launchCustomGUI(self, name):
try:
importlib.import_module(name)
except ImportError:
from mantid.kernel import logger
logger.error(str('Failed to load {} interface'.format(name))) # TODO logger should accept unicode
raise
def launchCustomGUI(self, script):
execfile(script)
def populateAfterMantidImport(self):
from mantid.kernel import ConfigService, logger
......@@ -266,16 +261,18 @@ class MainWindow(QMainWindow):
# list of custom interfaces that have been made qt4/qt5 compatible
# TODO need to make *anything* compatible
GUI_WHITELIST = []
GUI_WHITELIST = ['FilterEvents.py']
# detect the python interfaces
interfaces = {}
for item in items:
key,scriptname = item.split('/')
key, scriptname = item.split('/')
# TODO logger should accept unicode
if not os.path.exists(os.path.join(interface_dir, scriptname)):
logger.warning('Failed to find script "{}" in "{}"'.format(scriptname, interface_dir))
logger.warning(str('Failed to find script "{}" in "{}"'.format(scriptname, interface_dir)))
continue
if scriptname not in GUI_WHITELIST:
logger.information(str('Not adding gui "{}"'.format(scriptname)))
continue
temp = interfaces.get(key, [])
temp.append(scriptname)
......@@ -290,8 +287,8 @@ class MainWindow(QMainWindow):
names.sort()
for name in names:
action = submenu.addAction(name.replace('.py', '').replace('_', ' '))
script = name.replace('.py', '')
action.triggered.connect(lambda checked, script=script:self.launchCustomGUI(script))
script = os.path.join(interface_dir, name)
action.triggered.connect(lambda checked, script=script: self.launchCustomGUI(script))
def add_dockwidget(self, plugin):
"""Create a dockwidget around a plugin and add the dock to window"""
......@@ -380,6 +377,10 @@ class MainWindow(QMainWindow):
import matplotlib.pyplot as plt # noqa
plt.close('all')
app = QApplication.instance()
if app is not None:
app.closeAllWindows()
event.accept()
else:
# Cancel was pressed when closing an editor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment