Plugin: Theme Creator Extension

Theme Creator: This plugin allows to create a basic version of a color Theme file,
with (not completely accurate) previewing of it while choosing colors.

Creating the theme by picking colors, and previewing their effect:

The preview is inaccurate because it won’t update all widgets or properly reflect the colors for selected/disabled states, and it doesn’t account for special blending effects.
The resulting exported theme’s actual appearance (after restarting Krita, choosing it
from Settings->Themes, then restarting again to make sure everything updates):


Note that the selected tool’s icon is now purple, the selected layer’s purple is subtly blended with the darker green behind it, and the Advanced Color Selector and status bar angle selector’s backgrounds are now recolored.

See the manual for more details.

Links:

Code repository: Freya Lupen / Theme Creator Extension · GitLab
Zip file download: https://invent.kde.org/freyalupen/theme-creator-extension/-/archive/master/theme-creator-extension-master.zip

80 Likes

I just downloaded and got done playing around with this a
bit and so far really happy with the first results so far :smiling_face_with_three_hearts: Thanks so much for sharing this



figured itd be fun to start seeing people upload what colors they might try :slight_smile:

3 Likes

This is awesome! Wish this was made sooner, I only just finished my themes lmao. Here’s one I put together while playing around with this tool


download

14 Likes

You truly made god’s job. Can’t wait to try it out once I get home :>

1 Like

:slight_smile: Hello @thejoyofpainting, and welcome to the forum!

Since you forgot to tell us such elementary hints as the operating system you are using and the version of Krita, I can only answer the middle part of your question in general terms.
The other parts of your questions are probably best answered from @freyalupen, since freyalupen made this and is the one who knows it best.

In case you are using the Windows installer version of Krita, you will find the Krita color themes directory in the folder "c:\Program Files\Krita (x64)\share\color-schemes". However, if you are using the portable version, it is there in the folder "[ROOT OF YOUR UNZIPPED PORTABLE KRITA]\share\color-schemes".

Since the AppImage version is a kind of all-containing and all-executable archive, a kind of “black box”, you won’t be able to get to that directory there easily - usually not at all. With the versions from the repositories of the different distributions, it should be possible to find it in the same path structure as under Windows - only that the path there does not start with “c:\Program Files\Krita (x64)\”, but follows the Linux structures - if the maintainers of these versions stick to these structures. Unfortunately, the versions from the repositories are often compiled incorrectly.

For macOS, if I should be correctly informed, it is the same as for Linux, I call it an “Apple version” of AppImage as for Linux, here the same will apply as for Linux, if my assumption about the DMG files is correct.

Michelist

1 Like

Some of the properties aren’t easy to create a preview of the effects of, and some aren’t used by Krita. The plugin only writes the properties it understands because it’s simpler that way. In the future I may add writing of the default values.

Modifying an existing theme file would be tricky, because it requires being able to parse it. It’s something I don’t have much experience with doing, but I intend to look into it.

I managed to find KFrameworks’ KConfig parsing code and adapt it to Python (.colors files are KConfigs just like the kritarc file is), so I was able to implement theme loading/saving:

I’ve updated the plugin, the latest version can be downloaded from the links in the first post.

Changes:

  • The color text inputs now accept colors formatted like 255,255,255.
  • Loading and resaving theme files is now supported; in other words you can now modify existing themes directly, instead of needing to manually copy unsupported properties. When no theme file has been loaded, one containing default values will be used.
6 Likes

Hi, excuse me but i followed the steps and this happen :frowning:

What can i do?

AttributeError
Python 3.8.1: C:\Program Files\Krita (x64)\bin\krita.exe
Tue May  2 23:40:36 2023

A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.

 C:\Users\CutieMonts\AppData\Roaming\krita\pykrita\theme_creator\theme_creator.py in openDialog(self=<theme_creator.theme_creator.Theme_creator object>)
  149     def openDialog(self):
  150         if self.firstRun:
  151             self.initialize()
  152         self.showDialog()
  153 
self = <theme_creator.theme_creator.Theme_creator object>
self.initialize = <bound method Theme_creator.initialize of <theme_creator.theme_creator.Theme_creator object>>

 C:\Users\CutieMonts\AppData\Roaming\krita\pykrita\theme_creator\theme_creator.py in initialize(self=<theme_creator.theme_creator.Theme_creator object>)
  156         self.firstRun = False
  157 
  158         self.currentFolder = Application.getAppDataLocation() + "/color-schemes"
  159 
  160         self.newColors = [0 for i in range(len(PALETTE_VALUES))]
