Skip to content

error_details_dialog

error_details_dialog

Classes

ErrorDetailsDialog(title, error, parent=None)

Bases: QDialog

Dialog showing the full message and traceback of an error.

Initialize ErrorDetailsDialog.

Parameters:

Name Type Description Default
title str

window title, e.g. the path of the node that failed.

required
error BaseException

error to show.

required
parent QWidget | None

parent widget.

None
Source code in src/nyx/editor/widgets/dialogs/error_details_dialog.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def __init__(
    self,
    title: str,
    error: BaseException,
    parent: QtWidgets.QWidget | None = None,
) -> None:
    """Initialize ErrorDetailsDialog.

    Args:
        title (str): window title, e.g. the path of the node that failed.
        error (BaseException): error to show.
        parent (QtWidgets.QWidget | None): parent widget.
    """
    super().__init__(parent)
    self.setWindowTitle(title)
    self.resize(760, 620)

    self.text_edit = QtWidgets.QPlainTextEdit(self)
    self.text_edit.setReadOnly(True)
    self.text_edit.setLineWrapMode(QtWidgets.QPlainTextEdit.LineWrapMode.NoWrap)
    self.text_edit.setFont(
        QtGui.QFontDatabase.systemFont(QtGui.QFontDatabase.SystemFont.FixedFont)
    )
    self.text_edit.setPlainText("".join(traceback.format_exception(error)).rstrip())

    copy_button = QtWidgets.QPushButton("Copy", self)
    copy_button.clicked.connect(
        lambda: QtWidgets.QApplication.clipboard().setText(
            self.text_edit.toPlainText()
        )
    )
    close_button = QtWidgets.QPushButton("Close", self)
    close_button.clicked.connect(self.accept)

    buttons = QtWidgets.QHBoxLayout()
    buttons.addStretch(1)
    buttons.addWidget(copy_button)
    buttons.addWidget(close_button)
    layout = QtWidgets.QVBoxLayout(self)
    layout.addWidget(self.text_edit)
    layout.addLayout(buttons)
Attributes
text_edit = QtWidgets.QPlainTextEdit(self) instance-attribute
Functions