Action Shortcuts for Dockers?

I wanted to make some shortcuts for my docker and after following the tuts about it I was left with a couple of questions after following the tuts with success.

I am not sure if my case just is outside of bounds or if I am feeling my python handicap somewhere.
However I will try and explain.

  1. Krita Manual
    On this one I created the action file inside the action folder, and inside the main *.py file body I created a class that inherits from Extension that creates the action and connects to a operation. On this one my issue is that I cant connect to what I want to connect. This case works but it is executing the function Coisa. which is just a floating function outside of any class in which I want to operate though I can make also trigger a function within the Extension class with self.Coisa()


def Coisa():
    QMessageBox.information( QWidget(), i18n("Test"), i18n("Hello! This is Krita version %s") % Application.version())

# Create Action
class PigmentOExtension(Extension):

    def __init__(self, parent):
        super(PigmentOExtension, self).__init__(parent)

    def setup(self):

    def createActions(self, window):
        action_red_plus = window.createAction("channels_rgb_red_plus", "Channels RGB Red Plus")

instead of (works)


I trying something like this (no connection to work)

self.pigmento = PigmentODocker()

I tryed to create the action inside the docker itself instead of a external class like a Extension. But even with inherinting the “Extension” to the class I have no access to the “window” to feed it to the createActions function. Or at least I think it is the case.

class PigmentODocker(DockWidget, Extension):
    def createActions(self, window):
            action_red_plus = window.createAction("channels_rgb_red_plus", "Channels RGB Red Plus")
  1. Krita Scripting School
    I though I would have to then create the QAction manually as said here inside the docker class. however this would prove also unsuccessful as it also would only execute after a trigger(like a button) would be issued and not when a shortcut would be fired unless I am missing some important point here somewhere.


class PigmentODocker(DockWidget):
    def __init__(self):
        super(PigmentODocker, self).__init__()
    def createActions(self, window):
            action_red_plus = QAction("channels_rgb_red_plus")
  1. Other scripts
    After analysing other scripts I noticed that all scripts with actions where all based in a Extension model only as they would only trigger functions within themselves. However that is not my case to do a switch.

  2. So i took a look inside the current available classes to create actions and compared it to the reference site and there seems to be a disparity on what is on the site and what is on Krita? is this check real or I am having a false read here? I am left with the impression you have action creation available to the docker class also but there seems to be no reference anywhere on how to use it properly yet?

First thing that pops to my eye is difference of giving function handle/name as argument vs. calling the function, and giving its result as argument.

def a_function():
    print(f"a function called!")

action_red_plus.triggered.connect(  a_function  )
# vs.
action_red_plus.triggered.connect(  a_function()  )


I did forget to mention but I did try both ways just in case I was thinking wrong.
self.pigmento.Pigment_RGB_1_Minus() and self.pigmento.Pigment_RGB_1_Minus

This for the case given by the Krita Manual and for the case given in Krita Scripting School.