Skip to main content

Help you create a plugin for MSLX

Project description

MSLXPluginHelper

注意

文档现在领先于代码。请以文档为准。

开始编写插件

  • 首先,您应该编写from MSLXPluginHelper.PluginList import RegisterPlugin,这将导入用于注册插件函数的修饰器。

  • 编写您的插件函数体。

  • 使用@RegisterPlugin来修饰您的函数使其注册为一个MSLX插件,此修饰器需要一个字典才能正确注册,字典的格式如下:

{
	"name":"",
	"author":"",
	"description":"",
	"version":"x.x.x",
	"args":
    {
        "need_funcs":[],
        "need_vars":[],
    },
    "unsafe":True,
    "muti_thread":True,
    "thread_class":"Start_Plugin_Thread",
    "location":("main","after"),
    "events":
    {
        "on_load":("func","name"),
        "on_enable":("func","name"),
        "on_disable":("func","name"),
    }
}
  • name 是插件的名称
  • author 是插件的作者
  • description 是插件的描述
  • version 是插件的版本
  • args 表示插件需要在运行时获取的变量和函数
    • need_funcs 欲获取主程序中的函数的列表
    • need_vars 欲获取主程序中的变量的列表
  • unsafe 如果程序需要修改主程序中的函数或者变量,则此参数必须为True
  • muti_thread 如果程序需要经过threading的特殊处理可将此项设为True
  • thread_class 在指定上一个参数为True的情况下必须指定此项为继承了Threading的子类的类名
  • location 第一个参数表示插件加载的位置,第二个参数表示要在初始化之前或者初始化之后运行这个插件,只能为before或者after其中之一
  • events 表示插件在发生指定事件时需要执行的特殊动作
    • on_load 当插件被检测到的时候运行的函数名称,无论插件是否启用
    • on_enable 当插件被启用时运行的函数名称,插件的初始化函数应该写在这里而不是on_load处
    • on_disable 当插件被关闭时运行的函数名称,需要注意的是如果主程序启动时插件已经被禁用则这里的函数不会被运行

其中on_load,on_enable,on_disable的值还可写成这种形式:

{
"mode":"register",
"type":"class",
"value":"xxxx"
}

在这种情况下,MSLX会根据此处字典的值执行相应操作。

目前只支持register模式和class类型。在此种方法下,value应为已经存在的欲添加的class的名称。

最后,您应该在发布时将所有MSLXPluginHelper.PluginList替换为.PluginList

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

MSLXPluginHelper-0.0.2.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

MSLXPluginHelper-0.0.2-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file MSLXPluginHelper-0.0.2.tar.gz.

File metadata

  • Download URL: MSLXPluginHelper-0.0.2.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for MSLXPluginHelper-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3ab25b47cda771d183ad656d4d897325e457bc202d2b5c9f20427501f4487a7f
MD5 4973b4ddc17d4ca27025bd80f776f04c
BLAKE2b-256 5c2f81984d64ffbb01c8b6c14a1eeb3ab185ba156ce5322e827da50e189a0204

See more details on using hashes here.

File details

Details for the file MSLXPluginHelper-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for MSLXPluginHelper-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 baf51b4bd151763d98880e8b7446a327419b388ac05892b89e3ff3cf2999fdd8
MD5 0a568615a4698f3a7833e2406bd2415e
BLAKE2b-256 f5f32d09d795e745586e301ae3ccb39bfa07ed0c04ba9dad589976bf475f8ecd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page