Gimp-Forum.net
plugin help: not appearing in gimp - 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)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: plugin help: not appearing in gimp (/Thread-plugin-help-not-appearing-in-gimp)



plugin help: not appearing in gimp - gimpygirl - 02-29-2024

Hi

What's wrong with this code and why does it not appear in GIMP?
What needs to be changed to make it work?


Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
from gimpfu import*



def test(timg, tdrawable):

   print_to_stderr("Hello World")

def print_to_stderr(*a):

   print(*a, file=sys.stderr)
   
   
   
register(
       "test",
       "test",
       "test",
       "test",
       "test",
       "2024",
       "<Image>/Tools/test...",
       "*",
       [],
       [],
       test
       )

main()



RE: plugin help: not appearing in gimp - Adaddinsane - 03-02-2024

Using tabs and not spaces?

(As a gimp/python newbie who suffered for several days with scripts randomly appearing and disappearing from the menu, and also not realising comments need to be indented too)


RE: plugin help: not appearing in gimp - Ofnuts - 03-02-2024

Which is why the first thing to do is to run the script in  command prompt outside of Gimp (yes, it' easier to do on Linux/OSX, but it can also be done in Windows):

Bad code, will definitely not run when Gimp tries to make it register:
Code:
$python ggtest.py
 File "ggtest.py", line 40
   gimp.message(e.args[0])
   ^
IndentationError: unexpected indent

Worth trying (doesn't mean there are zero errors, but these will show when the script is used):
Code:
$python ggtest.py
Traceback (most recent call last):
 File "ggtest.py", line 5, in <module>
   from gimpfu import *
ImportError: No module named gimpfu
This is also why it is important to use an adequate editor, that won't try to "help".