Files
HPI/library/message_box.py

54 lines
1.6 KiB
Python
Raw Normal View History

from PyQt5.QtWidgets import QApplication, QDialog
from PyQt5.QtCore import Qt
import sys
from library.message_box_ui import *
class MessageBox(QDialog, Ui_message_box_ui):
def __init__(self, txt, parent=None):
'''
The super().__init__() method invokes the base class constructor from the MyForm class,
that is, the constructor of the QDialog class is invoked from MyForm class to indicate that
QDialog is displayed through this class iss a top-level window.
'''
super(MessageBox, self).__init__(parent)
self.setupUi(self)
# self.setWindowState(Qt.WindowMaximized) # 初始化时就最大化窗口
self.setWindowModality(Qt.ApplicationModal) # 阻塞此窗口只能在关闭此窗口之后才能操作后面的窗口但是不会阻塞调用此窗口的进程的代码此行代码必须放在show()函数之前
# self.setWindowModality(Qt.WindowModal)
# 无边框
# self.setWindowFlags(Qt.FramelessWindowHint)
self.txt = txt
self.info()
self.confirm_bt.clicked.connect(self.shutdown)
# 禁止调整大小
# self.setFixedSize(self.width(), self.height())
def info(self):
self.info_label.setText(self.txt)
# self.exec() # 阻塞调用此窗口后的进程的代码,只有此窗口返回后才能执行此窗口外的代码
# self.show() # 只是显示,不会阻塞任何代码
def shutdown(self):
self.close()
if __name__ == '__main__':
app = QApplication(sys.argv)
x = MessageBox('请先曝光和采集暗电流!')
# x.show()
sys.exit(app.exec_())