On Thursday 20 August 2009, saulgo...@flashingtwelve.brickfilms.com wrote:
> Quoting professor <for...@gimpusers.com>:
> > When using Gimp interactively, I can assign names to the different
> > layers, e.g. "p1", "p2", "p3" etc.
> > Now, is it possible to set a layer active by referring to its name? E.g.:
> > gimp-image-set-active-layer "p1" ?
> You will have to manually search the list of layers for the one with
> the matching name.
> The following function will do so for a given image, returning the
> layerID (or "0" if not found).
> (define (find-layer-by-name image s)
> (let* (
> (layer's (vector->list (cadr (gimp-image-get-layers image))))
> (found 0)
> (while (pair? layer's)
> (if (string=? s (car (gimp-layer-get-name (car layer's))))
> (set! found (car layer's))
> (set! layer's (cdr layer's))
Huh???ah, You mean:
def find_layer_by_name (image, name):
for layer in image:
if layer.name == name:
(yes, this is the actual python code for it, not pseudo-code)
you just need a proper register call to have it as a gimp-plugin
Scheme was great for its time - when computers could not hold interpreters
mroe complex than what is needed to handle scheme. Scheme may still be usefull
-and look great - for people who already hae it flowing in their veins. But
the truth is that for very single problems one have to go through a lot of
work around to get to the core of it. One of the ideas of Python, as a very
high level language is not to stay between you and the problem, as you can see
by the snippet above.
> Gimp-user mailing list
Gimp-user mailing list