58 lines
1.3 KiB
Python
58 lines
1.3 KiB
Python
'''Precedes splashscreen of main application
|
|
'''
|
|
import sys
|
|
import time
|
|
|
|
from qtpy.QtCore import Qt, QTime, QTimer
|
|
from qtpy.QtGui import QColor, QImage, QPainter, QPixmap
|
|
from qtpy.QtWidgets import QApplication, QLabel
|
|
|
|
from pyqtacc.qrc_resources.facility.proscan.pyrcc5 import qrc_resources
|
|
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|
try:
|
|
due = QTime.currentTime()
|
|
message = "HUSH! will begin to load shortly"
|
|
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: wakeup.py HH:MM [optional message]"
|
|
|
|
|
|
while QTime.currentTime() < due:
|
|
time.sleep(1)
|
|
|
|
image = QImage(":/Hush.jpg")
|
|
p = QPainter(image)
|
|
font = p.font()
|
|
font.setPixelSize(54)
|
|
p.setFont(font)
|
|
p.setPen(QColor(Qt.red))
|
|
#p.setStyleSheet("color:red;")
|
|
#p.save()
|
|
p.drawText(40, 350, message)
|
|
#p.restore()
|
|
|
|
pixmap = QPixmap.fromImage(image)
|
|
|
|
label = QLabel()
|
|
label.setPixmap(pixmap)
|
|
label.setScaledContents(True)
|
|
|
|
label.setWindowFlags(Qt.SplashScreen)
|
|
label.setAlignment(Qt.AlignCenter)
|
|
label.setFixedHeight(600)
|
|
label.setFixedWidth(600)
|
|
label.show()
|
|
QTimer.singleShot(5000, app.quit) #5 seconds
|
|
|
|
app.exec_()
|