Question

How can I pass a parameter in GimpFU python?

#!/usr/bin/env python

from gimpfu import *
import traceback
import sys


def upload_image(img, layer, dir):
    # Actual plug-in code will go here
    try:
        open('/tmp/upload.txt', 'w+').write('img:\n')
    except:
        open('/tmp/upload_error.txt', 'w+').write(traceback.format_exc())
        open('/tmp/upload_error.txt', 'a').write(sys.exc_info()[0])

    return


register(
    "Uploader",
    "Boo",
    "Far",
    "foo",
    "bar",
    "2014",
    "<Image>/File/Upload",
  "*", 
[],
[],
    upload_image)
main()
Was it helpful?

Solution

Just chek any other python-fu plug-in - the first list on the parameters list is where you specify the input parameters. Each item on the list is a tuple of a minimum of 4 elements: The paramter type (for example, PF_FILE, or PF_STRING, a string with the parameter name, a string with the textual description of the parameter (used as label and tooltip), and a default value.).

PF_FILE however had been broken for a while, and will work again on GIMP 2.8.12 - in other versions, you can't use PF_FILE to select a not-yet exiting filename.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top