Skip to content

Commit 19f18f0

Browse files
author
wonder
committedMar 4, 2007
Report Python errors with QgsMessageOutput instead of QMessageBox.
(User can copy & paste message from it, with message box he can't) git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6761 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
 

‎src/app/qgspythonutils.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,20 @@ void QgsPythonUtils::initPython(QgisInterface* interface)
8383
runString("import traceback"); // for formatting stack traces
8484

8585
// hook that will show information and traceback in message box
86-
// TODO: maybe QgsMessageOutput / QgsMessageViewer should be used instead
8786
runString(
8887
"def qgis_except_hook(type, value, tb):\n"
8988
" 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"
9190
" for s in lst:\n"
9291
" str += s\n"
93-
" QtGui.QMessageBox.warning(None, 'Python error', str)\n");
94-
92+
" str = str.replace('\\n', '<br>')\n"
93+
" str = str.replace(' ', '&nbsp;')\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+
95100
// hook for python console so all output will be redirected
96101
// and then shown in console
97102
runString(

0 commit comments

Comments
 (0)
Please sign in to comment.