Python/pyqt5/CODE/元件使用範例/進階範例/qt05_timer02.py

25 lines
535 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
'''
【簡介】
PyQT5中QTimer關閉程式範例
'''
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
if __name__ == '__main__':
app = QApplication(sys.argv)
label = QLabel("<font color=red size=128><b>Hello PyQt視窗會在10秒後消失</b></font>")
# 無邊框視窗
label.setWindowFlags(Qt.SplashScreen|Qt.FramelessWindowHint)
label.show()
# 設定10秒後自動退出
QTimer.singleShot(10000, app.quit)
sys.exit(app.exec_())