File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -83,15 +83,20 @@ void QgsPythonUtils::initPython(QgisInterface* interface)
83
83
runString (" import traceback" ); // for formatting stack traces
84
84
85
85
// hook that will show information and traceback in message box
86
- // TODO: maybe QgsMessageOutput / QgsMessageViewer should be used instead
87
86
runString (
88
87
" def qgis_except_hook(type, value, tb):\n "
89
88
" lst = traceback.format_exception(type, value, tb)\n "
90
- " str = 'An error has occured while executing Python code:\\ n '\n "
89
+ " str = '<font color= \" red \" > An error has occured while executing Python code:</font><br><br> '\n "
91
90
" for s in lst:\n "
92
91
" str += s\n "
93
- " QtGui.QMessageBox.warning(None, 'Python error', str)\n " );
94
-
92
+ " str = str.replace('\\ n', '<br>')\n "
93
+ " str = str.replace(' ', ' ')\n " // preserve whitespaces for nicer output
94
+ " \n "
95
+ " msg = QgsMessageOutput.createMessageOutput()\n "
96
+ " msg.setTitle('Error')\n "
97
+ " msg.setMessage(str, QgsMessageOutput.MessageHtml)\n "
98
+ " msg.showMessage()\n " );
99
+
95
100
// hook for python console so all output will be redirected
96
101
// and then shown in console
97
102
runString (
You can’t perform that action at this time.
0 commit comments