You are here

GIMP 3.0.6 (revision 1) Python-Fu - my scripts do not appear in GIMP menus

6 posts / 0 new
Last post
pootmonkey
Offline
Last seen: 12 hours 56 min ago
Joined: 2026-01-23 07:57
GIMP 3.0.6 (revision 1) Python-Fu - my scripts do not appear in GIMP menus

GIMP 3.0.6 (revision 1) Python-Fu - my scripts do not appear in GIMP menus.
I'm running it on a Windows 10 laptop, with all updates available up to the end of service date.

(Thanks, John T. Haller -- and everyone else who works on these projects, making great stuff available!!! John, I see your name all over, and in particular for the PortableGIMP project, so that's why I'm thanking you by name.)

The main product page at https://portableapps.com/apps/graphics_pictures/gimp_portable says, "Adding Plugins and Scripts: In a local install of GIMP, user plug-ins and scripts are typically installed to the plug-ins and scripts directories within C:\Users\USER\AppData\Roaming\Gimp\3.0\. In GIMP Portable, these directories would be X:\PortableApps\GIMPPortable\Data\GimpAppData\".

I have a folder named hello_world containing a script hello_world.py placed in F:\GIMPPortable\Data\GimpAppData\scripts . I keep my portable apps placed under my F: root directory, not under a PortableApps directory, and not running from the Portableapps platform.

hello_world.py contents:

#!/usr/bin/env python3

from gimpfu import *

def hello_world():
    pdb.gimp_message("Hello, world!")

register(
    "python_fu_hello_world",                # Unique identifier
    "Hello World",                          # Menu label
    "Displays a 'Hello, world!' message",   # Description
    "Your Name", "Your Name", "2026",       # Author info
    "<Filters>/Hello World",                # Menu path
    "",                                     # Image types the script works on
    [],                                     # Input parameters
    [],                                     # Output parameters
    hello_world                             # Function to be called
)

main()

This is my very first use of Python-Fu. Here are some facts, numbered in case that makes it easier for any later references:

  1. I do remember to quit and restart PortableGIMP after any changes to script or script location.
  2. From what I have read, if there is a syntax error, that would prevent the script from appearing in the menus.
  3. I have tried placing the both *the script* and *the folder and the script inside it* in various directories suggested by web searches, with no success.
  4. I have tried writing just about the simplest script I could, in order to reduce the chances of syntax errors, and reviewed it as best I could without human aid.
  5. I've tried specifying the Menu Path differently to place the script's menu item at the top level and elsewhere.
  6. On that note, I have simply removed the <Filters> portion, and also tried it with /Filters instead, as suggested in one place.
  7. My script does not require any image to be loaded or any tool to be in use; but also, it doesn't appear whether an image is loaded or not, just in case anybody wonders.

I recognize that ...
... My problem might be GIMP-related as opposed to PortableGIMP-related.
... My problem might still be Python-Fu syntax related.
... And it could be something else ...

I'd love to be certain that I'm placing things in the right place, for one. I have even considered writing a VBA script to copy the script and the directory-with-script into EVERY subdirectory of my PortableGIMP installation, with a unique and slight modification to the output message in each instance, to see if ANY of them appear and tell me which one(s).

Other than that, I'm not certain what the problem might be.

I appreciate any help. And any earnest attempts to help Smile .
-- Pootmonkey = )

pootmonkey
Offline
Last seen: 12 hours 56 min ago
Joined: 2026-01-23 07:57
UPDATE: I put the script in every folder; it didn't appear

So, without any response or other ideas, I tried something. I wrote a program to put a copy of [the script and the appropriately-named folder that should contain it] into every subfolder in the program's directory tree; and each script was uniquely-named, and printed its location's full path after "hello world".

Having done that, the script's *location* should not have been a problem, since every single location had a copy of the script. Since I've ruled that out, ...

Can anyone tell me if the script itself has some syntax error that AI and I have not spotted?

With hope and thanks,
-- Pootmonkey = )

Ken Herbert
Ken Herbert's picture
Offline
Last seen: 5 hours 53 min ago
DeveloperModerator
Joined: 2010-05-25 18:19
That looks like a GIMP 2.x

That looks like a GIMP 2.x script, GIMP 3.x doesn't have the "gimpfu" module anymore.

pootmonkey
Offline
Last seen: 12 hours 56 min ago
Joined: 2026-01-23 07:57
Help needed for GIMP 3.6 (revision 1) compatibility

Ah. Thanks, Ken!

Can anyone help by modifying the script for GIMP 3.6 (revision 1) compatibility, by any chance? (I've tried using AI to rewrite it again, but it led me to trying to install PyGObject -- which required other installations and failed at every turn.)

Ultimately, I'll be working on a more complex script, but for now, I'm trying to get ANY Python-Fu script to run just to see that I can -- at all. Hopefully, that will nail down the very basic basics, and then let me try to build out from there.

Ken Herbert
Ken Herbert's picture
Offline
Last seen: 5 hours 53 min ago
DeveloperModerator
Joined: 2010-05-25 18:19
Have a look at this tutorial

Have a look at this tutorial in the GIMP docs. It is exactly what you are looking for.

Complete code is at the bottom, and the rest of it explains the purpose for each line of the code.

I would suggest staying away from standard online AI for Python development. In my experience they have a bad habit of jamming different bits of Python 2 & 3 code together into something that rarely works, even when you specify the version. They only become semi-decent at it when they have been trained specifically on one version or the other.

pootmonkey
Offline
Last seen: 12 hours 56 min ago
Joined: 2026-01-23 07:57
Thank you again. I

Thank you again. I appreciate this just as much as you might imagine -- or more, especially if you imagine I don't or might not ;P . I *do* appreciate being pointed at a tutorial. I was hoping, even with no deadline, to get a good jumping off point from the AI without having to learn from the ground up. In particular, I was hoping to get the calls specific to the parts of GIMP I want to use (using rotate color maps) and basic set-up, since I have other coding experience, including a pretty small amount of straight-up Python.

But after my last message, I went ahead and searched for tutorials and found the one you linked and this other one, and started reading the first. I got notification of your message just as I started GIMP after putting the tutorial's example into place. ... I let it load while reading and typing this reply. The plug-in doesn't show up in the menu, so I'll have to do a little more reading and work.

Part of what I'll need to learn is the difference between plug-ins and scripts. I dropped the subfolder & file into F:\GIMPPortable\Data\GimpAppData\scripts\ -- but maybe it should have gone into the F:\GIMPPortable\Data\GimpAppData\plug-ins directory instead, since after all, the tutorial is titled using "plug-in" and not "script". Testing ... YES! That worked. The 'Tutorial' menu item with its submenu appeared in the Filters menu.

There's a line in there ...
procedure.add_menu_path('<mage>/Filters/Tutorial/')
... and from what I read before -- right or wrong -- the '<Image>' part specifies that an image must be loaded for the plug-in to run; indeed without an image loaded, it does not run. BUT when I remove that or that plus the following slash, the plug-in doesn't appear in the menu at all. I'll want my end plug-in to run without images loaded since it will load a series of images itself, so I will continue my reading and learning, but I'm open to any more outside input.

Once more, thank you, Ken! I appreciate your responding :))) .

EDIT: I replaced some literal angle brackets with the HTML entities in this message so that the "<mage>" portion of my quoted code would be displayed instead of being interpreted as HTML by the website's parser.

Log in or register to post comments