mirror of
https://github.com/goldenfishs/MRobot.git
synced 2025-07-03 22:24:17 +08:00
构建home
This commit is contained in:
parent
e7822bbf64
commit
26ce1316ca
73
fluentui.py
73
fluentui.py
@ -29,45 +29,77 @@ class HomeInterface(BaseInterface):
|
|||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
# 欢迎图标
|
# 顶部Logo
|
||||||
iconLabel = QLabel(self)
|
iconLabel = QLabel(self)
|
||||||
iconPixmap = QPixmap('img/MRobot.png').scaled(
|
iconPixmap = QPixmap('img/MRobot.png').scaled(
|
||||||
300, 300, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation
|
180, 180, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation
|
||||||
)
|
)
|
||||||
iconLabel.setPixmap(iconPixmap)
|
iconLabel.setPixmap(iconPixmap)
|
||||||
iconLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
iconLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
|
|
||||||
# 欢迎语
|
# 标题
|
||||||
welcomeLabel = SubtitleLabel("高效、智能的R代码助手", self)
|
titleLabel = QLabel("MRobot 智能R助手", self)
|
||||||
setFont(welcomeLabel, 18)
|
titleLabel.setFont(QFont("微软雅黑", 28, QFont.Bold))
|
||||||
welcomeLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
titleLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
|
titleLabel.setStyleSheet("color: #1976d2; margin-top: 12px;")
|
||||||
|
|
||||||
# 操作按钮
|
# 副标题
|
||||||
btnGen = PushButton('生成代码', self, FIF.LIBRARY)
|
subtitle = QLabel("高效 · 智能 · 便捷\n让R语言开发更简单", self)
|
||||||
btnGen.setFixedWidth(160)
|
subtitle.setFont(QFont("微软雅黑", 16))
|
||||||
|
subtitle.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
|
subtitle.setStyleSheet("color: #555; margin-bottom: 18px;")
|
||||||
|
|
||||||
|
# 三个主按钮
|
||||||
|
btnGen = PushButton('代码生成', self, FIF.LIBRARY)
|
||||||
|
btnGen.setFixedSize(180, 48)
|
||||||
|
btnGen.setFont(QFont("微软雅黑", 15))
|
||||||
btnGen.clicked.connect(self.showInfoBar)
|
btnGen.clicked.connect(self.showInfoBar)
|
||||||
|
|
||||||
btnHelp = PushButton('帮助文档', self, FIF.HELP)
|
btnHelp = PushButton('帮助文档', self, FIF.HELP)
|
||||||
btnHelp.setFixedWidth(160)
|
btnHelp.setFixedSize(180, 48)
|
||||||
|
btnHelp.setFont(QFont("微软雅黑", 15))
|
||||||
btnHelp.clicked.connect(self.showHelp)
|
btnHelp.clicked.connect(self.showHelp)
|
||||||
|
|
||||||
btnAbout = PushButton('关于我们', self, FIF.INFO)
|
btnAbout = PushButton('关于我们', self, FIF.INFO)
|
||||||
btnAbout.setFixedWidth(160)
|
btnAbout.setFixedSize(180, 48)
|
||||||
|
btnAbout.setFont(QFont("微软雅黑", 15))
|
||||||
btnAbout.clicked.connect(self.showAbout)
|
btnAbout.clicked.connect(self.showAbout)
|
||||||
|
|
||||||
# 按钮布局
|
btnLayout = QHBoxLayout()
|
||||||
btnLayout = QVBoxLayout()
|
btnLayout.setSpacing(36)
|
||||||
btnLayout.setSpacing(16)
|
btnLayout.addStretch(1)
|
||||||
btnLayout.addWidget(btnGen)
|
btnLayout.addWidget(btnGen)
|
||||||
btnLayout.addWidget(btnHelp)
|
btnLayout.addWidget(btnHelp)
|
||||||
btnLayout.addWidget(btnAbout)
|
btnLayout.addWidget(btnAbout)
|
||||||
btnWidget = QWidget(self)
|
btnLayout.addStretch(1)
|
||||||
btnWidget.setLayout(btnLayout)
|
|
||||||
|
# 卡片式欢迎信息
|
||||||
|
card = QFrame(self)
|
||||||
|
card.setStyleSheet("""
|
||||||
|
QFrame {
|
||||||
|
background: #f8fbfd;
|
||||||
|
border-radius: 18px;
|
||||||
|
border: 1.5px solid #d6eaf8;
|
||||||
|
padding: 24px 32px 18px 32px;
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
cardLayout = QVBoxLayout(card)
|
||||||
|
cardLayout.setSpacing(10)
|
||||||
|
cardLayout.addWidget(titleLabel)
|
||||||
|
cardLayout.addWidget(subtitle)
|
||||||
|
cardLayout.addLayout(btnLayout)
|
||||||
|
|
||||||
# 主布局
|
# 主布局
|
||||||
self._mainLayout.insertWidget(0, iconLabel, 0, Qt.AlignmentFlag.AlignCenter)
|
layout = QVBoxLayout()
|
||||||
self._mainLayout.insertWidget(1, welcomeLabel, 0, Qt.AlignmentFlag.AlignCenter)
|
layout.setSpacing(24)
|
||||||
self._mainLayout.insertWidget(2, btnWidget, 0, Qt.AlignmentFlag.AlignCenter)
|
layout.setContentsMargins(0, 32, 0, 0)
|
||||||
|
layout.addWidget(iconLabel, 0, Qt.AlignmentFlag.AlignHCenter)
|
||||||
|
layout.addWidget(card, 0, Qt.AlignmentFlag.AlignHCenter)
|
||||||
|
layout.addStretch(1)
|
||||||
|
|
||||||
|
# 清空原有内容并设置新布局
|
||||||
|
QWidget().setLayout(self._mainLayout)
|
||||||
|
self.setLayout(layout)
|
||||||
|
|
||||||
def showInfoBar(self):
|
def showInfoBar(self):
|
||||||
InfoBar.success(
|
InfoBar.success(
|
||||||
@ -79,11 +111,10 @@ class HomeInterface(BaseInterface):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def showHelp(self):
|
def showHelp(self):
|
||||||
webbrowser.open("https://github.com/lvzucheng/MRobot") # 示例
|
webbrowser.open("https://github.com/lvzucheng/MRobot")
|
||||||
|
|
||||||
def showAbout(self):
|
def showAbout(self):
|
||||||
MessageBox("关于我们", "MRobot 由 lvzucheng 开发,致力于高效智能的R代码辅助。", self).exec()
|
MessageBox("关于我们", "MRobot 由 lvzucheng 开发,致力于高效智能的R代码辅助。", self).exec()
|
||||||
|
|
||||||
# ===================== 代码生成页面 =====================
|
# ===================== 代码生成页面 =====================
|
||||||
class DataInterface(BaseInterface):
|
class DataInterface(BaseInterface):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user