Reputation: 2271
Today I wrote a short python script that should rename a list of layers of a gimp image to add some flags, which are used when the layers are part of an animation. The script is integrated into the Gimp menu and the information provided in the Python-Fu console is correct. But if I execute the script within the Python-Fu console or from the action menu, nothing happens. I was not able to locate a problem. Posting the function content by hand to the console works.
Does someone know a solution to this problem or did face the same problem in Gimp 2.8?
#!/usr/bin/env python
from gimpfu import *
import os
def renameAllLayers(img):
print 'Starting ...\n'
for layer in img.layers:
print layer.name + '\n'
if layer.name[-16:] is '(66ms) (replace)':
pass
elif layer.name[-17:] is '(200ms) (replace)':
pass
elif layer.name[-10:] is ' (replace)':
layer.name = layer.name[:-10] + '(66ms) (replace)'
print layer.name + '\n'
print 'Finished ...\n'
register(
proc_name=("rename_all_layers"),
label=("Rename all layers"),
blurb=("Rename all layers so they include all missing flags"),
help=("Help?"),
author=("Andreas Schickedanz"),
date=("2013"),
menu=("<Image>/Scripts/Layer Renamer"),
imagetypes=("*"),
params=[
(PF_IMAGE, "img", "Select an image", None),
],
results=[],
function=(renameAllLayers)
)
main()
Upvotes: 2
Views: 1614
Reputation: 69052
In your script you compare strings using is
, which checks for object identity, so it will always return False
in this cases, therfore your layers aren't renamed.
Use ==
instead to compare strings. Besides that your script works perfectly.
Upvotes: 1