self = <theme_creator.theme_creator.Theme_creator object>
self.currentFolder undefined
builtinApplication = <PyKrita.krita.Krita object>
Application.getAppDataLocation undefined
AttributeError: 'Krita' object has no attribute 'getAppDataLocation'
    __cause__ = None
    __class__ = <class 'AttributeError'>
    __context__ = None
    __delattr__ = <method-wrapper '__delattr__' of AttributeError object>
    __dict__ = {}
    __dir__ = <built-in method __dir__ of AttributeError object>
    __doc__ = 'Attribute not found.'
    __eq__ = <method-wrapper '__eq__' of AttributeError object>
    __format__ = <built-in method __format__ of AttributeError object>
    __ge__ = <method-wrapper '__ge__' of AttributeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of AttributeError object>
    __gt__ = <method-wrapper '__gt__' of AttributeError object>
    __hash__ = <method-wrapper '__hash__' of AttributeError object>
    __init__ = <method-wrapper '__init__' of AttributeError object>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of AttributeError object>
    __lt__ = <method-wrapper '__lt__' of AttributeError object>
    __ne__ = <method-wrapper '__ne__' of AttributeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of AttributeError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of AttributeError object>
    __repr__ = <method-wrapper '__repr__' of AttributeError object>
    __setattr__ = <method-wrapper '__setattr__' of AttributeError object>
    __setstate__ = <built-in method __setstate__ of AttributeError object>
    __sizeof__ = <built-in method __sizeof__ of AttributeError object>
    __str__ = <method-wrapper '__str__' of AttributeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = False
    __traceback__ = <traceback object>
    args = ("'Krita' object has no attribute 'getAppDataLocation'",)
    with_traceback = <built-in method with_traceback of AttributeError object>

The above is a description of an error in a Python program. Here is
the original traceback:

Traceback (most recent call last):
  File "C:\Users\CutieMonts\AppData\Roaming\krita\pykrita\theme_creator\theme_creator.py", line 151, in openDialog
    self.initialize()
  File "C:\Users\CutieMonts\AppData\Roaming\krita\pykrita\theme_creator\theme_creator.py", line 158, in initialize
    self.currentFolder = Application.getAppDataLocation() + "/color-schemes"
AttributeError: 'Krita' object has no attribute 'getAppDataLocation'

@Cutie_Monts That error means you’re using a version of Krita older than 5.1.0, where a function the script uses wasn’t added yet. I’ve pushed a fix to work around that, so if you redownload the plugin it should work now.

ohhhhhh, omg thanks you!!

I’m lost on how to get the plugin uploaded to the program. I’ve already downloaded the zip file and I’ve read the manual in there, but I’m still confused on what to do. Can someone help me?

:slight_smile: Hello @prim, and welcome to the forum!

The easiest way to install plugins in Krita is to open the menu “Tools” hoover “Scripts” and click on “Import Python Plugin from File…”, in the dialog that opens, you have to specify the path to the plugin (the ZIP-File you just downloaded), select the ZIP-File and confirm your selection, confirm the next dialog box as well, then restart Krita, and it should be found in Krita via the menu ‘‘Tools’’ → ‘‘Scripts’’ under ‘‘Theme Creator’’.
Sometimes you may need to activate a plugin before the first usage, to activate you have to open the menu ‘‘Settings’’ → ‘‘Configure Krita’’ → ‘‘Python Plugin Manager’’ and set a checkmark in front of the plugin to activate. After you have set this checkmark, you need a second restart of Krita to be able to use the plugin.

If you should have further questions, feel free to ask.
In case these questions are for different issues than the installation or usage of this plugin, and also not belong to another resource offered here in the forum, where you could ask for support for that particular resource, I ask you to create a new topic in an appropriate category of the forum and ask these questions there.

Michelist

7 Likes

Thank you!! The first method worked.

2 Likes

got error on kripta 5.3 pre alpha 2220 version. this is the message:
RuntimeError
Python 3.10.7: C:\Program Files\Krita (x64)\bin\krita.exe
Sat Sep 16 13:44:41 2023

A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.

C:\Users\harry\AppData\Roaming\krita\pykrita\theme_creator\theme_creator.py in openDialog(self=<theme_creator.theme_creator.Theme_creator object>)
150 if self.firstRun:
151 self.initialize()
152 self.showDialog()
153
154 # Set up things only when the dialog is opened for the first time.
self = <theme_creator.theme_creator.Theme_creator object>
self.showDialog = <bound method Theme_creator.showDialog of <theme_creator.theme_creator.Theme_creator object>>

