Revised version attached.
On Mon, Sep 29, 2008 at 3:37 AM, Sven Neumann <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I would very much welcome if you could change the call to
> gimp.install_procedure() to not pass the full menu path. The procedure
> is supposed to be passed the menu label only. There's a seperate
> procedure to register the menu entry: gimp.menu_register().
>
>
> Sven
>
>
>
#!/usr/bin/env python
# 9/14/2008 - Greg MacDonald
# This is an example gimp python plugin template. It demonstrates how to
# create two different types of plugins; an image plugin, and a toolbox
# plugin. The toolbox plugin only takes a run_mode parameter, while
# the image plugin takes a run_mode parameter as well as an image and
# drawable paramter.
#
# The example also shows how to use logging. This is useful for "printf"
# debugging when running in interactive mode as print statements don't seem to
# output to the console. They do however in batch mode.
#
# Batch mode is also demonstrated with a mechanism to run a command in batch
# mode if this file is run from the command line: "python
gimp_plugin_template.py".
#
# If an exception occurs during plugin execution, a stack trace is sent to the
log.
try:
import gimp
except:
if __name__ == '__main__':
import os
cmd = 'gimp-2.4 --console-messages --verbose --no-data
--batch-interpreter python-fu-eval --no-interface --batch
"pdb.toolbox_go(RUN_NONINTERACTIVE)" --batch "pdb.gimp_quit(0)"'
os.sys.exit(os.system(cmd))
else:
raise
import gimpplugin
from gimpenums import *
pdb = gimp.pdb
import logging
FORMAT = '%(lineno)d:%(levelname)s %(asctime)s : %(message)s'
# Other logging format options:
#%(name)sName of the logger (logging channel).
#%(levelno)sNumeric logging level for the message (DEBUG, INFO,
WARNING, ERROR, CRITICAL).
#%(levelname)sText logging level for the message ('DEBUG', 'INFO',
'WARNING', 'ERROR', 'CRITICAL').
#%(pathname)sFull pathname of the source file where the logging call
was issued (if available).
#%(filename)sFilename portion of pathname.
#%(module)sModule (name portion of filename).
#%(funcName)sName of function containing the logging call.
#%(lineno)dSource line number where the logging call was issued (if
available).
#%(created)fTime when the LogRecord was created (as returned by
time.time()).
#%(relativeCreated)dTime in milliseconds when the LogRecord was
created, relative to the time the logging module was loaded.
#%(asctime)sHuman-readable time when the LogRecord was created. By
default this is of the form ``2003-07-08 16:49:45,896'' (the numbers after the
comma are millisecond portion of the time).
#%(msecs)dMillisecond portion of the time when the LogRecord was
created.
#%(thread)dThread ID (if available).
#%(threadName)sThread name (if available).
#%(process)dProcess ID (if available).
#%(message)sThe logged message, computed as msg % args.
logging.basicConfig(filename=r'c:\gimp_plugin.log', level=logging.INFO,
format=FORMAT)
import gtk
class MyPlugin(gimpplugin.plugin):
def __init__(self):
self.log = logging.getLogger('MyPlugin')
def start(self):
self.log.info('start')
gimp.main(self.init, self.quit, self.query, self._run)
def init(self):
self.log.info('init')
def quit(self):
self.log.info('quit')
def query(self):
self.log.info('query')
authorname = "My Name"
copyrightname = "My Name"
date = "2008"
menulabel = "_Go"
toolbox_go_description = "An example of a toolbox plugin."
toolbox_go_help = "An example of a toolbox plugin."
toolbox_go_params = [(PDB_INT32, "run_mode", "Run mode")]
gimp.install_procedure("toolbox_go",
toolbox_go_description,
toolbox_go_help,
authorname,
copyrightname,
date,
menulabel,
"*",
PLUGIN,
toolbox_go_params,
[])
menupath = "/My _Plugin/"
gimp.menu_register("toolbox_go", menupath)
menulabel = "_Go"
image_go_description = "An example of an image plugin."
image_go_help = "An example of an image plugin."
image_go_params = [(PDB_INT32, "run_mode", "Run mode"),
(PDB_IMAGE, "image", "Input image"),
(PDB_DRAWABLE, "drawable", "Input drawable")]
gimp.install_procedure("image_go",
image_go_description,
image_go_help,