Gimp Python Documentation
Prev |  | Next

# Support Modules

This section describes the modules that help make using the `gimp` module easier. These range from a set of constants to storing persistent data.

## The gimpenums Module

This module contains all the constants found in the header `libgimp/gimpenums.h`, as well as some extra constants that are available in Script-Fu.

## The gimpfu Module

This module was fully described in an earlier section. It provides an easy interface for writing plugins, where you do not need to worry about run_modes, GUI's and saving previous values. It is the recommended module for writing plugins.

## The gimpplugin Module

This module provides the framework for writing Gimp plugins in Python. It gives more flexibility for writing plugins than the gimpfu module, but does not offer as many features (such as automatic GUI building).

To use this framework you subclass `gimpplugin.plugin` like so:

    import gimpplugin
    class myplugin(gimpplugin.plugin):
    	def init(self):
    		# initialisation routines
    		# called when gimp starts.
    	def quit(self):
    		# clean up routines
    		# called when gimp exits (normally).
    	def query(self):
    		# called to find what functionality the plugin provides.
    		gimp.install_procedure("procname", ...)
    	# note that this method name matches the first arg of
    	# gimp.install_procedure
    	def procname(self, arg1, ...):
    		# do what ever this plugin should do

## The gimpshelf Module

This module gives a nicer interface to the persistent storage interface for Gimp plugins. Due to the complicated nature of Python objects (there is often a lot of connections between them), it can be dificult to work out what to store in gimp's persistent storage. The python interface only allows storage of strings, so this module wraps pickle and unpickle to allow persistentstorage of any python object.

Here is some examples of using this module:

    >>> from gimpshelf import shelf
    >>> shelf['james'] = ['forty-two', (42, 42L, 42.0)]
    >>> shelf.has_key('james')
    1
    >>> shelf['james']
    ['forty-two', (42, 42L, 42.0)]

Anything you store with `gimpshelf.shelf` will exist until Gimp exits. This makes this interface perfect for when a plugin is executed with the run mode RUN_WITH_LAST_VALS.

Prev | Home | Next
Gimp Objects |  | End Note