Gimp-Forum.net
GIMP V2.99.4 Flatpak Python Issue - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+--- Thread: GIMP V2.99.4 Flatpak Python Issue (/Thread-GIMP-V2-99-4-Flatpak-Python-Issue)

Pages: 1 2


GIMP V2.99.4 Flatpak Python Issue - programmer_ceds - 04-22-2021

I have installed V2.99.4 flatpak and can run this or V2.10.24 as I wish but not quite in the way suggested where you have to use a flatpak command to select the version that is to be run (beta or stable). If I use the command to select the beta version the Menu/Graphics/GNU Image Manipulation Entry always starts V2.10.24. To start V2.99.4 I have a bash script. I'm not sure that this is relevant to the issue noted below.

When I start V2.99.4 in a terminal window I see the following error message:

Gtk-Message: 17:32:23.772: Failed to load module "xapp-gtk3-module"

So far as I can tell I have this module installed (file usr/lib/x86_64-linux-gnu/gtk-3.0/modules/libxapp-gtk3-module.so exists)

I have also taken the text for the Python Goat exercise and renamed all occurrences of 'goat' to 'goatee' and placed the file in a subfolder of the user plug-ins folder but it doesn't appear in the GIMP menus. Initially I made the mistake of placing it directly in the plug-ins folder and received a warning from GIMP - so it is looking in the user plug-ins folder.

The latest version of the python goat exercise script, as downloaded from the gitlab site, contains statements that it relies on Gimp 3.0 and GimpUi 3.0 - I have tried changing these to 2.99 since that is the beta version - this had no effect.

Has anybody else had more success in this respect?

I thought I would go through the scripts that I have written and those that I have downloaded from elsewhere and update them for GIMP 3 if I could (starting off by running them in V2.10.24 with the --pdb-compat-mode=warn option to report deprecated scripts). I have successfully updated all the .scm files - some run without a problem but many fail with the (known) error message about GimpObjectArray being an unknown return type - I think I just have to retest these when V2.99.6 becomes available. However, as noted above I have hit a problem with the .py files.


RE: GIMP V2.99.4 Flatpak Python Issue - Ofnuts - 04-22-2021

AFAIK the API in Gimp3 is very different. The Gimp2 PDB was mostly a way to mimic the Scheme API but it is removed in Gimp3 (instead you talk more directly to the Gimp and Gegl APIs, but the objects classes have a much more complete set of methods). So the rewrite effort comes more from the Gimp2 ➤ Gimp3 change than from the Python2 ➤ Python3 one.

