更新版本

This commit is contained in:
2026-06-12 16:01:53 +08:00
parent 62ebc2f589
commit d17a54eb73
23 changed files with 8448 additions and 52 deletions
+86
View File
@@ -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):
"""工具箱主窗口类
继承自 QWidgetQt 窗口基类)和 Ui_FormToolsQt 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}")