forked from pur1fying/blue_archive_auto_script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow.py
135 lines (104 loc) · 4.3 KB
/
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# coding:utf-8
import os
import sys
from PyQt5.QtCore import Qt, QSize, QJsonDocument
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QFrame, QHBoxLayout
from qfluentwidgets import FluentIcon as FIF, SplashScreen
from qfluentwidgets import (FluentWindow, SubtitleLabel, setFont, setThemeColor)
from core import default_config, DEFAULT_CONFIG_PATH
sys.stderr = open('error.log', 'w+', encoding='utf-8')
sys.stdout = open('output.log', 'w+', encoding='utf-8')
sys.path.append('./')
# Offer the error to the error.log
ICON_DIR = 'gui/assets/logo.png'
def check_config():
if not os.path.exists('./config'):
os.mkdir('./config')
if not os.path.exists('./config/static.json'):
with open('./config/static.json', 'w', encoding='utf-8') as f:
f.write(default_config.STATIC_DEFAULT_CONFIG)
if not os.path.exists('./config/config.json'):
with open('./config/config.json', 'w', encoding='utf-8') as f:
f.write(default_config.DEFAULT_CONFIG)
if not os.path.exists('./config/event.json'):
with open('./config/event.json', 'w', encoding='utf-8') as f:
f.write(default_config.EVENT_DEFAULT_CONFIG)
# 每次都要重新生成
with open('./config/display.json', 'w', encoding='utf-8') as f:
f.write(default_config.DISPLAY_DEFAULT_CONFIG)
with open('./config/switch.json', 'w', encoding='utf-8') as f:
f.write(default_config.SWITCH_DEFAULT_CONFIG)
class Widget(QFrame):
def __init__(self, text: str, parent=None):
super().__init__(parent=parent)
self.label = SubtitleLabel(text, self)
self.hBoxLayout = QHBoxLayout(self)
setFont(self.label, 24)
self.label.setAlignment(Qt.AlignCenter)
self.hBoxLayout.addWidget(self.label, 1, Qt.AlignCenter)
self.setObjectName(text.replace(' ', '-'))
class Window(FluentWindow):
def __init__(self):
super().__init__()
self.initWindow()
self.splashScreen = SplashScreen(self.windowIcon(), self)
self.splashScreen.setIconSize(QSize(102, 102))
self.show()
setThemeColor('#0078d4')
# create sub interface
from gui.fragments.home import HomeFragment
from gui.fragments.switch import SwitchFragment
from gui.fragments.settings import SettingsFragment
self.homeInterface = HomeFragment(parent=self)
self.schedulerInterface = SwitchFragment(parent=self)
# self.processInterface = ProcessFragment()
self.settingInterface = SettingsFragment(parent=self)
self.initNavigation()
self.splashScreen.finish()
def call_update(self):
self.schedulerInterface.update_settings()
def initNavigation(self):
self.addSubInterface(self.homeInterface, FIF.HOME, '主页')
self.navigationInterface.addSeparator()
self.addSubInterface(self.schedulerInterface, FIF.CALENDAR, '调度器')
# add custom widget to bottom
self.addSubInterface(self.settingInterface, FIF.SETTING, '设置')
def initWindow(self):
self.resize(900, 700)
self.setWindowIcon(QIcon(ICON_DIR))
self.setWindowTitle('BlueArchiveAutoScript')
desktop = QApplication.desktop().availableGeometry()
_w, _h = desktop.width(), desktop.height()
self.move(_w // 2 - self.width() // 2, _h // 2 - self.height() // 2)
def closeEvent(self, event):
super().closeEvent(event)
def start():
QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv)
w = Window()
w.show()
app.exec_()
if __name__ == '__main__':
# pa=Main()
# pa._init_emulator()
# pa.solve("arena")
check_config()
QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv)
w = Window()
# 聚焦窗口
w.setFocus(True)
w.show()
app.exec_()
# if __name__ == '__main__':
# print(datetime.now())
# s = Scheduler()
# p = s.log('test')
# print(p)
# p = sorted(p, key=lambda x: x['next_tick'])
# print(p)