金普:我为什么不能注册? [英] Gimp: why can't I register this?
问题描述
我正在为Blender编写一个插件,以使其与Gimp同步,并且该脚本应该能够从Gimp内部启动,但是我无法注册它……为什么?
blender_gimp_sync.py:
#-*-编码:utf-8-*-#!/usr/bin/env python从gimpfu进口*def blender_gimp_sync():image_dir =/home/antoni4040/Έγγραφα/Layout.png"图片= gimp.pdb.gimp_file_load(image_dir,image_dir)gimp.Display(图像)登记("python_fu_bgsync","Blender-Gimp同步",使用Blender同步Gimp以进行纹理处理",安东尼斯·卡维拉斯",安东尼斯·卡维拉斯","2012",<图像>/图像/Blender-Gimp同步","*",[],[],blender_gimp_sync)主要的()
真的很奇怪...
您没有说要得到哪个错误-但是由于您发布了源文件,所以我想我可以猜到:GIMP期望它的插件可以被系统执行-并且告诉Posix(包括linux)系统应该使用特定解释器或shell执行文件的是shebang行-行行#!/usr/bin/env python
在您的示例中.
但是,此行必须是文件中的第一行-其中的#!
字符应为文件的前两个字符.表示字符编码的行-#-*-编码:utf-8-*-
应该紧随其后-它必须是文件中的第二行,它们之间不能有空行./p>
最后,通过在Python文件上运行"chmod a + x",确保将脚本设置为可执行文件.
与之相关,但不是引起问题的原因,因此在GIMP中已弃用菜单路径和脚本菜单名称-正确的方法是在"date"参数之后,仅传递名称应该显示在菜单中的同步"中,并在调用结束时将菜单路径作为命名参数传递,例如: menu =< Image>/Image/Blender-Gimp"
menu =< Image>/Image/Blender-Gimp" menu =< Image>/Image/Blender-Gimp" 代码>
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...
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"
这篇关于金普:我为什么不能注册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!