C:\Users\harry\AppData\Roaming\krita\pykrita\theme_creator\theme_creator.py in showDialog(self=<theme_creator.theme_creator.Theme_creator object>)
263
264 def showDialog(self):
265 self.dialog.show()
266
267 # – Painting –
self = <theme_creator.theme_creator.Theme_creator object>
self.dialog = <PyQt5.QtWidgets.QDialog object>
self.dialog.show =
RuntimeError: wrapped C/C++ object of type QDialog has been deleted
cause = None
class = <class ‘RuntimeError’>
context = None
delattr = <method-wrapper ‘delattr’ of RuntimeError object>
dict = {}
dir =
doc = ‘Unspecified run-time error.’
eq = <method-wrapper ‘eq’ of RuntimeError object>
format =
ge = <method-wrapper ‘ge’ of RuntimeError object>
getattribute = <method-wrapper ‘getattribute’ of RuntimeError object>
gt = <method-wrapper ‘gt’ of RuntimeError object>
hash = <method-wrapper ‘hash’ of RuntimeError object>
init = <method-wrapper ‘init’ of RuntimeError object>
init_subclass =
le = <method-wrapper ‘le’ of RuntimeError object>
lt = <method-wrapper ‘lt’ of RuntimeError object>
ne = <method-wrapper ‘ne’ of RuntimeError object>
new =
reduce =
reduce_ex =
repr = <method-wrapper ‘repr’ of RuntimeError object>
setattr = <method-wrapper ‘setattr’ of RuntimeError object>
setstate =
sizeof =
str = <method-wrapper ‘str’ of RuntimeError object>
subclasshook =
suppress_context = False
traceback =
args = (‘wrapped C/C++ object of type QDialog has been deleted’,)
with_traceback =

The above is a description of an error in a Python program. Here is
the original traceback:

Traceback (most recent call last):
File “C:\Users\harry\AppData\Roaming\krita\pykrita\theme_creator\theme_creator.py”, line 152, in openDialog
self.showDialog()
File “C:\Users\harry\AppData\Roaming\krita\pykrita\theme_creator\theme_creator.py”, line 265, in showDialog
self.dialog.show()
RuntimeError: wrapped C/C++ object of type QDialog has been deleted

Seem this error happens if you have multiple windows open and close the one Theme Creator was originally opened in. I didn’t design this extension with multiple windows in mind, so it behaves a bit weirdly in that case.
I’ll do some investigation on how to fix the error, and think about how multiwindow behavior should work as well. Thanks for the report.

2 Likes

thank you for responding, can you upgrade the plugin to start automatically? and add customization for slide bar color?

Honestly, this feature is something I’ve been dreaming of for a long time, and it’s really awesome :kiki_star_stuck:

(normal display will appear like the screenshot above)
of the 3 themes I created I experienced something strange with this one theme, namely when I open another window or application, then the theme display behind it the saturation will increase, like the screenshot below


please feel free to try it :point_right: download
if it only happens on my device or you also experience the same thing.

There are a few issues with this plugin that I’m experiencing on my device running Krita 5.2.0 on Linux mint 21.2 Cinnamon. That is, every time I save a new theme, it is not in .colors format so it will not appear in the krita theme selection, but I have to manually search for the newly created theme file in the krita folder (color-schemes) and rename it by adding .colors at the end of the file. And finally the theme I created can appear in the theme selection.
:kiki_smile:

2 Likes

Thank you for sharing!

Michelist

1 Like

@Iruhas It seems that blindingly saturated pink is caused by the ColorEffects in the theme. You can open the theme in a text editor and remove the [ColorEffects:Inactive] section, or try modifying those values for a different effect. Unfortunately the plugin can’t preview those effects, so you’d have to restart Krita to test those.
I might have to double check if the default values the plugin uses there are correct…


Do you mean that the file extension is not automatically added? It should work if you type it in manually. (Unless you’re using an OS-native file dialog and it does something weird, I guess.)


  • I’ve just pushed an update to automatically add the .colors extension if it wasn’t typed in when saving with the Qt file dialog.
  • And also, a fix for an issue I noticed on Linux where the Theme Creator dialog would hide behind the Krita window after closing the save message. Although, I should probably just make the dialog always stay on top. (The dialog still hides on macOS, but if the Brush Editor is anything to go by, keeping it on top there may be difficult.)
  • I’ve yet to rework the multiple window behavior. There’s a few other things that could probably use refactoring as well.
2 Likes