问题
I'm writing an add-on for Blender to sync it with Gimp and this script should be able to start from within Gimp, but I can't register it... Why?
blender_gimp_sync.py:
# -*- coding: utf-8 -*-
#!/usr/bin/env python
from gimpfu import *
def blender_gimp_sync():
image_dir = "/home/antoni4040/Έγγραφα/Layout.png"
image = gimp.pdb.gimp_file_load(image_dir, image_dir)
gimp.Display(image)
register(
"python_fu_bgsync",
"Blender-Gimp Sync",
"Syncronize Gimp with Blender for texturing",
"Antonis Karvelas",
"Antonis Karvelas",
"2012",
"<Image>/Image/Blender-Gimp Sync",
"*",
[],
[],
blender_gimp_sync
)
main()
It's really strange...
回答1:
You didn't say which error you are getting - but since you posted your source file I think I can guess it:
GIMP expect's it's plug-ins to be exectuable by the system - and what tell's Posix (linux included) systems that a file should be executed with a particular interpreter or shell is the shebang line - the line that goes #!/usr/bin/env python
in your example.
This line, however, has to be the first line in your file - the #!
characters in it should be the first two characters in the file. The line denoting the character encoding - # -*- coding: utf-8 -*-
should come after it - it has to be the second line in the file, no blank lines between them).
And finally, be sure to set the script as executable, by running "chmod a+x " on the Python file.
related to it, but not being what is causing the problem, putting the menu path along with the script menu name is deprecated in GIMP - the correct way to do it is, after the "date" parameter, pass just the name that should show in the menu -- "Sync" - and pass the menu path as a named parameter, at the end of the call, like: menu="<Image>/Image/Blender-Gimp"
来源:https://stackoverflow.com/questions/12713399/gimp-why-cant-i-register-this