Overview of scripting in Krita. Go over the Scripter tool for writing and executing basic scripts
Welcome to the wonderful world of scripting Krita. Scripting allows you to add features and modify many many areas in the Krita application. These are some of the benefits of scripting vs. trying to be a hardcore Krita developer
This all means that it is easy to get started without a lot of technical knowledge. Let's see where we will be doing all our work in.
Tip
There are some things scripting won't be able to do. With the help of the Krita community and Krita developers, new things are getting added all the time.
Open Krita and there will be an option on the main menu Tools > Scripts > Scripter. A window will appear
This is what we will refer to as “Scripter”. The top text area is where we will be writing code. The bottom area is where we can see the results and test things with the Output tab.
If the top code part is white and you want to change the style like my image. This is done from the scripter main menu. From the Scripter menu, go to File > Settings. There is an area called “Syntax Style”. The one I am using is called BreezeDarkSyntaxStyle. The window will update immediately as you change styles. There is no save button to confirm. This setting will be remembered the next time you start Krita, so you shouldn't have to change it again.
In the top area type the following:
To run this, you need to press the play button in the toolbar. Press that and you should see the output like below.
The print() function will output something to the Output area. This will be used in the future a lot when we want to see how our script is behaving. The warning in the output is ok. It means that this script that we have is not saved anywhere. If we were to close Krita and open it later, we would lose our scripting.
You can load and save scripts from Scripter's main menu. There are a few options that you have available from the File menu in scripter.
When you are saving and loading files, the common file format that is used is a “py” file. When you save a script it might be called something like “my-custom-scripts.py”. The py extension is meant to communicate that this is a Python file.
In this lesson we learned a bit about why scripting is a good alternative for doing modifications to Krita. We also learned where to write scripts, how to customize the scripting window, run a script, and how to load and save script files.
Head to the Krita artists where we have a dedicated area for plugin development and give any feedback you might have.