diff --git a/interface/main.py b/interface/main.py index cba95d2..3c331bb 100644 --- a/interface/main.py +++ b/interface/main.py @@ -1,11 +1,9 @@ -from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget +from PyQt5.QtWidgets import QWidget +from qfluentwidgets import PushButton, VBoxLayout class MainWidget(QWidget): def __init__(self, title="主页"): super().__init__() - self.name = "11" - layout = QVBoxLayout() - button = QPushButton(title) - layout.addWidget(button) - self.setLayout(layout) - self.setWindowTitle(title) \ No newline at end of file + self.setWindowTitle(title) + PushButton(title, self) # 创建按钮并添加到布局 + self.setLayout(VBoxLayout(self)) # 设置布局 \ No newline at end of file diff --git a/interface/setting.py b/interface/setting.py new file mode 100644 index 0000000..abfd0fb --- /dev/null +++ b/interface/setting.py @@ -0,0 +1,9 @@ +from PyQt5.QtWidgets import QWidget +from qfluentwidgets import PushButton, VBoxLayout + +class SettingWidget(QWidget): + def __init__(self, title="设置"): + super().__init__() + self.setWindowTitle(title) + PushButton(title, self) # 创建按钮并添加到布局 + self.setLayout(VBoxLayout(self)) # 设置布局 \ No newline at end of file diff --git a/main.py b/main.py index 3400376..5d4cc0b 100644 --- a/main.py +++ b/main.py @@ -1,15 +1,20 @@ import sys from PyQt5.QtWidgets import QApplication from qfluentwidgets import FluentWindow, Theme, setTheme -from interface.main import MainWidget from qfluentwidgets import FluentIcon as FIF +from interface.main import MainWidget +from interface.setting import SettingWidget class MainWindow(FluentWindow): def __init__(self): super().__init__() + self.setWindowTitle("HoYoCenter") setTheme(Theme.DARK) - self.id2obj = {"main": MainWidget()} + self.id2obj = { + "主页": [MainWidget(), FIF.HOME], + "设置": [SettingWidget(), FIF.SETTING] + } self.init_ui() def init_ui(self): @@ -18,8 +23,8 @@ class MainWindow(FluentWindow): def init_menu(self): self.navigationInterface.setExpandWidth(150) for name, obj in self.id2obj.items(): - obj.setObjectName(name) - self.addSubInterface(obj, FIF.HOME, name) + obj[0].setObjectName(name) + self.addSubInterface(obj[0], obj[1], name) def create_app(): app = QApplication(sys.argv)