import sys from PyQt5.QtWidgets import QMainWindow, QPushButton, QMessageBox, QApplication class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle('My App') button = QPushButton('Press me for a dialog!') button.setCheckable(True) button.clicked.connect(self.button_clicked) self.setCentralWidget(button) def button_clicked(self, is_checked): # button = QMessageBox.question(self, "Question dialog", "The longer message") button = QMessageBox.critical( self, 'Oh dear!', 'Somthing went very wrong', buttons=QMessageBox.Discard | QMessageBox.NoToAll | QMessageBox.Ignore, defaultButton=QMessageBox.Discard, ) if button == QMessageBox.Discard: print("Discard!") elif button == QMessageBox.NoToAll: print("No to all!") else: print("Ignore!") app = QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_())