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.
- 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
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): pass def createActions(self, window): action_red_plus = window.createAction("channels_rgb_red_plus", "Channels RGB Red Plus") action_red_plus.triggered.connect(Coisa)
instead of (works)
I trying something like this (no connection to work)
self.pigmento = PigmentODocker() action_red_plus.triggered.connect(self.pigmento.Pigment_RGB_1_Minus())
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") action_red_plus.triggered.connect(self.Pigment_RGB_1_Minus)
- 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__() self.createAction(self) ... def createActions(self, window): action_red_plus = QAction("channels_rgb_red_plus") action_red_plus.triggered.connect(self.Pigment_RGB_1_Minus)
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.
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?