Gimp script:

This new version of gimpfu adds three new objects and several extra options to help with the design of the interface.

New Items

  • PF_TAB: gimpfu3 PF_TAB This object adds a Notebook object to the interface, the fifth value that is passed is a list of the page titles, the notebook will have many pages as we pass values ​​to that list. For example:
       PF_TAB , # 1st value : object type
       "ptab", # the 2nd value : variable name
       "tabs" , # 3rd value : not used
       0,       # 4th value : selected page
       # 5 value list of page titles
       (_("Position, rotation & scale'), _('Opacity , blur & color'))
    To add objects to a particular page will use the extra option : tab , in this example we add a PF_SPINNER to the 2nd page:
        PF_SPINNER , "lightERnd", _("To: "), 0,(-100 , +100 , 1),
        {'tab':1} # page of the notebook , if omitted is
                  # added to the 0 (1st page)
  • PF_TITLE : gimpfu3 PF_TITLE Add a Label to the interface, the fourth value is a list of two decimal numbers from 0.0 to 1.0 , where the first is the horizontal alignment (0.0 left-aligned , centered 0.5 , 0.1 aligned right) and the second vertical (aligned above 0.0, 0.5 centered, 1.0 below). Example of use:
    (PF_TITLE, "anchorTit", _("Anchor: (Center for layer transforms)"), (0.0,0.0 ), None, {'cols': 8, 'iniCol':3, 'newLine' : 1}),
  • PF_DRAW: gimpfu3 PF_DRAW Add DrawingArea the interface that we can use the drawing functions of gtk, the 5 value we pass is a list with the width and height:
        (300,300) # width and height of DrawingArea

New extra options

All objects can have an array of extra values ​​that affect their position, size, page in the notebook in which you add or link it to a function (def), these extra options are added as a sixth value in the function, for example to add a PF_TITLE indicate that we want to appear on the second page of the notebook:
(PF_TITLE, "blurtit", _("Blur:"))
As an PF_TITLE only need 3 values add two null values ​​for the sixth value is the array we pass extra options:
(PF_TITLE,"blurtit", _("Blur:") , None, None, {' tab':1})
These extra options are:
  • newLine By default when adding objects to the interface is added in a new row, to have several objects in the same row will pass the value 0 to this option.
       PF_SPINNER, "oparndP", _("Random from"), 0, (0, +100, 1),
         'newLine' : '0', # the next object will be in the same line
         'tab' : 1
  • cols: cols It sets the number of columns that take an object, given that each object occupies two columns, one for the label and one for the editable object, if we set this value to 2 in order total will occupy 3 columns
  • iniCol Set the column to add the object, if not set the object would be added in the first column.
  • rows Number of rows for the object
  • tab Determines that the notebook page we add the object
  • connect Connects an action to the current object, requires two parameters, the signal that is linked to and a function, for example to run function testFn to a change in our object would use this code:
       PF_SPINNER, "scIniX", "X from:", 100, (1, +200 , 1),
         'iniCol' : 2,
         'connect': {'signal':'changed' , 'function':testFn}
    The value for ‘signal’ depends on the object to which we assign the function



2 thoughts on “Gimp script:

  1. Your modification of class StringEntry crashes a plugin which uses PF_STRING :

    # define a mapping of param types to edit objects …
    class StringEntry(gtk.Entry):
    def __init__(self, default=””):
    # self.set_line_wrap(True)
    # self.set_single_line_mode(False)

    The last two lines, which I commented out, cause the crash.

    • Hi peter, you can try to surround the error line with a “try catch” block to see what is the error message that returns, the source could be like this:
      catch Exception, e:

Leave a Reply

Your email address will not be published. Required fields are marked *