Hi and thank you for those tutorials. I should have started scripting in krita long ago, but it was this tutorial that finally helped me to actualy get started - thank you so much for that.
Here are my first day impressions from scripting in krita.
During this first day I managed to write an insanely simple switch between my most frequently used brush opacities:
(CLICK) Switching opacity between 50% and 100% with one key
from krita import *
for view in Krita.instance().views():
print(view.paintingOpacity())
if view.paintingOpacity() == 1.0:
view.setPaintingOpacity(0.5)
else:
view.setPaintingOpacity(1.0)
and the same for switching between my two brush blending modes
(CLICK) Switching between normal and overlay mode
from krita import *
for view in Krita.instance().views():
[print([a.objectName(), a.text()]) for a in Krita.instance().actions()]
if view.currentBlendingMode() == "normal":
Krita.instance().action("Select Overlay Blending Mode").trigger()
else:
Krita.instance().action("Select Normal Blending Mode").trigger()
It’s really convenient for me to use them that way, as I spend vast majority of my time in canvas-only mode.
For a long time I was wondering why switching blending modes with shortcuts never worked on my computer. Once I used:
[print([a.objectName(), a.text()]) for a in Krita.instance().actions()]
it turned out, that the actions like “Select Normal Blending Mode” (probably due to those spaces in their names), were accidentally translated in Polish translation (normally only method description should be translated). So krita tried to use methods like “Wybierz normalny tryb przesłaniania”, that is obviously not implemented.
So I guess I have found both a bug and its origin in my first day of scripting in krita 
I also tried to make a bit more complicated script that would allow me to have reference image and the artwork in separate views (as I tend to work), but make the reference image automatically set up to the coordinates - be the same size, rotation, on the same height, just like you would have a normal reference image, but once you zoom deep in the artwork, the reference is zoomed the same way - so you have both of them zoomed to the exact same spot.
Most of those (mirror, rotation, scale(sort of
) already work as I found those in the View class, although I couldn’t find how to translate the canvas inside the view - I guess this variable is somewhere deeper as I haven’t found anything like that in View class (or any of the most basic ones).
(CLICK) not finished "smart reference" script
from krita import *
for window in Krita.instance().windows():
activeView = window.activeView()
for view in Krita.instance().views():
if view != activeView:
reference = view
activeCan = activeView.canvas()
referenceCan = reference.canvas()
activeDoc = activeView.document()
referenceDoc = reference.document()
referenceCan.setMirror(activeCan.mirror())
referenceCan.resetRotation()
referenceCan.setRotation(activeCan.rotation())
scale = activeDoc.width()/referenceDoc.width()
print(activeDoc.width(),referenceDoc.width())
referenceCan.resetZoom()
referenceCan.setZoomLevel(activeCan.zoomLevel()/scale)
My biggest scripting dream in krita was to get the “show color selector” popup work on a modifier in “canvas input” instead as a usual shortcut. I already know that I can get it with:
Krita.instance().action("show_color_selector").trigger()
but it seems that making it appear on positive slope of the modifier (like pressing alt) and disappear only on negative one (I release alt) won’t be as easy with my knowledge after one day of scripting 
Anyway, if someone knows how to tackle any of those problems, or have the idea where specifically I should search in the krita documentation, feel free to let me know 