Python Plugin Developer Tools

Introducing Python Plugin developer Tools!

The goal of these tools is to make it easier for people to develop python plugins.

Current features include:

Selector/Sampler - for selecting with the mouse PyQt5 objects. Hold the shift key(or optionally ctrl/alt/meta key) and move the mouse as you wish, when you find the item you want, let go of the shift and it will show up in inspector.

Inspector - Lets you browse/search the PyQt5 tree and also view all the properties (including inherited ones).
With quick access to QT5 docs, parent traversing, code generation (code generation is primitive at this point but will improve with time), and show location of widget(when holding the button).

Console - A more basic version of scripter made for mostly quick tests or actions. Enter will execute the code (Use shift+enter for new lines if needed)

You can also bind console to your favorite text editor and send the code from the text editor directly to console.

Icons List - Shows you a full list of Krita icons available for usage. Clicking an icon gives you the code for it as well. There is also Theme icons, but I would be careful with those. If you are on windows, the icons that do show will probably work on other platforms, but if you are on linux, linux has a lot more theme icons that windows does not.

Actions List - Full list of actions and their descriptions. Double clicking will give you the trigger code for the action.

Krita API - Collection of Krita API commands and optionally download API documentation. Can also generate python autocomplete file.

I have a bit more nice features planned, but not sure how long it will take as work and other commitments are getting in the way. But it’ll probably be before the end of the year…

Anyways, hope developers find this useful and make more plugins!

16 Likes

That look pretty nifty, it may even be useful for C++ Krita development.

While by now I know where to find all those icons and action definitions in the sources, it sure looks like this UI makes things easier to find. Will keep this in mind next time I need to deal with one those things…

2 Likes

This is really cool. From the looks, the goal is something similar to Firefox’s web dev tools?

I am super curious about this.

1 Like

I just used it for a second and I am already impressed. this is actually amazing work. I got so much to learn and I think this will help alot. thank you so much.

1 Like

New update, I added multiwindow support (albeit the code may be in need of refactoring but it works):

If it helps with C++ development as well, even better :slight_smile:

Yes, it has always been a bit of a pain to look for things to hook onto here and there and took up some time. At first I was just dumping the entire tree, but that made it hard to see things in context. So if you combine all the time I spent finding this or that, it would be hours.

Then I figured, why not recreate the browser’s dev tools to make things easier. And I already see quite a quick improvement in the ability to find things.

There is still more useful tools to come.

Thanks, glad it helps :slight_smile:

4 Likes

I know I said no more new features for a bit, but one more for the road since it would be weird for a Krita Python Developer Tools not to actually have any Python API itself in there.

So I quickly added the Python API. It would probably need to be revised to be better like pulling descriptions from git, code completion in console and etc. But for now it still better than nothing.

Edit: So I added an AutoComplete generator, so one can do:

from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from .PyKrita import *
else:
    from krita import *

And have access to both autocomplete and documentation directly inside their IDE. That said, I can’t seem to test it :confused: KDevelop isn’t taking forward declarations of annotations, and VSCode isn’t working for autocomplete to begin with for anything.

So anyone uses an IDE that has working autocomplete and give it a shot?

2 Likes

This plugin is dope!
I think this one definitely should replace Scripter.
If the Console tab will allow load/save/reload scripts from file this will be so good!

Glad that it is useful, as for replacing scripter… I don’t know about that. Scipter is meant for prototyping, where as console is more for quick testing. Scripter has more features than just save and load, it has highlighting, tabbing to some extent and etc.

What I can do though as an alternative to scripter to some extent is to create a temp file and open it in your favorite text editor. Then any time you save the file, it will automatically load it up and run it in scripter. In this way you would get access to all the features of a text editor, won’t lose your progress if your script causes Krita to crash or hang. And I can bind up the autocomplete file generated to allow for Krita API autocomplete.

1 Like

Oh man, this is great. This will be extremely helpful for the Redesign plugin, as one of my main problems was trying to figure out how to access a certain widget to style.

This really is fantastic news, and I’m super excited to try it out, thank you!!!

Okay, I added the text editor binding stuff, try it out. It may still need a bit of polish here and there but I think you will like it more than simply a save/load for console as now you pretty much have full access to the full featured IDE.

I know the pain, half of my programming time pretty much went towards looking for things to bind to or finding some subproperty here and there.

And I know the more annoying something is to do, the less it encourages people to work on plugins. So the goal is to pretty much make most of the annoyances go away.

If anyone has any other things they find annoying when making plugins, feel free to mention it and I’ll see what I can do when I have the time.

1 Like

I have some things! First of all, I tried out your plugin last night when working in the redesign, and there was one thing that wasn’t working well for me. When I use the inspector to find an element, I can see that it gives the proper name. However, once I click it, the tree view hasn’t auto selected the element I just clicked.

I don’t know if its a bug, or that’s a feature that isn’t implemented yet, but it would be super helpful that that worked.

A new possible feature, though I don’t know how feasible it would be, would be to inject a stylesheet onto an element. Sometimes I just want to test how something would look, without needing all things of that type to be affected.

Once again though, thank you for this plugin!

Same problem on my side :wink:

Tested on a linux appimage with Krita5 beta2

Grum999

Is this before or after my previous post? The reason it wasn’t linked before was that sometimes elements can be removed after the tree was filled. So it had issues sometimes. But with yesterday nights update, I just decided to refresh the entire tree before. So it should be working fine if you downloaded the latest version.

That isn’t too hard. But to be clear, you want to modify the individual elements styles on the fly or you want to assign a global stylesheet for all the elements?

1 Like

I downloaded it the 25 of October, around 10.15pm
But -I don’t know why- I downloaded it on my Windows VM and then, tested it on windows on not linux as I was thinking :sweat_smile:

I’ll download and try it again tomorrow, on windows and linux (as I usually don’t use windows except for testing purposes…)

Grum999

One thing that could be useful (if not yet implemented, I didn’t tested yet the last version), when an item is selected in tree, automatically add a 1px or 2px blue (or current system highlight color) border on selected item in UI :slight_smile:

Grum999

Yeah, that is old version. I just did an update yesterday which improves the selector and the console.

That is implemented to some extent even on the old version.
If you select an item on the tree or with selector, just hold the “Hold to Highlight Widget Position” the button all the way on the right and it will show for that item.

I guess I can change it to toggle instead of hold if you want it automated through the tree.

Edit: Okay, did the change. It is now toggle.

2 Likes

First, I haven’t tested it with the latest update, but it’s great that it’s fixed!

Regarding the stylesheet, what would be amazing would be to be able to access an element’s stylesheet (don’t know if Qt allows this), or at least injecting styles to an element. It could also be cool to apply to the entire window, but I think it would be more helpful to inject only to a specified element.

I just used this plugin for development today.

Man, this is awesome tool!
I am happy that you made it. Helps a lot.

New update!

You can now modify any property as long as it has a “set” or “to” method, 1 parameter and accepts: string, int, float, bool, QRect, QRectF, QPoint, QPointF, QSize or QSizeF

Just doubleclick the value in the table view.

tl;dr - setStyleSheet can be modified for any element, setStyle, setFont and etc can not. (for now, at least not directly, you can still modify it in console)

Great to hear :slight_smile:

4 Likes