Python PyQt5: How to show an error message with PyQt5

前端 未结 6 1296
别那么骄傲
别那么骄傲 2020-12-15 13:00

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 a

6条回答
  •  萌比男神i
    2020-12-15 14:02

    Don't forget to call .exec_() to display the error:

    from PyQt5.QtWidgets import QMessageBox
    
    msg = QMessageBox()
    msg.setIcon(QMessageBox.Critical)
    msg.setText("Error")
    msg.setInformativeText('More information')
    msg.setWindowTitle("Error")
    msg.exec_()
    

提交回复
热议问题