Python Plugin Developer Tools

If you are on windows, try using krita.com instead of the exe in command line

As for the errors, yes you are correct, I used the QDialog way which doesn’t quite work on the DockWidget. Though it may have in the past since I didn’t notice, but it isn’t impossible that I missed it for one of them in a hurry

I did some fixes including to other templates, as long as I didn’t make any copy and paste errors again, it should work

As for making the tools part of Krita, I’ll ask the devs about it at one point. But I’d prefer to rewrite it a bit first and clean up the code. As you can see a lot of the parts have been rushed, and I am a bit busy with work. But when I finish the major project at work, I’ll clean up the code, and be sure to double test everything properly

But I will do any fixes if anyone finds any issues. So thanks for testing and reporting

1 Like

If you are on windows, try using krita.com instead of the exe in command line

It worked, thank you so much :pray:! (didn’t work with cmd, but it did with powershell). This makes things much easier! :grinning:

Though it may have in the past since I didn’t notice, but it isn’t impossible that I missed it for one of them in a hurry

Probably it may have worked in the past (if I recall correctly, I saw you used it without a problem in your plugin (that’s why I was very confused about what was happening)).

You are welcome, I’m glad I was helpful :slight_smile: If I ever find something else, if you prefer I can open an issue in github if it helps you to have everything more organized there (and if I can tackle any problem I found I can try fixing it by myself if it helps).

I’ve changed the contrast of the print() in the console (because with dark themes was very hard to see):

333796458-f0e16099-0a5d-4928-9208-f9f588da8ac2

Made a little pull request in case you like it and wanted to add it.


Also, I’ve been doing some changes in my fork (they are not in that pull request). But I did an action for executing the dock as a dialog since is my favourite way of using it.

(I have sometimes a problem when the dock is attached to the panels (docked?); when is ‘undocked’ (?), depending on my panels’ position, sometimes it messes the Krita’s UI and I have to manually minimize and maximize krite to set everything correctly). The option to show as Dialog had the problem that when is closed, is docked automatically. I searched in case krita has an option to manually redraw all its interface, but found nothing.

I did an action that triggered the dialog without connecting the close signal to the docking (?) action. I thought it solved that issue, but I tried to modify the code the less as possible, and I noticed that sometimes is still messing with the Krita’s panels (I think is because it is still being added to the UI, at least for a moment).

I’m trying to work on that, but at the moment I had no luck solving it.

2 Likes

You can call an update() on qt widgets. But maybe that isn’t what you are looking for? Are you talking about a layout shift?

It may help if you do a video or screenshot of what you mean. I don’t have an issue here with the dialog on KDE Plasma, it may also be how you have the docker/dialog. So showing what you mean may make it easier to debug.

If you want, you can change the functionality of adding separate button to not float docker. Or set up a dialog that asks if you want it to dock or close

1 Like

Here is a video of what is happening:

(the bottom part of the Krita UI disappears, and some part of the dockers)

I tried calling update() in every docker (and also repaint()) but I had no luck.

Maybe is not a very important issue (it only seems to happen when I have my UI very cluttered with dockers).

Sorry for the delay in getting back, been very busy unfortunately.

I don’t get that here in linux or maybe our ui is different enough that it doesn’t cause problems. What is you saveState and restoreState the mainwindow?

Hey, don’t worry a single bit, is not that is an important bug or anything (again, only happens when the ui is cluttered).

What is you saveState and restoreState the mainwindow?

Excuse my ignorance, but what do you mean? (I googled it but I’m not sure what you mean).

Krita.instance().activeWindow().qwindow().saveState()

You can pretty much force the window to reload itself by saving and restoring state.

1 Like

thank you, didn’t know that. Probably that will solve my issue.

@KnowZero do you know if it is possible to access Krita’s classes inside the PluginDevTools.console.temp.py script used in the console tab?

I mean, for being able to do something like:

do_something_with_a_node(node_to_manipulate:None):
    # now I have autocomplete for node_to_manipulate

(I like to “stick to it” to that script the most I can and then move everything to my plugin, since is faster than adding things to my plugin and restarting Krita over and over)

I tried to generate the PyKrita inside the pykrita folder, but I’m not able to access it.

(Also tried directly copying the content in PyKrita.py to that script but for some reason I don’t know, the script stops working)

You tried adding it to the same path and adding this on top?

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

Thank you so much for the help!

Yes I tried that, but I was having a problem* placing the generated PyKrita.py in pykrita’s folder (next to the console script,also in pykrita folder).
*It was breaking the loading of all plugins in pykrita.

But now is working (I just changed it to a different name and I’m not having that error (I remember doing that, but seems last time I forgot to restart VSCode :face_with_open_eyes_and_hand_over_mouth:)).
Thanks again.

First of all, I love this plugin. Very handy when altering the GUI, you’re a lifesaver!

Is there a way to configure it so it won’t call the open script dialog on every restart?

I failed to find in on the GUI and couldn’t locate any easily accessible config var to turn it off in the plugin files either so I just manually sabotaged the call. :grimacing:

It’d be nice to have a way to properly configure it so I won’t have to worry about reapplying the change when updating.

What do you mean by open scripter dialog every restart?

Every time you start Krita and first interact with the dev tools plugin this dialog will open. No context, just the dialog.

It’s created by the setScriptFile() method @ line 646 of PluginDevToolsWidget.py.

It’s being triggered by a toggle signal first connected to the method @ line 566.

self.caller.centralWidget.consoleSetScriptFileBtn.toggled.connect(self.setScriptFile)

(the quickest way to stop the dialog was to comment this out, preventing the callback from firing)

I couldn’t find the aforementioned button in the GUI nor mentions of it in this thread.

I’m using the flatpak version of Krita on Linux, if that matters.

Okay, I see the problem. I did a fix, try now.

3 Likes

It works! Thank you for taking the time.

Again, amazingly helpful plugin. You’re very kind to have written it and shared with us.

Oh, and I thought the window was by design, sorry about the jumbled initial report. :joy:

I’ve been helping with the Qt6 port of Krita recently, and this plugin has helped me to debug some issues by inspecting the widgets (issues such as widgets being misrendered on macOS and the brush editor being too tall).

That wouldn’t have been possible without my porting the plugin to PyQt6, so I’m sharing my patch for that: Patch to port KnowZero's Krita plugin Python Plugin Developer Tools to PyQt6 ($3399) · Snippets · GitLab

This patch is only useful for testing the Krita 6.0.0-prealpha builds, which are only found on CI (CI pipelines) right now. (PyQt6 support should be in tomorrow’s builds.) I’m not knowledgeable enough about the plugin to test everything, so there may still be some bugs on PyQt6.

5 Likes

Great to hear that it is helping :slight_smile: !

Is the patch backwards compatible with QT5? If so then I can merge it into the original project and then I can handle any issues to QT6 if reported.

1 Like

Yes, it works with both PyQt5 and PyQt6. It’d be great if you could merge it.

1 Like