Hi all.
I was just curious, is there any resource online that contains a complete PyGimp API spec? That is, a resource that shows the syntax, parameters and return values for each of the functions available for interfacing with GIMP through Python?
For example, look at the register function. Without knowing exactly what parameters are defined within the function declaration, how is a newcomer to working with PyGimp supposed to know what arguments to pass to it? How are we supposed to debug any errors?
If anyone can point me towards a good PyGimp developers resource, that'd be great.
Cheers
PyGimp documentation
You are not the only one, look here to start with.
http://www.gimp.org/docs/python/index.html
Use the introspection
I've been told the best and most up to date documentation is in the code it self, which you can get via python's introspection feature.
Open the console and type:
help(gimp)
-Rob A>
Gimp API, using Python help()
Clarifying:
In GIMP, choose Filters/Python-Fu/Console.
Then enter:
help(gimp)
Or enter:
import gimpfu
help(gimpfu)
Or not so interesting, the other GIMP Python modules (gimpenums and gimpshelf and gimpplugin.)
gimpenums: useful GIMP constants
gimpshelf: helps a plugin keep persistent data (between GIMP sessions.)
gimpplugin: an alternative to gimpfu, if you need low-level, more detailed access for plugin creation for plugins of type EXTENSION or TEMPORARY
gimpfu is what most plugin writers will use. It imports gimp and defines an alias "pdb" to gimp.pdb.
The help you get from help(gimp) or similar could be better. The help is generated (by a program) from the Python code itself (mostly not edited by a human technical writer.) Some of it comes from the docstrings (comments in certain positions in the Python code) that are supposed to document the code. The docstrings in Python Gimp (gimp, gimpfu, etc.) are sparse or sloppy (for example they include the license, which they should not.)
Note you can't usefully import a plugin and call help() on it.
For example:
import foggify
crashes the GIMP Python console.
(I proposed a patch to Python GIMP that would prevent this crash, on the gimp-dev mailing list, but received a luke-warm response.)
Also, in the GIMP Python console, the PATH environment variable is not set so your personal plugins (the ones you have downloaded or are writing yourself) are found. Try:
import sys
print sys.path
it won't include for example ~/.gimp-2.6/plug-ins (the hidden file in your home directory on some Linux distributions where your personal GIMP plugins are installed.) You can set the path yourself.
Gimp API, using Python help()
You are right the help you get from help(gimp) or similar could be much better and that makes it very difficult for 'newbees' (like me) to write a plugin. Oke I've partly rewritten the contactsheet plugin with gimpfu. Now I'm rewriting the GUI because it's growing too big, with Glade and gimpplugin. Look at the help(gimpplugin) I can do nothing with that I've spend days to find something usefull, even on this forum I got no response on my topic: http://registry.gimp.org/node/23674. At the end I found something useful on a German forum (schumaml. Lucky I can read German; http://www.gimpforum.de/showthread.php?t=9287). At the moment the new design is partly working but.....still a lot of questions left.
A few questions have been answered now but were do I found something about a variable containing the userdir or homedir?? The problem you described with sys was indeed one of my problems.
So I'm looking for examples especially with "Glade". I have already read a lot of python plugins on this registry and I already found usefull commands I could use.