from PyQt5.QtWidgets import QMessageBox msgBox = QMessageBox() msgBox.setIcon(QMessageBox.Information) msgBox.setText("This is an information message box.") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec()
from PyQt5.QtWidgets import QMessageBox, QPushButton msgBox = QMessageBox() msgBox.setIcon(QMessageBox.Warning) msgBox.setText("This is a warning message box.") msgBox.addButton(QPushButton('Option 1'), QMessageBox.YesRole) msgBox.addButton(QPushButton('Option 2'), QMessageBox.NoRole) msgBox.exec()The code examples make use of the PyQt5.QtWidgets QMessageBox module.