更新版本
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
|
||||
from PySide6.QtWidgets import QFrame
|
||||
from .tool_card_ui import Ui_FrameToolCard
|
||||
|
||||
|
||||
class ToolCard(QFrame, Ui_FrameToolCard):
|
||||
"""工具卡片类
|
||||
|
||||
继承自 QFrame(Qt 帧基类)和 Ui_FrameToolCard(Qt Designer 生成的 UI 界面)
|
||||
负责显示工具的卡片界面,包含工具的图标、名称和描述。
|
||||
"""
|
||||
def __init__(self, parent = None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setupUi(self)
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FrameToolCard</class>
|
||||
<widget class="QFrame" name="FrameToolCard">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>491</width>
|
||||
<height>64</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButtonInstall">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>安装</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pushButtonUninstall">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>卸载</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pushButtonUpdate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>更新</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelInfo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,91 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
################################################################################
|
||||
## Form generated from reading UI file 'tool_card.ui'
|
||||
##
|
||||
## Created by: Qt User Interface Compiler version 6.11.1
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
################################################################################
|
||||
|
||||
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||
QMetaObject, QObject, QPoint, QRect,
|
||||
QSize, QTime, QUrl, Qt)
|
||||
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QFont, QFontDatabase, QGradient, QIcon,
|
||||
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QApplication, QFrame, QGridLayout, QLabel,
|
||||
QPushButton, QSizePolicy, QWidget)
|
||||
|
||||
class Ui_FrameToolCard(object):
|
||||
def setupUi(self, FrameToolCard):
|
||||
if not FrameToolCard.objectName():
|
||||
FrameToolCard.setObjectName(u"FrameToolCard")
|
||||
FrameToolCard.resize(491, 64)
|
||||
self.gridLayout_2 = QGridLayout(FrameToolCard)
|
||||
self.gridLayout_2.setObjectName(u"gridLayout_2")
|
||||
self.gridLayout = QGridLayout()
|
||||
self.gridLayout.setObjectName(u"gridLayout")
|
||||
self.labelName = QLabel(FrameToolCard)
|
||||
self.labelName.setObjectName(u"labelName")
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.labelName.sizePolicy().hasHeightForWidth())
|
||||
self.labelName.setSizePolicy(sizePolicy)
|
||||
|
||||
self.gridLayout.addWidget(self.labelName, 0, 0, 1, 1)
|
||||
|
||||
self.pushButtonInstall = QPushButton(FrameToolCard)
|
||||
self.pushButtonInstall.setObjectName(u"pushButtonInstall")
|
||||
sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
|
||||
sizePolicy1.setHorizontalStretch(0)
|
||||
sizePolicy1.setVerticalStretch(0)
|
||||
sizePolicy1.setHeightForWidth(self.pushButtonInstall.sizePolicy().hasHeightForWidth())
|
||||
self.pushButtonInstall.setSizePolicy(sizePolicy1)
|
||||
|
||||
self.gridLayout.addWidget(self.pushButtonInstall, 0, 1, 1, 1)
|
||||
|
||||
self.pushButtonUninstall = QPushButton(FrameToolCard)
|
||||
self.pushButtonUninstall.setObjectName(u"pushButtonUninstall")
|
||||
sizePolicy1.setHeightForWidth(self.pushButtonUninstall.sizePolicy().hasHeightForWidth())
|
||||
self.pushButtonUninstall.setSizePolicy(sizePolicy1)
|
||||
|
||||
self.gridLayout.addWidget(self.pushButtonUninstall, 0, 2, 1, 1)
|
||||
|
||||
self.pushButtonUpdate = QPushButton(FrameToolCard)
|
||||
self.pushButtonUpdate.setObjectName(u"pushButtonUpdate")
|
||||
sizePolicy1.setHeightForWidth(self.pushButtonUpdate.sizePolicy().hasHeightForWidth())
|
||||
self.pushButtonUpdate.setSizePolicy(sizePolicy1)
|
||||
|
||||
self.gridLayout.addWidget(self.pushButtonUpdate, 0, 3, 1, 1)
|
||||
|
||||
|
||||
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
|
||||
|
||||
self.labelInfo = QLabel(FrameToolCard)
|
||||
self.labelInfo.setObjectName(u"labelInfo")
|
||||
sizePolicy2 = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Expanding)
|
||||
sizePolicy2.setHorizontalStretch(0)
|
||||
sizePolicy2.setVerticalStretch(0)
|
||||
sizePolicy2.setHeightForWidth(self.labelInfo.sizePolicy().hasHeightForWidth())
|
||||
self.labelInfo.setSizePolicy(sizePolicy2)
|
||||
|
||||
self.gridLayout_2.addWidget(self.labelInfo, 1, 0, 1, 1)
|
||||
|
||||
|
||||
self.retranslateUi(FrameToolCard)
|
||||
|
||||
QMetaObject.connectSlotsByName(FrameToolCard)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, FrameToolCard):
|
||||
FrameToolCard.setWindowTitle(QCoreApplication.translate("FrameToolCard", u"Frame", None))
|
||||
self.labelName.setText(QCoreApplication.translate("FrameToolCard", u"Name", None))
|
||||
self.pushButtonInstall.setText(QCoreApplication.translate("FrameToolCard", u"\u5b89\u88c5", None))
|
||||
self.pushButtonUninstall.setText(QCoreApplication.translate("FrameToolCard", u"\u5378\u8f7d", None))
|
||||
self.pushButtonUpdate.setText(QCoreApplication.translate("FrameToolCard", u"\u66f4\u65b0", None))
|
||||
self.labelInfo.setText(QCoreApplication.translate("FrameToolCard", u"TextLabel", None))
|
||||
# retranslateUi
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
"""
|
||||
工具箱模块
|
||||
|
||||
提供工具箱主窗口,包含各种实用工具的入口。
|
||||
使用 PySide6 构建的窗口框架。
|
||||
|
||||
主要功能:
|
||||
- 工具箱主窗口界面
|
||||
- 窗口居中显示功能
|
||||
- 工具分类和导航
|
||||
|
||||
Author: Model Team
|
||||
Version: 0.0.1
|
||||
"""
|
||||
import logging
|
||||
|
||||
from qt_material import apply_stylesheet
|
||||
|
||||
from pathlib import Path
|
||||
from .tools_ui import Ui_FormTools
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtWidgets import QWidget, QApplication
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
PLUGINS_PATH = Path('Y:/SE/xufeifei/plugins')
|
||||
|
||||
class ToolsWindow(QWidget, Ui_FormTools):
|
||||
"""工具箱主窗口类
|
||||
|
||||
继承自 QWidget(Qt 窗口基类)和 Ui_FormTools(Qt Designer 生成的 UI 界面)
|
||||
负责显示工具箱的主界面,提供工具的分类和导航功能。
|
||||
|
||||
窗口特性:
|
||||
- 默认尺寸: 400x293 像素
|
||||
- 支持窗口居中显示
|
||||
- 可作为独立窗口或嵌入其他窗口使用
|
||||
|
||||
Attributes:
|
||||
parent: 父窗口对象,默认为 None(顶级窗口)
|
||||
"""
|
||||
def __init__(self, parent: QWidget = None) -> None:
|
||||
"""初始化工具箱窗口
|
||||
|
||||
创建工具箱窗口实例,初始化 UI 界面。
|
||||
|
||||
Args:
|
||||
parent: 父窗口对象,用于建立父子关系。
|
||||
默认为 None,表示这是顶级窗口。
|
||||
"""
|
||||
super().__init__(parent)
|
||||
self.setupUi(self)
|
||||
|
||||
self.initUI()
|
||||
self.load_stylesheet()
|
||||
|
||||
def initUI(self) -> None:
|
||||
"""
|
||||
初始化用户界面
|
||||
|
||||
配置窗口标题、图标、大小和居中显示。
|
||||
"""
|
||||
self.setWindowTitle("工具箱")
|
||||
self.setWindowIcon(QIcon('resources/tools.ico'))
|
||||
|
||||
|
||||
def load_stylesheet(self) -> None:
|
||||
"""
|
||||
加载 Qt 样式表和自定义样式文件
|
||||
|
||||
使用 qt_material 库加载暗色主题,并应用自定义 QSS 样式表
|
||||
失败时记录错误日志,但不影响应用继续运行(降级策略)
|
||||
|
||||
异常处理:
|
||||
- FileNotFoundError: 样式文件不存在
|
||||
- RuntimeError: 主题加载失败
|
||||
- 其他异常: 记录警告但不中断应用
|
||||
"""
|
||||
try:
|
||||
apply_stylesheet(self, style=None,theme='dark_teal.xml', css_file='resources/my.qss')
|
||||
except FileNotFoundError as e:
|
||||
logger.warning(f"样式文件未找到,使用默认主题: {e}")
|
||||
except RuntimeError as e:
|
||||
logger.warning(f"主题加载失败,使用默认主题: {e}")
|
||||
except Exception as e:
|
||||
logger.warning(f"样式加载失败,使用默认主题: {e}")
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FormTools</class>
|
||||
<widget class="QWidget" name="FormTools">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>810</width>
|
||||
<height>423</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,47 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
################################################################################
|
||||
## Form generated from reading UI file 'tools.ui'
|
||||
##
|
||||
## Created by: Qt User Interface Compiler version 6.11.1
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
################################################################################
|
||||
|
||||
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||
QMetaObject, QObject, QPoint, QRect,
|
||||
QSize, QTime, QUrl, Qt)
|
||||
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QFont, QFontDatabase, QGradient, QIcon,
|
||||
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QApplication, QGridLayout, QListWidget, QListWidgetItem,
|
||||
QSizePolicy, QWidget)
|
||||
|
||||
class Ui_FormTools(object):
|
||||
def setupUi(self, FormTools):
|
||||
if not FormTools.objectName():
|
||||
FormTools.setObjectName(u"FormTools")
|
||||
FormTools.resize(810, 423)
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(FormTools.sizePolicy().hasHeightForWidth())
|
||||
FormTools.setSizePolicy(sizePolicy)
|
||||
self.gridLayout = QGridLayout(FormTools)
|
||||
self.gridLayout.setObjectName(u"gridLayout")
|
||||
self.listWidget = QListWidget(FormTools)
|
||||
self.listWidget.setObjectName(u"listWidget")
|
||||
|
||||
self.gridLayout.addWidget(self.listWidget, 0, 0, 1, 1)
|
||||
|
||||
|
||||
self.retranslateUi(FormTools)
|
||||
|
||||
QMetaObject.connectSlotsByName(FormTools)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, FormTools):
|
||||
FormTools.setWindowTitle(QCoreApplication.translate("FormTools", u"Form", None))
|
||||
# retranslateUi
|
||||
|
||||
Reference in New Issue
Block a user