意见箱
恒创运营部门将仔细参阅您的意见和建议,必要时将通过预留邮箱与您保持联络。感谢您的支持!
意见/建议
提交建议

PyQt5中怎么显示消息框

来源:佚名 编辑:佚名
2024-03-13 14:15:51

在PyQt5中显示消息框可以使用QMessageBox类。以下是一个简单的例子:

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox

class Example(QWidget):
    def __init__(self):
        super().__init__()

        self.initUI()

    def initUI(self):
        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('Message box example')

        self.showMessageBox()

    def showMessageBox(self):
        QMessageBox.information(self, 'Information', 'This is an information message box')

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

在这个例子中,我们创建了一个简单的窗口,并在窗口中显示了一个信息消息框。您可以通过调用QMessageBox的静态方法(如information、question、warning等)来显示不同类型的消息框。


PyQt5中怎么显示消息框

本网站发布或转载的文章均来自网络,其原创性以及文中表达的观点和判断不代表本网站。
上一篇: Python中深拷贝和浅拷贝有什么区别 下一篇: mysql数据库创建失败怎么解决