You are here

Python-Fu: Implicit image and layer parameters in the register() function


I'm trying to scramble info to make a tutorial about creating Python-Fu plugin. I am myself just making my first steps in this, but, seeing how hard it is to gather decent help online, I feel I could help other wanna-bees like myself.

So, one of the things I have stumbled upon, is that the register() function can be called in several different ways. I'd like to understand, if some of those ways are now (Gimp 2.6.10) considered deprecated:

First, register with explicit image and layer parameters:

pluginFn (img, layer):
"Experimental Python plugin",
"Experimental Python plugin, long description",
"Author name",
"Copyright holder",
"Experimental Python plugin",
(PF_IMAGE, "img", "Input image", None),
(PF_DRAWABLE, "layer", "Input drawable", None)

However, in some plugins I see another working approach:

"PythonFu_plugin_test", # Plugin name
"Experimental Python plugin", # blurb
"Experimental Python plugin, long description", # help
"Author name", # Author
"Copyright holder", # Copyright
"2011", # Date
"/Filters/Experimental Python plugin", # Menu path and item
"*", # Image typesdefinition
[], # Parameters
[], # Results
pluginFn # Function

If I'd remove the two parameters from the fist register call, I'd get an error, complaining that 2 parameters are expected but 0 are passed. Interestingly, the only difference between the two calls is that full path to the menu item is included in the value of 7th parameter, and the assignment of named menu parameter is removed.

Is somewhere a full, detailed description of the register() function parameters available? For example, how the results parameter is used. Also, detailed info about the parameter types would not hurt. But, if such thing doesn't exist, I am ready to write a tutorial, using trial-error approach. Kind of silly, but better than nothing.

I know its been like a year, but here's an answer anyway:
The most comprehensive documentation you can get is the actual code in gimpfu, which can be found in in
\GIMP 2.7\lib\gimp\2.0\python

But if you want to see the generated documentation (from the docstrings):
In gimp, open the python console from the menu filters->python-fu->console
then type 'import gimpfu', then 'help(gimpfu)'
You can also save the contents of the console to look through later.

Subscribe to Comments for "Python-Fu: Implicit image and layer parameters in the register() function"