This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Tutorial Python Extension not appearing in Tools Menu

Tags: None
(comma "," separated)
krafczyk
Registered Member
Posts
2
Karma
0
My system:
Arch Linux
Krita 4.3.0

I've gone through the tutorial here: https://docs.krita.org/en/user_manual/p ... -extension

However, this script isn't appearing in the Tools menu as suggested by the tutorial. Executing krita from the command line also gives no error messages, so I'm at a bit of a loss.

My plugin so far:

colorplanner.desktop:

Code: Select all
[Desktop Entry]
Type=Service
ServiceTypes=Krita/PythonPlugin
X-KDE-Library=colorplanner
X-Python-2-Compatible=false
#X-Krita-Manual=colorPlanner.html
Name=Color Planner Plugin
Comment=This plugin takes a base image, mask, original color, and goal color and provides a preview of the image with that color.



colorplanner directory contains:
__init__.py
Code: Select all
from .colorplanner import *


colorplanner.py
Code: Select all
from krita import *
from PyQt5.QtWidgets import QFileDialog

class MyExtension(Extension):
    def __init__(self, parent):
        super().__init__(parent)
   
    def setup(self):
        pass

    def exportDocument(self):
        # Get the document
        doc = Krita.instance().activeDocument()

        # Saving a non-existent document causes crashes, so lets check for that first.
        if doc is not None:
            # This calls up the save dialog. The save dialog returns a tuple.
            fileName = QFileDialog.getSaveFileName()[0]
            # And export the document to the fileName location.
            # InfoObject is a dictionary with specific export options, but when we make an empty one Krita will use the export defaults.
            doc.exportImage(fileName, InfoObject())

    def createActions(self, window):
        action = window.createAction("myAction", "My Script", "Tools/Scripts")
        action.triggered.connect(self.exportDocument)

Krita.instance().addExtension(MyExtension(Krita.instance()))


And, after copying to my pykrita folder:
Code: Select all
ls ~/.local/share/krita/pykrita
colorplanner  colorplanner.desktop


Code: Select all
ls ~/.local/share/krita/pykrita/colorplanner
colorplanner.py  __init__.py


Is there any way to find out whether Krita is able to recognize the plugin?
krafczyk
Registered Member
Posts
2
Karma
0
Folks coming across this issue,

The solution is to enable the script through the Krita 'Python Plugin Manager'. This is reachable under the 'Settings' menu, Select 'Configure Krita', Then the icon should be towards the bottom of the list of the left. Find your plugin name as mentioned in your .desktop file and click it. Restart Krita, and it should be there.

This Plugin Manager IS mentioned in the Python Plugin tutorial, but only under a 'Note' and I missed it until I ran into this problem and had to figure it out.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]