首页 > 代码库 > pyqt学习之到点提醒程序(网友提供)
pyqt学习之到点提醒程序(网友提供)
import sys
import time
from PyQt4.QtCore import *
from PyQt4.QtGui import *
#aside1
app = QApplication(sys.argv)
#aside2
try:
due = QTime.currentTime()
message = "Alert!"
if len(sys.argv) < 2:
raise ValueError
hours, mins = sys.argv[1].split(":")
due = QTime(int(hours), int(mins))
if not due.isValid():
raise ValueError
if len(sys.argv) > 2:
message = " ".join(sys.argv[2:])
except ValueError:
message = "Usage: alert.pyw HH:MM [optional message]" # 24hr clock
#aside3
while QTime.currentTime() < due:
time.sleep(20) # 20 seconds
#aside4
label = QLabel("<font color=red size=72><b>" + message + "</b></font>")
label.setWindowFlags(Qt.SplashScreen)
label.show()
QTimer.singleShot(60000, app.quit) # 1 minute
app.exec_()
如图:
pyqt学习之到点提醒程序(网友提供)