Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
plugin help: not appearing in gimp
#1
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()
Reply
#2
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)
Reply
#3
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".
Reply


Forum Jump: