插件配置

一、插件配置
interface.py文件中
QCoreApplication.translate 是pyside6的翻译函数。有语言文件就会自动翻译。
demuc 是自定义的插件名称,必须与目录名字一致
例如:demuc_plugin 其中demuc是模块名称,demuc_plugin目录中的模块目录必须是 demuc
1、导入继承窗口

from PySide6.QtCore import QCoreApplication
from app.modules import xhook
class instance(xhook.windows.ShadowWindow):
    def __init__(self):
        super().__init__()

2、配置
配置必须变量名 pluConfig,是一个字典。

pluConfig = {
    "sys": "Windows",
    "model_name": "demuc",
    "name": QCoreApplication.translate("demuc","AI人声分离"),
    "category":  QCoreApplication.translate("demuc","音频处理"),
    "corder":1,
    "description": QCoreApplication.translate("demuc","从音视频文件中分离出 人声和背景音乐"),
    "icon": f"plugin/demuc_plugin/img/light/demuc.png",
    "author": "东",
    "version": "1.2",
    "order":5
}

二、初始化配置
把配置传进继承窗口后的初始化窗口函数

self.initWindow(pluConfig)

完整代码

from app.modules import xhook
from . import coms
hookimpl = xhook.lib_pluggy.HookimplMarker("my_plugins")
from PySide6.QtCore import QCoreApplication
pluConfig = {
    "sys": "Windows",
    "model_name": "demuc",
    "name": QCoreApplication.translate("demuc","AI人声分离"),
    "category":  QCoreApplication.translate("demuc","音频处理"),
    "corder":1,
    "description": QCoreApplication.translate("demuc","从音视频文件中分离出 人声和背景音乐"),
    "icon": f"plugin/demuc_plugin/img/light/demuc.png",
    "author": "东",
    "version": "1.2",
    "order":5
}
def create_instance(**kwargs):
    return instance()
#继承窗口xhook.windows.ShadowWindow
class instance(xhook.windows.ShadowWindow):
    def __init__(self):
        super().__init__()
        self.winsize = 1200, 720
        self.initWindow(pluConfig)


    #注册全局事件函数
    @hookimpl
    def globalEventWindow(self, event):
        pass
    #从主窗口直接调用传回参数
    @hookimpl
    def callback(self, data):
        pass
    #主窗口通信
    @hookimpl
    def windowSignalBus(self, data):
        pass
已采纳
再见旧时光
再见旧时光
QQ:986004469 Email:vutool@qq.com
7月前

6

0个回答默认排序 投票数排序
没有更多回答了~
本贴已经关闭回答功能~
0
1
0
1