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