My main worry is that AFAIK you no longer have the auto-generated parameter dialogs, so you have to cook up your own dialog for every plugin you create and this can take a lot more time than writing the plugin code itself. One of the devs mentioned that there will be specialized widgets to display Gimp-specific data (active images, layers, brushes, etc...) but I have not yet seen some example code for this (but I haven't refreshed my Gimp3 for a while).

Also, one wonders about built-in Python support in Windows....


RE: GIMP V2.99.4 Flatpak Python Issue - programmer_ceds - 04-22-2021

(04-22-2021, 08:08 PM)Ofnuts Wrote: AFAIK the API in Gimp3 is very different. The Gimp2 PDB was mostly a way to mimic the Scheme API but it is removed in Gimp3 (instead you talk more directly to the Gimp and Gegl APIs, but the objects classes have a much more complete set of methods). So the rewrite effort comes more from the Gimp2 ➤ Gimp3 change than from the Python2 ➤ Python3 one.

My main worry is that AFAIK you no longer have the auto-generated parameter dialogs, so you have to cook up your own dialog for every plugin you create and this can take a lot more time than writing the plugin code itself. One of the devs mentioned that there will be specialized widgets to display Gimp-specific data (active images, layers, brushes, etc...) but I have not yet seen some example code for this (but I haven't refreshed my Gimp3 for a while).

Also, one wonders about built-in Python support in Windows....

Assuming that V2.99.4 is representative of V3.x.x then there is little problem with .scm scripts - the main change being that the scripts and the menu entries have to be registered separately. The auto-generated UI dialog is still present (I have seen erroneous posts on other sites that suggest that this is not the case). Also the .scm files that have been updated for V2.99.4 still run on V2.10.24 - so no need to maintain two versions. (There was one script that needed code to check the GIMP version and then to use gimp-procedural-db-proc-exists in V2.10 and gimp-pdb-proc-exists in V2.99.x/V3.x.x but in all of the other scripts the same functions applied to both V2.10 and V2.99)

The Goat exercise Python code provides an example of how to generate the dialog and how to call GIMP functions and I was assuming that as it was provided as an example it would work - which leads me to suspect that either I haven't installed V2.99.4 flatpak correctly (although I followed the instructions provided by GIMP) or that the flatpak version doesn't support Python.


RE: GIMP V2.99.4 Flatpak Python Issue - Ofnuts - 04-22-2021

The Goat exercise works for me (self-compiled 2.99). Looking at the code it references (but doesn't seem to use) a GimpUi module and names in this module makes me think it contains widgets for UIs (BrushSelectButton for instance).


RE: GIMP V2.99.4 Flatpak Python Issue - programmer_ceds - 04-23-2021

(04-22-2021, 10:18 PM)Ofnuts Wrote: The Goat exercise works for me (self-compiled 2.99). Looking at the code it references (but doesn't seem to use) a GimpUi module and names in this module makes me think it contains widgets for UIs (BrushSelectButton for instance).

The Goat/Python exercise accessed by using "Filters/Development/Goat exercises/Exercise a goat and a python" works as it should but if I put the latest code for this (from the link in that function) into a subfolder of plugins, rename every occurrence of Goat (apart from the folder location for the script) to be Goatee the edited script doesn't show up.

I'm wondering whether the flatpak includes python 3 support.


RE: GIMP V2.99.4 Flatpak Python Issue - Ofnuts - 04-23-2021

Start Gimp from the terminal and check for errors in the console output. Also check that the Python file is executable. If the Goat exercise works in the Flatpak, then the flatpak has what it needs for the Python support.


RE: GIMP V2.99.4 Flatpak Python Issue - programmer_ceds - 04-23-2021

(04-23-2021, 04:46 PM)Ofnuts Wrote: Start Gimp from the terminal and check for errors in the console output. Also check that the Python file is executable. If the Goat exercise works in the Flatpak, then the flatpak has what it needs for the Python support.
The only error that is shown in the console is the failure to load xapp-gtk3-module.

What I have tried doing is to copy and paste the code for the script (edited to change goat to goatee) into the Python-Fu console. There is an unexpected indentation at line 50 - the return for the do_query_procedures function. I'm not a Python expert (yet!) but it is indented with the same number of spaces as line 47 - I deleted the indents and recreated them by typing the exact same number of spaces in each.

I'm not sure what is going on but its time to call it a day now. Thanks for your replies.


RE: GIMP V2.99.4 Flatpak Python Issue - programmer_ceds - 04-25-2021

I found the solution in the end - I knew that for GIMP V2.99.x plugins have to go into subfolders - I hadn't realised that the name of the subfolder has to be exactly the same as the (in this case) Python script file name (without the extension) - if this is not the case then the script doesn't appear in the menus or the PDB.

It looks as though there might be an exception to this using a metadata xml file since the Goat exercises do this - this then allows for having more than one plugin in a subfolder. However, I couldn't find the right form of words to edit this file so that I could have different names for the subfolder and Python script (no real need to do this - just for interest).

So now I can get on with porting the few Python scripts that I use.

(This means, of course, that it is possible to run user defined Python scripts in V2.99.4 flatpak - everything that is needed for this is present)


RE: GIMP V2.99.4 Flatpak Python Issue - Ofnuts - 04-25-2021

(04-25-2021, 04:43 PM)programmer_ceds Wrote: I found the solution in the end - I knew that for GIMP V2.99.x plugins have to go into subfolders - I hadn't realised that the name of the subfolder has to be exactly the same as the (in this case) Python script file name (without the extension) - if this is not the case then the script doesn't appear in the menus or the PDB.

A possible reason is that you can deliver the plugin as several files (in Python you would use imports), and Gimp has to know which one is the main.


RE: GIMP V2.99.4 Flatpak Python Issue - programmer_ceds - 04-26-2021

(04-25-2021, 04:59 PM)Ofnuts Wrote: A possible reason is that you can deliver the plugin as several files (in Python you would use imports), and Gimp has to know which one is the main.

Makes sense.