forked from jianchang512/pyvideotrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsp.py
85 lines (72 loc) · 2.77 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
84
85
# -*- coding: utf-8 -*-
import sys
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
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):
global qss
# 创建并显示窗口B
try:
nostyle = Path("./nostyle.txt")
st = time.time()
from videotrans.mainwin.spwin import MainWindow
MainWindow(width=self.width, height=self.height)
if not nostyle.exists():
with open('./videotrans/styles/stylenoimg.qss', 'r', encoding='utf-8') as f:
app.setStyleSheet(f.read())
file = Path(Path.cwd() / "tmp")
file.mkdir(parents=True, exist_ok=True)
et = time.time()
self.close()
print(f'启动用时:{et - st}')
if not nostyle.exists():
import videotrans.ui.dark.darkstyle_rc
with open('./videotrans/styles/style.qss', 'r', encoding='utf-8') as f:
app.setStyleSheet(f.read())
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())