Gimp script:
gimpfu3.py

Esta nueva versión de gimpfu añade tres objetos nuevos y varias opciones extra para ayudar con el diseño de la interfaz.

Nuevos objetos

  • PF_TAB: gimpfu3 PF_TAB Este componente añade un objeto Notebook a la interfaz, el quinto valor que le pasamos al crearlo es una lista de los títulos de las páginas, el notebook tendrá tantas páginas como valores pasemos a esa lista. Por ejemplo:
    (
       PF_TAB, # 1er valor: tipo de objeto
       "ptab",  # 2o valor: nombre de la variable
       "tabs",  # 3er valor: sin uso
       0,       # 4o valor: página seleccionada
       # 5º valor lista de titulos de las páginas
       (_('Position, rotation & scale'),_('Opacity, blur & color'))
    ),
    
    Para añadir objetos a una página concreta usaremos la opción extra: tab, en este ejemplo añadimos un PF_SPINNER a la 2ª página:
    (
        PF_SPINNER, "lightERnd", _("To:"), 0, (-100, +100, 1),
        {'newLine':1,'tab':1} # página del notebook, si se omite se
                              # añade en la 0 (1ª página)
    ),
    
  • PF_TITLE: gimpfu3 PF_TITLE Añade un Label a la interfaz, el cuarto valor es una lista de dos números decimales de 0.0 a 1.0, donde el primero es la alineación horizontal (0.0 alineado a la izquierda, 0.5 centrado, 0.1 alineado a la derecha) y el segundo la vertical (0.0 alineado arriba, 0,5 centrado, 1.0 abajo). Ejemplo de uso:
    (PF_TITLE, "anchorTit", _("Anchor: (Center for layer transforms)"), (0.0,0.0),None,{'cols':8,'iniCol':3,'newLine':1}),
    
  • PF_DRAW: gimpfu3 PF_DRAW Añade un DrawingArea a la interfaz en la que podremos usar las funciones de dibujo de gtk, el 5 valor que le pasamos es una lista con el ancho y alto:
    (
        PF_DRAW,
        "preview",
        _("P\nR\nE\nV\nI\nE\nW"),
        0,
        (300,300) # ancho y alto del DrawingArea
    ),

Nuevas opciones extra

A todos los objetos podemos añadirle un array con valores extra que afectan a su posición, tamaño, página en el notebook en la que se añaden o vincularlo a una función (def), estas opciones extra se añaden como un sexto valor en la función, por ejemplo para añadirle indicar a un PF_TITLE que queremos que aparezca en la segunda página del notebook:
(PF_TITLE, "blurTit", _("Blur:")),
Como un PF_TITLE solo necesita 3 valores añadimos dos nulos para que el sexto valor que le pasamos sea el array de opciones extra:
(PF_TITLE, "blurTit", _("Blur:"), None, None,{'tab':1}),
Estas opciones extra son:
  • newLine: Por defecto al añadir objetos a la interfaz cada uno se añade en una nueva fila, para poder tener varios objetos en la misma fila le pasaremos el valor 0 a esta opción.
    (
       PF_SPINNER,"oparndP",_("Random from "), 0, (0, +100, 1),
       {
         'newLine':'0', # el siguiente objeto estará en la misma línea
         'tab':1
       }
    ),
  • cols: cols Establece la cantidad de columnas que ocupará un objeto, teniendo en cuenta que cada objeto que crea gimpfu ocupa dos columnas, una para la etiqueta y otra para el objeto editable, si establecemos este valor a 2 el objeto en total ocupará 3 columnas
  • iniCol Establece en que columna añadimos el objeto, si no establecemos el valor se añadiría en la primera columna.
  • rows Cantidad de filas para el objeto
  • tab Determina en que página del notebook queremos añadir el objeto
  • connect Conecta una acción al objeto actual, necesita dos parámetros, la señal a la que se vincula y una función, por ejemplo para que se ejecute función testFn al cambiar nuestro objeto usaríamos este código:
    (
       PF_SPINNER,"scIniX","X from:", 100, (1, +200,    1),
       {
         'newLine':'0',
         'iniCol':2,
         'connect':{'signal':'changed','function':testFn}
       }
    ),
    
    El valor para ‘signal’ dependerá del objeto al que se lo asignamos
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:
    (
        PF_DRAW,
        "preview"
        _("P\nR\nE\nV\nI\nE\nW")
        0,
        (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

Download/Descarga

gimpfu3

2 thoughts on “Gimp script: gimpfu3.py

  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=»»):
    gtk.Entry.__init__(self)
    self.set_text(str(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:
      try:
      self.set_line_wrap(True)
      self.set_single_line_mode(False)
      catch Exception, e:
      gimp.message(str(e))
      pass


Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *