# Buggy code
def __init__(
    self, parent, title, main_text, buttons, show_input=False, checkbox_text=None
):
    DialogContainer.__init__(self, parent)

    uic.loadUi(get_ui_file_path("buttonsdialog.ui"), self.dialog_widget)

    self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)

    self.dialog_widget.dialog_title_label.setText(title)

    self.dialog_widget.dialog_main_text_label.setText(main_text)
    self.dialog_widget.dialog_main_text_label.adjustSize()
    self.checkbox = self.dialog_widget.checkbox

    if not show_input:
        self.dialog_widget.dialog_input.setHidden(True)
    else:
        connect(
            self.dialog_widget.dialog_input.returnPressed,
            lambda: self.button_clicked.emit(0),
        )

    if not checkbox_text:
        self.dialog_widget.checkbox.setHidden(True)
    else:
        self.dialog_widget.checkbox.setText(checkbox_text)

    hspacer_left = QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Fixed)
    self.dialog_widget.dialog_button_container.layout().addSpacerItem(hspacer_left)

    self.buttons = []
    for index in range(len(buttons)):
        self.create_button(index, *buttons[index])

    hspacer_right = QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Fixed)
    self.dialog_widget.dialog_button_container.layout().addSpacerItem(hspacer_right)

    connect(self.window().escape_pressed, self.close_dialog)
    self.on_main_window_resize()


# Traceback (AttributeError)
Traceback (most recent call last):,
File "run_tribler.py", line 179, in <module>,
File "tribler_gui/tribler_window.py", line 1019, in clicked_menu_button_debug,
File "tribler_gui/debug_window.py", line 79, in __init__,
tribler_gui.utilities.CreationTraceback,
The above exception was the direct cause of the following exception:,
Traceback (most recent call last):,
File "tribler_gui/utilities.py", line 385, in trackback_wrapper,
File "tribler_gui/utilities.py", line 382, in trackback_wrapper,
File "tribler_gui/debug_window.py", line 79, in <lambda>,
File "tribler_gui/debug_window.py", line 747, in on_memory_dump_button_clicked,
File "tribler_gui/dialogs/confirmationdialog.py", line 53, in show_error,
File "tribler_gui/dialogs/confirmationdialog.py", line 48, in __init__,
AttributeError: 'DebugWindow' object has no attribute 'escape_pressed'

# Fixed code
def __init__(
    self, parent, title, main_text, buttons, show_input=False, checkbox_text=None
):
    DialogContainer.__init__(self, parent)

    uic.loadUi(get_ui_file_path("buttonsdialog.ui"), self.dialog_widget)

    self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)

    self.dialog_widget.dialog_title_label.setText(title)

    self.dialog_widget.dialog_main_text_label.setText(main_text)
    self.dialog_widget.dialog_main_text_label.adjustSize()
    self.checkbox = self.dialog_widget.checkbox

    if not show_input:
        self.dialog_widget.dialog_input.setHidden(True)
    else:
        connect(
            self.dialog_widget.dialog_input.returnPressed,
            lambda: self.button_clicked.emit(0),
        )

    if not checkbox_text:
        self.dialog_widget.checkbox.setHidden(True)
    else:
        self.dialog_widget.checkbox.setText(checkbox_text)

    hspacer_left = QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Fixed)
    self.dialog_widget.dialog_button_container.layout().addSpacerItem(hspacer_left)

    self.buttons = []
    for index in range(len(buttons)):
        self.create_button(index, *buttons[index])

    hspacer_right = QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Fixed)
    self.dialog_widget.dialog_button_container.layout().addSpacerItem(hspacer_right)
    if hasattr(self.window(), "escape_pressed"):
        connect(self.window().escape_pressed, self.close_dialog)
    self.on_main_window_resize()