-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.py
62 lines (47 loc) · 1.74 KB
/
display.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from ast import Call
import sys
import threading
from PyQt5.QtCore import pyqtSignal, Qt, QThread, qInstallMessageHandler
from PyQt5.QtGui import QMovie
from PyQt5.QtWidgets import QApplication, QSplashScreen, QMainWindow
from typing import Callable
import asyncio
class Window(QMainWindow):
def __init__(self):
super().__init__()
class SplashScreen(QSplashScreen):
def __init__(self, filepath, callback:Callable, flags=0):
super().__init__(flags=Qt.WindowFlags(flags))
self.movie = QMovie(filepath, parent=self)
self.callback = callback
self.movie.frameChanged.connect(self.handleFrameChange)
self.movie.start()
def handleFrameChange(self):
pixmap = self.movie.currentPixmap()
self.setPixmap(pixmap)
self.setMask(pixmap.mask())
if self.movie.currentFrameNumber() == self.movie.frameCount()-1:
try:
self.movie.stop()
self.close()
if self.callback is not None:
self.callback()
except Exception:
pass
class Media:
StartSequence = 'media/F1_start_light_sequence_animation.gif'
class Display:
def __init__(self):
self.thread: threading.Thread = None
def handler(msg_type, msg_log_context, msg_string):
pass
qInstallMessageHandler(handler)
def show(self, media: Media, callback:Callable=None):
self.thread = threading.Thread(
target=self.__show, args=(media,callback), daemon=True
).start()
def __show(self, media, callback:Callable):
app = QApplication(sys.argv)
splash = SplashScreen(media, callback, Qt.WindowStaysOnTopHint)
splash.show()
app.exec_()