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如果程序需要修改主程序中的函数或者变量,则此参数必须为Truemuti_thread如果程序需要经过threading的特殊处理可将此项设为Truethread_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ab25b47cda771d183ad656d4d897325e457bc202d2b5c9f20427501f4487a7f
|
|
| MD5 |
4973b4ddc17d4ca27025bd80f776f04c
|
|
| BLAKE2b-256 |
5c2f81984d64ffbb01c8b6c14a1eeb3ab185ba156ce5322e827da50e189a0204
|
File details
Details for the file MSLXPluginHelper-0.0.2-py3-none-any.whl.
File metadata
- Download URL: MSLXPluginHelper-0.0.2-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baf51b4bd151763d98880e8b7446a327419b388ac05892b89e3ff3cf2999fdd8
|
|
| MD5 |
0a568615a4698f3a7833e2406bd2415e
|
|
| BLAKE2b-256 |
f5f32d09d795e745586e301ae3ccb39bfa07ed0c04ba9dad589976bf475f8ecd
|