代码:
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class WinForm( QWidget):
def __init__(self):
super(WinForm,self).__init__()
self.setWindowTitle("QMessageBox 例子")
self.resize(300, 100)
self.myButton = QPushButton(self)
self.myButton.setText("点击弹出消息框")
self.myButton.clicked.connect(self.msg)
def msg(self):
# 使用infomation信息框
reply = QMessageBox.information(self, "标题", "对话框消息正文",
QMessageBox.Yes | QMessageBox.No ,
QMessageBox.Yes )
print( reply )
if __name__ == '__main__':
app= QApplication(sys.argv)
demo = WinForm()
demo.show()
sys.exit(app.exec_())
来自《pyqt5 开发与实战》
显示效果:
当弹出 消息框的时候,在主窗口 点击, 消息框,会闪烁或者抖动
任务栏是 一个程序实例
https://www.cnblogs.com/zach0812/p/11398808.html
有问题,这个QMessageBox 必须 设置 parent吗,不能独立一个窗口吗?