RefactoringRope/ErrorDialog.py

Mon, 02 Apr 2018 17:43:09 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 02 Apr 2018 17:43:09 +0200
changeset 251
4dcc73076100
child 302
2e853e2f2430
permissions
-rw-r--r--

Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.

251
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de>
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to show an error message and optionally a
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 traceback.
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from __future__ import unicode_literals
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt5.QtWidgets import QDialog
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .Ui_ErrorDialog import Ui_ErrorDialog
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class ErrorDialog(QDialog, Ui_ErrorDialog):
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a dialog to show an error message and optionally a
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 traceback.
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 def __init__(self, title, errorMessage, traceback=None, parent=None):
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Constructor
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param title title of the dialog
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @type str
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param errorMessage error message to be shown
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @type str
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param traceback list of traceback entries
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @type list of str
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param parent reference to the parent widget
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @type QWidget
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 super(ErrorDialog, self).__init__(parent)
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setupUi(self)
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.tracebackEdit.hide()
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.setWindowTitle(title)
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.errorMessageLabel.setText(errorMessage)
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 if traceback:
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 tbIntro = self.tr("Traceback (most recent call first):\n\n")
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.tracebackEdit.setPlainText(
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 tbIntro + "\n".join(reversed(traceback)))
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 else:
4dcc73076100 Removed the Python3 only rope variant and introduced an extended error dialog showing a traceback for errors within the rope library.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.tracebackEdit.setEnabled(False)

eric ide

mercurial