diff --git a/app/config.py b/app/config.py index 5c8abb7..bdeb9d7 100644 --- a/app/config.py +++ b/app/config.py @@ -11,6 +11,7 @@ class Config: """ base_config = { "theme": "dark", + "init": False } def __init__(self): """ diff --git a/interface/init.py b/interface/init.py deleted file mode 100644 index 439b67e..0000000 --- a/interface/init.py +++ /dev/null @@ -1,14 +0,0 @@ -from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication -from qfluentwidgets import MessageBoxBase, SubtitleLabel - -class InitWindow(QWidget): - """ Custom message box """ - - def __init__(self): - super().__init__() - self.layout = QVBoxLayout(self) - self.titleLabel = SubtitleLabel('初始化') - # 将组件添加到布局中 - self.layout.addWidget(self.titleLabel) - - self.setLayout(self.layout) diff --git a/interface/init/__init__.py b/interface/init/__init__.py new file mode 100644 index 0000000..b4a308b --- /dev/null +++ b/interface/init/__init__.py @@ -0,0 +1,56 @@ +from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QDesktopWidget +from PyQt5.QtCore import Qt +from qfluentwidgets import PushButton, SubtitleLabel, Theme, setTheme +import app.env as env + +class InitWindow(QWidget): + def __init__(self, main_window): + super().__init__() + self.window = main_window + + if env.config.theme == "dark": + setTheme(Theme.DARK) + # 给窗口添加样式 + self.setStyleSheet("background-color: #2E2E2E;") + else: + setTheme(Theme.LIGHT) + + # 设置窗口大小 + self.resize(800, 600) + + # 设置窗口始终位于最上层 + self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint) + + # 居中显示 + self.center_window() + + # 初始化布局 + self.layout = QVBoxLayout(self) + self.titleLabel = SubtitleLabel('初始化') + self.start_button = PushButton('开始') + self.start_button.clicked.connect(self.run) + self.layout.addWidget(self.start_button) + # 将组件添加到布局中 + self.layout.addWidget(self.titleLabel) + + # 应用布局 + self.setLayout(self.layout) + + def center_window(self): + """将窗口居中显示""" + screen = QDesktopWidget().screenGeometry() + size = self.geometry() + new_left = (screen.width() - size.width()) // 2 + new_top = (screen.height() - size.height()) // 2 + self.move(new_left, new_top) + + def run(self): + self.window.show() + self.close() + +if __name__ == "__main__": + import sys + app = QApplication(sys.argv) + window = InitWindow() + window.show() + sys.exit(app.exec_()) \ No newline at end of file diff --git a/interface/init/about.py b/interface/init/about.py new file mode 100644 index 0000000..b37e224 --- /dev/null +++ b/interface/init/about.py @@ -0,0 +1,7 @@ +from PyQt5.QtWidgets import QWidget + +class AboutWidget(QWidget): + def __init__(self, typex="init"): + self.init_ui() + + def init_ui() \ No newline at end of file diff --git a/main.py b/main.py index d331c2b..5a0db52 100644 --- a/main.py +++ b/main.py @@ -30,8 +30,9 @@ class MainWindow(FluentWindow): self.init_ui() def init_ui(self): - self.w = InitWindow() - self.w.show() + if not env.config.init: + self.w = InitWindow(self) + self.w.show() # 初始化菜单 self.init_menu() @@ -54,12 +55,13 @@ def create_app(): # 设置窗口大小 window.resize(workaera.width(),workaera.height()) # 显示窗口 - window.show() + # window.show() return app # 主函数 def main(): app = create_app() + # 运行应用程序 sys.exit(app.exec_())