My plugin is not showing up in GUI, why?

I have just started scripting in GIMP. I’m following a tutorial and below is my hello world script:

from gimpfu import *

    "Hello World image", "Create an image with user-passed string",
    "Santosh Kumar", "Santosh Kumar", "2018",
    "Hello world...",
        (PF_STRING, "string", "String", "Hello, World!"),
        (PF_FONT, "font", "Font face", "Sans"),
        (PF_SPINNER, "size", "Font size", 50, (1, 3000, 1)),
        (PF_COLOR, "color", "Text color", (1.0, 1.0, 1.0)),
    hello_world, menu="<Image>/File/Create"


def hello_world(initstr, font, size, color):
    if font == "Comic Sans MS":
        initstr = "Comic Sans? Really?"
    img = gimp.Image(1, 1, RGB)


    layer = pdb.gimp_text_fontname(img, None, 0, 0, initstr, 10, True, size, PIXELS, font)
    # resize the img to the width and height of text layer
    img.resize(layer.width, layer.height, 0, 0)


hello_world("Hello, World!", "Comic Sans MS", 72, "#ffffff")

Well, I’m on Windows, with GIMP version 2.10.2, and I’m pushing this script to C:\Users\<my name>\AppData\Roaming\GIMP\2.10\plug-ins.
I’m sure this plugin is loading at least. Because it shows up on the splash screen. I don’t know where do I find it. I expect it to be on Image menu, but it’s not there. :thinking:

What wrong have I done?

Here’s a hint for debugging, Add this to the top of your code and make sure you have a C:/tmp directory or change it to suit a location you actually have.

 sys.stderr = open("C:/tmp/gimp_python_errs.txt",'a')

 print("Hello World")

Then you’ll see the following:
Hello World Traceback (most recent call last): File "C:\Users\brmp68\AppData\Roaming\GIMP\2.10\plug-ins\", line 21, in <module> hello_world, menu="<Image>/File/Create" NameError: name 'hello_world' is not defined

As you’ve got things in the wrong order, you need to do the def hello_world before the register.

(And how am I supoposed to insert code blocks into posts here?)

1 Like

Thanks for the support @paynekj I’ll keep coming back to this post for next few times. :sweat_smile:

Write down your code, select the code, and press Ctrl+Shift+C. Or simple press the icon beside the quote in the composer.