forked from jianchang512/pyvideotrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sp.py
83 lines (67 loc) · 2.57 KB
/
sp.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# -*- coding: utf-8 -*-
import sys, os
from pathlib import Path
import time
from PySide6 import QtWidgets
from PySide6.QtCore import Qt, QTimer, QPoint
from PySide6.QtGui import QPixmap, QPalette, QBrush, QIcon, QGuiApplication
from videotrans import VERSION
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
class StartWindow(QtWidgets.QWidget):
def __init__(self):
super(StartWindow, self).__init__()
self.width = 1200
self.height = 700
# 设置窗口无边框和标题
self.setWindowFlags(Qt.FramelessWindowHint)
# 设置窗口的背景图片
palette = QPalette()
palette.setBrush(QPalette.Window, QBrush(QPixmap("./videotrans/styles/logo.png")))
self.setPalette(palette)
self.setAutoFillBackground(True)
self.setWindowIcon(QIcon(".videotrans/styles/icon.ico"))
v1 = QtWidgets.QVBoxLayout()
v1.addStretch(1)
h1 = QtWidgets.QHBoxLayout()
v1.addLayout(h1)
v1.addStretch(0)
h1.addStretch(1)
self.lab = QtWidgets.QLabel()
self.lab.setText(f"pyVideoTrans {VERSION} Loading...")
self.lab.setStyleSheet("""font-size:16px;color:#fff;text-align:center""")
h1.addWidget(self.lab)
h1.addStretch(0)
self.setLayout(v1)
# 窗口大小
self.resize(560, 350)
self.show()
self.center()
QTimer.singleShot(200, self.run)
def run(self):
# 创建并显示窗口B
try:
if not Path("./nostyle.txt").exists():
import videotrans.ui.dark.darkstyle_rc
with open('./videotrans/styles/style.qss', 'r', encoding='utf-8') as f:
app.setStyleSheet(f.read())
st = time.time()
from videotrans.mainwin.spwin import MainWindow
MainWindow(width=self.width, height=self.height)
Path(Path.cwd() / "tmp").mkdir(parents=True, exist_ok=True)
et = time.time()
print(f'启动用时:{et - st}')
self.close()
except Exception as e:
print(f'main window {str(e)}')
def center(self):
screen = QGuiApplication.primaryScreen()
screen_resolution = screen.geometry()
self.width, self.height = screen_resolution.width(), screen_resolution.height()
self.move(QPoint(int((self.width - 560) / 2), int((self.height - 350) / 2)))
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
try:
startwin = StartWindow()
except Exception as e:
print(f"error:{str(e)}")
sys.exit(app.exec())