import sys from PyQt5.QtWidgets import QApplication, QDialog, QDialogButtonBox, QVBoxLayout class MyDialog(QDialog): def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle("Example Dialog") # Create QDialogButtonBox and add OK/Cancel buttons button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) # Connect buttons to respective functions button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) # Create layout and add button box layout = QVBoxLayout(self) layout.addWidget(button_box) if __name__ == '__main__': app = QApplication(sys.argv) dialog = MyDialog() dialog.exec_() sys.exit(app.exec_())In this example, we create a QDialogButtonBox and add the "OK" and "Cancel" buttons using the QDialogButtonBox.Ok and QDialogButtonBox.Cancel constants. We then connect these buttons to their respective accept and reject functions and add the button box to a layout managed by a QVBoxLayout. The PyQt5.QtWidgets QDialogButtonBox class belongs to the PyQt5.QtWidgets package library, which is a set of widgets and classes used for creating graphical user interfaces (GUIs) in Python using the Qt framework.