SimpleAction.py
SimpleAction.py
# Import StreamController modules
from src.backend.PluginManager.ActionBase import ActionBase #(1)!
from src.backend.DeckManagement.DeckController import DeckController #(2)!
from src.backend.PageManagement.Page import Page #(3)!
from src.backend.PluginManager.PluginBase import PluginBase #(4)!
# Import python modules
import os
# Import gtk modules - used for the config rows
import gi
gi.require_version("Gtk", "4.0") #(5)!
gi.require_version("Adw", "1") #(6)!
from gi.repository import Gtk, Adw #(7)!
class SimpleAction(ActionBase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def on_ready(self) -> None:
icon_path = os.path.join(self.plugin_base.PATH, "assets", "info.png")
self.set_media(media_path=icon_path, size=0.75) #(8)!
def on_key_down(self) -> None:
print("Key down") #(9)!
def on_key_up(self) -> None:
print("Key up") #(10)!
- Import the ActionBase class
- Import the DeckController class - just used for typing
- Import the Page class - just used for typing
- Import the PluginBase class - just used for typing
- Set the GTK version to 4.0
- Set the Adw version to 1
- Import GTK and Adw
- Set an icon for the action
- Print "Key down" if the key is pressed
- Print "Key up" if the key is released