优化
This commit is contained in:
@@ -10,10 +10,12 @@ Model Team Tools - 主程序入口
|
||||
- 配置菜单栏和状态栏
|
||||
- 提供统一的日志记录接口
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import core
|
||||
import traceback
|
||||
import importlib
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
@@ -33,6 +35,7 @@ MICRO_VER: int = 1 # 修订版本号
|
||||
APP_NAME: str = "Model Team Tools"
|
||||
APP_VERSION: str = f"{MAJOR_VER}.{MINOR_VER}.{MICRO_VER}"
|
||||
|
||||
LOCAL_PLUGINS_PATH = Path("./plugins")
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
"""
|
||||
@@ -45,9 +48,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setupUi(self)
|
||||
self.initUI()
|
||||
|
||||
self.tools = dict()
|
||||
self.plugin_registry = core.PluginRegistry()
|
||||
self.plugins = core.Plugins(self.plugin_registry)
|
||||
self.plugin_registry.plugins_loader_signal.connect(self.on_plugins_loader)
|
||||
|
||||
self.initUI()
|
||||
|
||||
def initUI(self) -> None:
|
||||
"""
|
||||
@@ -108,13 +114,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
- 打开失败时记录 ERROR 级别日志
|
||||
"""
|
||||
try:
|
||||
self.tool_window = core.ToolsWindow(self.tools)
|
||||
self.tool_window.show()
|
||||
# logger.info("工具箱窗口已打开")
|
||||
self.plugins.show()
|
||||
except Exception as e:
|
||||
logger.error(f"无法打开工具箱窗口: {e}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
def on_plugins_loader(self, plugins:dict):
|
||||
for name in plugins.keys():
|
||||
self.stackedWidget.addWidget(plugins[name]['obj'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
Reference in New Issue
Block a user