In normal Python (3.x) we always use showerror() from the tkinter module to display an error message but what should I do in PyQt5 to display exactly the same message type as well?
Qt includes an error-message specific dialog class QErrorMessage
which you should use to ensure your dialog matches system standards. To show the dialog just create a dialog object, then call .showMessage()
. For example:
error_dialog = QtWidgets.QErrorMessage()
error_dialog.showMessage('Oh no!')
Here is a minimal working example script:
import PyQt5
from PyQt5 import QtWidgets
app = QtWidgets.QApplication([])
error_dialog = QtWidgets.QErrorMessage()
error_dialog.showMessage('Oh no!')
app.exec_()