Re: [Gimp-developer] template python plugin

2008-09-30 Thread Sven Neumann
Hi,

On Tue, 2008-09-30 at 20:59 -0700, Greg MacDonald wrote:
> Revised version attached.

Another question: why does your plug-in register image and drawable
input parameters? It doesn't seem to use these at all.


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] template python plugin

2008-09-30 Thread Greg MacDonald
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,

Re: [Gimp-developer] template python plugin

2008-09-29 Thread Sven Neumann
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


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] template python plugin

2008-09-29 Thread Greg MacDonald
Hi Sven,

No reason really. But now that you bring it up, I wonder if gimpfu
might be more useful to people. If I had needed to setup a gui, I
probably would've stuck with gimpfu for it's auto gui generation
features. I think I may have gone with gimpplugin too because it just
felt familiar to me; reminded me of other sorts of plugins I've
written.

Would you like me to switch it over?

-Greg


On Mon, Sep 29, 2008 at 2:03 AM, Sven Neumann <[EMAIL PROTECTED]> wrote:
> Hi,
>
> On Sun, 2008-09-28 at 17:15 -0700, Greg MacDonald wrote:
>
>> I've been fiddling around with writing gimp-python plugins and ended
>> up creating a template for myself. It took me a day to put together so
>> I was thinking I might post it.
>
> This is interesting. Is there a particular reason that your plug-in
> template is not using gimpfu, the convenience layer that the Python
> binding offers for making it easier to write simple plug-ins?
>
>
> Sven
>
>
>
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] template python plugin

2008-09-29 Thread Sven Neumann
Hi,

On Sun, 2008-09-28 at 17:15 -0700, Greg MacDonald wrote:

> I've been fiddling around with writing gimp-python plugins and ended
> up creating a template for myself. It took me a day to put together so
> I was thinking I might post it.

This is interesting. Is there a particular reason that your plug-in
template is not using gimpfu, the convenience layer that the Python
binding offers for making it easier to write simple plug-ins?


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer