main.py
The main.py is the main file of your plugin and will be executed when the plugin is loaded. Therefore this is the place where you can add your actions to your plugin.
Per default the file looks like this:
main.py
# Import StreamController modules
from src.backend.PluginManager.PluginBase import PluginBase #(1)!
from src.backend.PluginManager.ActionHolder import ActionHolder #(2)!
# Import actions
from .actions.SimpleAction.SimpleAction import SimpleAction #(3)!
class PluginTemplate(PluginBase):
def __init__(self):
super().__init__()
## Register actions
self.simple_action_holder = ActionHolder( #(4)!
plugin_base = self,
action_base = SimpleAction,
action_id = "dev_core447_Template::SimpleAction", # Change this to your own plugin id
action_name = "Simple Action",
)
self.add_action_holder(self.simple_action_holder) #(5)!
# Register plugin
self.register(
plugin_name = "Template",
github_repo = "https://github.com/StreamController/PluginTemplate",
plugin_version = "1.0.0",
app_version = "1.1.1-alpha"
) #(5)!
- Import the PluginBase class which is the base for all plugins.
- Import the
ActionHolder
class which holds [ActionBases] until creation. - Import the SimpleAction which is a sample action with no backend.
- Create a new ActionHolder class for the [SimpleAction] action.
- Add the ActionHolder to the plugin.
- Register the plugin.
Let's go over the code:¶
Import StreamController modules¶
imports the PluginBase which is the base class for all plugins. imports the ActionHolder which holds [ActionBases] until creation.Import actions¶
imports the SimpleAction. This is the sample action with no backend.The plugin class¶
self.simple_action_holder = ActionHolder(
plugin_base = self,
action_base = SimpleAction,
action_id = "dev_core447_Template::SimpleAction", # Change this to your own plugin id
action_name = "Simple Action",
)
self.register(
plugin_name = "Template",
github_repo = "https://github.com/StreamController/PluginTemplate",
plugin_version = "1.0.0",
app_version = "1.1.1-alpha"
)