添加设置
This commit is contained in:
parent
2a4ab55fc5
commit
a25b0e07fe
|
@ -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)
|
||||
self.setWindowTitle(title)
|
||||
PushButton(title, self) # 创建按钮并添加到布局
|
||||
self.setLayout(VBoxLayout(self)) # 设置布局
|
9
interface/setting.py
Normal file
9
interface/setting.py
Normal file
|
@ -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)) # 设置布局
|
13
main.py
13
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user