Skip to content

query

sleap.gui.dialogs.query

Generic module to ask user permission to complete an action.

Classes:

Name Description
QueryDialog

Opens QDialog to ask user permission to complete an action.

QueryDialog

Bases: QDialog

Opens QDialog to ask user permission to complete an action.

Parameters:

Name Type Description Default
title str

Text to be displayed in the header of dialog box.

required
message str

Test to be displayed in the body of dialog box.

required

Methods:

Name Description
__init__

Initialize and display QDialog.

Source code in sleap/gui/dialogs/query.py
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
class QueryDialog(QDialog):
    """Opens `QDialog` to ask user permission to complete an action.

    Args:
        title: Text to be displayed in the header of dialog box.
        message: Test to be displayed in the body of dialog box.
    """

    def __init__(self, title: str, message: str, *args, **kwargs):
        """Initialize and display `QDialog`."""
        super().__init__(*args, **kwargs)

        self.user_response = False

        self.setWindowTitle(title)

        QBtn = QDialogButtonBox.Ok | QDialogButtonBox.Cancel

        self.buttonBox = QDialogButtonBox(QBtn)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

        self.layout = QVBoxLayout()
        message = QLabel(message)
        self.layout.addWidget(message)
        self.layout.addWidget(self.buttonBox)
        self.setLayout(self.layout)

__init__(title, message, *args, **kwargs)

Initialize and display QDialog.

Source code in sleap/gui/dialogs/query.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def __init__(self, title: str, message: str, *args, **kwargs):
    """Initialize and display `QDialog`."""
    super().__init__(*args, **kwargs)

    self.user_response = False

    self.setWindowTitle(title)

    QBtn = QDialogButtonBox.Ok | QDialogButtonBox.Cancel

    self.buttonBox = QDialogButtonBox(QBtn)
    self.buttonBox.accepted.connect(self.accept)
    self.buttonBox.rejected.connect(self.reject)

    self.layout = QVBoxLayout()
    message = QLabel(message)
    self.layout.addWidget(message)
    self.layout.addWidget(self.buttonBox)
    self.setLayout(self.layout)