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
from src.backend.PluginManager.ActionBase import ActionBase # (1)
from src.backend.PluginManager.PluginBase import PluginBase # (2)
# Import gtk modules
import gi # (3)
gi.require_version("Gtk", "4.0") # (4)
gi.require_version("Adw", "1") # (5)
from gi.repository import Gtk, Adw # (6)
# Import actions
from .actions.Backend.BackendAction import BackendAction # (7)
class PluginTemplate(PluginBase): # (8)
def __init__(self):
self.PLUGIN_NAME = "PluginTemplate" # (9)
self.GITHUB_REPO = "https://github.com/Core447/PluginTemplate" # (10)
super().__init__() # (11)
self.add_action(BackendAction) # (12)
- Import the ActionBase which is the base class for all actions.
- Import the PluginBase which is the base class for all plugins.
- Import the GTK bindings
- Set the GTK version to 4.0
- Set the Adw version to 1
- Import GTK and Adw
- Import the BackendAction which is the sample action with seperated backend.
- Create a new plugin class by extending the PluginBase class.
- Set the name of your plugin. This will be shown in the ui but not in the store.
- Set the link to your github repository. This will not be shown in the ui.
- Initialize the base class.
- Add the sample action to the plugin. This must be the class of the action not an instance.
Let's go over the code:¶
StreamController imports¶
imports the ActionBase which is the base class for all actions. imports the PluginBase which is the base class for all plugins.Gtk import¶
import gtk
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Gtk, Adw
Import actions¶
imports the BackendAction. This is the sample action with seperated backend.The plugin class¶
class PluginTemplate(PluginBase):
def __init__(self):
self.PLUGIN_NAME = "PluginTemplate"
self.GITHUB_REPO = "https://github.com/Core447/PluginTemplate"
super().__init__()
self.add_action(BackendAction)
PLUGIN_NAME
is the name of your plugin. This will be shown in the ui.GITHUB_REPO
is the link to your github repository. This will not be shown in the ui.super().__init__()
initializes the base class.self.add_action(BackendAction)
adds the sample action to the plugin. This must be the class of the action not an instance.