PyQt5基础学习-QTimer.singleShot(定时执行程序)
设置定时器对整个程序进行关闭
""" 让程序定时关闭 QTimer.singleShot """ import sys from typing import Union from PyQt5.QtWidgets import * from PyQt5.QtCore import QTimer, QDateTime from PyQt5.QtGui import * from PyQt5.QtCore import * if __name__ == "__main__": app = QApplication(sys.argv) #构造标签 label = QLabel("Hello World, 窗口在5秒后自动关闭!") #作为窗口提示 label.setWindowFlags(Qt.SplashScreen | Qt.FramelessWindowHint) #进行标签显示 label.show() #一定时间后进行关闭 QTimer.singleShot(5000, app.quit) sys.exit(app.exec_())