"使用Python和PyQt5库创建弹出QMessageBox框的示例代码,其中包含了你所需的选项:\n\npython\nimport sys\nfrom PyQt5.QtWidgets import QApplication, QMessageBox\n\ndef show_message_box():\n app = QApplication(sys.argv)\n msg_box = QMessageBox()\n \n msg_box.setIcon(QMessageBox.Question)\n msg_box.setText(\"你选择做处理?\" )\n msg_box.setWindowTitle(\"提示\" )\n msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)\n msg_box.setDefaultButton(QMessageBox.Yes)\n \n ret = msg_box.exec_()\n \n if ret == QMessageBox.Yes:\n print(\"你选择了继续处理\" )\n elif ret == QMessageBox.No:\n print(\"你选择了重开\" )\n else:\n print(\"你选择了停止\" )\n \n sys.exit(app.exec_())\n\nif __name__ == '__main__':\n show_message_box()\n\n\n运行以上代码,将会弹出一个QMessageBox框,其中包含了你所需的选项。选择不同的选项,将会在控制台打印不同的输出。\n\n

Python PyQt5 弹出QMessageBox框提示用户选择: 继续、重开或停止

原文地址: https://www.cveoy.top/t/topic/pj86 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录