Re: [Gimp-user] Debugging register function for registration of a python plugin under Windows XP



On 14/06/14 17:54, SeldomNeedy wrote:
Debugging register function for registration of a python plugin under Windows XP

Hey, all.

I've started writing plugins in Python for GIMP but have so far only been able
to successfully register a plugin via the following form:

# in C:\Program Files\GIMP 2_8\lib\gimp\2.0\plug-ins
# synch-current-frame.py

def synch_current_frame(*args):
         # code
         return

register("synch_current_frame",
          N_("Adjust layers to the current animation-frame."),
          howTo,
          "Needthistool",
          "Needthistool",
          "June 2014",
          N_("_Synchronize Layers to Current Frame"),
          "",
          [],
          [],
          synchronize_to_frame,
          menu="<Toolbox>/Layer/Stack",
          domain=("gimp20-python", gimp.locale_directory)
          )
main()

Changing the leading category from "<Toolbox>" to "<Image>" or "<Layer>" seems
to immediately break something and cause GIMP to skip over the script, as does
adding tuples to describe parameters to the first list.

I'm aware that Linux users can see what errors are raised by register during
startup but I'm not aware of how to do this with Windows. The Error Console and
builtin Python shell seem only to display errors from plugins that are able to
first load in correctly and show no record of what GIMP did while it was
loading. After I'm past that, things are straight-forward, but at present I have
no idea what I'm doing right or wrong as I register a function and currently
have to "pass" parameters to plugins in some awkward ways, unable to achieve
gimpfu registration with parameters. To avoid this, I need to debug the register
function's registration, which happens at startup, where errors are hidden.

How do I avoid flying blind on Windows (XP) with GIMP 2.8.8?

Thanks,
- Seldom


traceback (most recent call last):
  File "/home/me/.gimp-2.8/plug-ins/badone.py", line 7, in <module>
    register("synch_current_frame",
NameError: name 'register' is not defined


In practice you are missing "from gimpfu import *" at the beginning of the file.

Additionally, <Toolbox> is deprecated (since at least Gimp 2.6). you should be putting your menu entry in "<Image>" (the window displaying the current image), or in "<Layers>" (the right-click menu in the layers list), but the latter requires your plug-in to take image and drawable parameters.

Debugging Python plugins under Windows isn't too easy. I just made a small write-up on the subject:

http://gimpforums.com/thread-debugging-your-python-scripts-using-the-python-fu-console



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]