For plugin devs: restartKrita

Another - quite minimalistic - Krita plugin: restartKrita

This is a little special, I admit. While developing csh2krita and another addon I had to restart Krita constantly to test the new plugin versions and that got onto my nerves. So I did a quick “restart”-Plugin. You can add a UI button and restart Krita with one click (or via menu: scripts->restartKrita).

Tested in Krita 5.3.1 and 6.1.0 prealpha

https://codeberg.org/xanathon/restartKrita

#Krita #Krita5 #Krita6 #OpenSource #Plugin #KritaPlugin #FOSS

8 Likes

I’d like to share one of my own approaches as well.

For example, I have a file called Asd.py, which contains a class:

class Asd(Extension):
    actionList = []

    def testA(self):
        curAsd = self
        with open(r"G:\krita-5.2.3-prealpha-f50f6feb\resources\pykrita\asd\testA.py") as f:
            c = f.read()
            exec(c, globals(), locals())

And in testA.py, I have the following code:

print('testA.py')
print(f'{curAsd}')
print(f'{Asd}')
print(f'{curAsd.actionList}')

Inside testA.py, you can access the current instance of Asd via curAsd, and things like curAsd.actionList work just fine.

More importantly, you can modify testA.py in real time without restarting Krita. Every time testA() is called, it reads and executes the latest content of testA.py. The key here is the exec function.

For more details and caveats about exec, you can refer to the official Python documentation. Of course, this approach has its limitations, but at least it provides a way to reduce the number of times we need to restart Krita during development.

The code above is extracted from part of my plugin. You can quickly create a menu entry to trigger your method using something like:

window.createAction("layer2Selection", "layer2Selection", "tools/scripts").triggered.connect(self.layer2Selection)

Or you can create your own QButton—either way works. The key point here is the use of exec.

Hope this helps!

1 Like

It kept showing me this.

@Kaaivs i need more information. I tested this on Krita 5 and 6 on Windows, so I need to know what OS and what exakt version did you download? It may be better if you open an issue on the Codeberg download page.

Edit: I just tested to import the plugin again and it worked (I thought I might have botched the latest version), so I need more information to see what is wrong at your side.

@f3ef Great information, thanks for this.

Krita 5.3.0 (git 148ce5c), Windows 11.

I couldn’t finish the second step after installing rust, and for that I tried to import the plugin like I usually do with the other plugin i’ve installed.

You are mixing up things and plugins. That was the reason why I have asked you for the name of the plugin that gives you issues, which you did not even do by now!
How should we help you when you do not cooperate and answer the most simple questions? If you have language issues, then use a translator, for Russian DeepL.com and also Gemini are good options, at least far better than Google or even Yandex. For Greek, I believe DeepL.com is the best, but that can be wrong.

The plugin you are talking about right now is Zen picker, there you need to install VS and RUST, you must compile it yourself and there are environments where it was impossible to compile a working plugin from the fragments offered by xanderjakeq, mine for instance, because no matter what I did, I was unable to get that plugin working. And I believe that I knew at least what I did there. (And I do not understand why xanderjakeq did not offer a complete build plugin, but this construction kit.)

Michelist

##################
##################

Μπερδεύεις τα πράγματα με τα πρόσθετα. Αυτός ήταν ο λόγος για τον οποίο σου ζήτησα το όνομα του πρόσθετου που σου δημιουργεί προβλήματα, κάτι που ακόμα δεν έχεις κάνει!
Πώς να σε βοηθήσουμε όταν δεν συνεργάζεσαι και δεν απαντάς στις πιο απλές ερωτήσεις; Αν έχεις προβλήματα με τη γλώσσα, χρησιμοποίησε έναν μεταφραστή. Για τα ρωσικά, το DeepL.com και το Gemini είναι καλές επιλογές, τουλάχιστον πολύ καλύτερες από το Google ή ακόμα και το Yandex. Για τα ελληνικά, πιστεύω ότι το DeepL.com είναι το καλύτερο, αλλά μπορεί να κάνω λάθος.

Το plugin για το οποίο μιλάς αυτή τη στιγμή είναι το Zen picker, εκεί πρέπει να εγκαταστήσεις το VS και το RUST, πρέπει να το μεταγλωττίσεις μόνος σου και υπάρχουν περιβάλλοντα όπου ήταν αδύνατο να μεταγλωττιστεί ένα λειτουργικό plugin από τα τμήματα που προσέφερε ο xanderjakeq, το δικό μου για παράδειγμα, γιατί ό,τι κι αν έκανα, δεν κατάφερα να κάνω αυτό το plugin να λειτουργήσει. Και πιστεύω ότι ήξερα τουλάχιστον τι έκανα εκεί. (Και δεν καταλαβαίνω γιατί ο xanderjakeq δεν πρόσφερε ένα πλήρες plugin, αλλά αυτό το κιτ κατασκευής.)

Michelist

Translated with DeepL.com (free version)

1 Like

It’s alright I’ll try again figuring it out.

Thank you for your time