diff --git a/qt/python/mantidqt/widgets/codeeditor/interpreter.py b/qt/python/mantidqt/widgets/codeeditor/interpreter.py index 3fe50625a1277e969409c494be1542139462a174..ea847acedb588327c53a24d8f34e959d4b9b5344 100644 --- a/qt/python/mantidqt/widgets/codeeditor/interpreter.py +++ b/qt/python/mantidqt/widgets/codeeditor/interpreter.py @@ -70,6 +70,7 @@ class PythonFileInterpreterPresenter(QObject): # connect signals self.model.sig_exec_success.connect(self.on_exec_success) self.model.sig_exec_error.connect(self.on_exec_error) + self.model.sig_exec_progress.connect(self.view.editor.updateProgressMarker) # starts idle self.view.set_status_message(IDLE_STATUS_MSG) @@ -83,7 +84,14 @@ class PythonFileInterpreterPresenter(QObject): return self.model.execute_async(text) def on_exec_success(self): + self.view.set_editor_readonly(False) self.view.set_status_message(IDLE_STATUS_MSG) - def on_exec_error(self): + def on_exec_error(self, task_error): + if isinstance(task_error.exception, SyntaxError): + lineno = task_error.exception.lineno + else: + lineno = task_error.stack_entries[-1][1] + self.view.editor.updateProgressMarker(lineno, True) + self.view.set_editor_readonly(False) self.view.set_status_message(IDLE_STATUS_MSG) diff --git a/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py b/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py index 89c201db9a3c375412379e11ed4e04c90d425aa2..c72f5f9d2203f8f3f3c6402f0457cc749dcfc937 100644 --- a/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py +++ b/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py @@ -30,10 +30,10 @@ class MultiPythonFileInterpreter(QWidget): super(MultiPythonFileInterpreter, self).__init__(parent) # layout - self.editors = QTabWidget(self) - self.editors.setMovable(True) + self._editors = QTabWidget(self) + self._editors.setMovable(True) layout = QVBoxLayout() - layout.addWidget(self.editors) + layout.addWidget(self._editors) self.setLayout(layout) layout.setContentsMargins(0, 0, 0, 0) @@ -42,8 +42,16 @@ class MultiPythonFileInterpreter(QWidget): @property def editor_count(self): - return self.editors.count() + return self._editors.count() + + def current_editor(self): + return self._editors.currentWidget() + + def execute_current(self): + self.current_editor().execute_all_async() def append_new_editor(self): title = "New" - self.editors.addTab(PythonFileInterpreter(self.editors), title) + self._editors.addTab(PythonFileInterpreter(self._editors), + title) + diff --git a/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter.py b/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter.py index 9b04709cb15e2479390bc13ee923509bfc6a173c..2122b51f23169e5cdd40d11ce8fe7bc9426ba3e6 100644 --- a/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter.py +++ b/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter.py @@ -29,11 +29,15 @@ from mantidqt.widgets.codeeditor.multifileinterpreter import MultiPythonFileInte @requires_qapp class MultiPythonFileInterpreterTest(unittest.TestCase): - # Success tests + def test_default_contains_single_editor(self): + widget = MultiPythonFileInterpreter() + self.assertEqual(1, widget.editor_count) - def test_default_contains_single_tab(self): + def test_add_editor(self): widget = MultiPythonFileInterpreter() self.assertEqual(1, widget.editor_count) + widget.append_new_editor() + self.assertEqual(2, widget.editor_count) if __name__ == '__main__': diff --git a/qt/python/mantidqt/widgets/src/_widgetscore.sip b/qt/python/mantidqt/widgets/src/_widgetscore.sip index e80ecdd80b28f84cc42773ead0a7d2b5cf939a8a..3f426f9f8d2ba7db3e9982e7e9355f03a17c80bb 100644 --- a/qt/python/mantidqt/widgets/src/_widgetscore.sip +++ b/qt/python/mantidqt/widgets/src/_widgetscore.sip @@ -72,6 +72,9 @@ public: void setReadOnly(bool ro); void setText(const QString &text); +public slots: + void updateProgressMarker(int lineno, bool error); + private: ScriptEditor(const ScriptEditor&); }; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptEditor.h b/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptEditor.h index 813837022581632894cc9c8225376ba3542353cd..72fda92641d2a64e4b8f69ec0425c0e40a6c755f 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptEditor.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptEditor.h @@ -127,7 +127,7 @@ public slots: /// Set the marker state void setMarkerState(bool enabled); /// Update the progress marker - void updateProgressMarker(int lineno, bool error); + void updateProgressMarker(int lineno, bool error=false); /// Mark the progress arrow as an error void markExecutingLineAsError(); /// Refresh the autocomplete information base on a new set of keywords