-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathyasumi_window.py
65 lines (55 loc) · 2.67 KB
/
yasumi_window.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
63
64
65
import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QApplication, QDialog, QLabel, QVBoxLayout, QMainWindow
from PyQt5.QtCore import Qt
from util import load_config
from MainWindowThread import DrawAnimationThread
class yasumiWindow(QDialog):
"""倒计时结束后的休息窗口,播放一遍麻衣学姐的gif。
self.yasumi_thread:播放动画的Qthread
"""
def __init__(self):
super().__init__()
self.config = load_config()
self.windowconfig = load_config(self.config["window_pos"])
self.src_conifg = load_config(self.config["source"])
self.desktop = QApplication.desktop()
self.gif = self.src_conifg["yasumi"]
# 获取显示器分辨率大小
self.screenRect = self.desktop.screenGeometry()
self.screen_height = self.screenRect.height()
self.screen_width = self.screenRect.width()
self.yasumi_thread = None
self.initUI()
def initUI(self):
self.setWindowTitle("Loading...")
self.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog)
self.setFixedSize(self.screen_width // 6 * 5,
self.screen_height // 6 * 5) # 固定窗口大小
self.setStyleSheet("background-color: white;") # 设置背景色为白色
# 隐藏最小化,关闭等按键
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowMinimizeButtonHint|Qt.WindowStaysOnTopHint)
self.animation_label = QLabel(self)
self.animation_label.setGeometry(QtCore.QRect(0 ,
0,
self.screen_width // 6 * 5,
self.screen_height // 6 * 5))
self.start_drawgif_task()
def start_drawgif_task(self):
if not self.yasumi_thread or not self.yasumi_thread.isRunning():
self.yasumi_thread = DrawAnimationThread()
self.yasumi_thread.setup(path=self.gif,
label=self.animation_label,
pos=(0,
0,
self.screen_width // 6 * 5,
self.screen_height // 6 * 5),
frame_speed=24,
whileTrue=False)
self.yasumi_thread.start()
def closeEvent(self, event):
if self.yasumi_thread and self.yasumi_thread.isRunning():
self.yasumi_thread.running = False
self.yasumi_thread.wait()
self.yasumi_thread.quit()
event.accept()