它需要处理用户可能尚未打开的图像文件。不过,似乎只有在图像已经打开的情况下,我才会启用插件。在打开图像之前,gimp2.8附带的所有Python插件都将被禁用。搜索了很多例子,似乎每个例子都需要在插件执行之前打开一个图像。在
这是一个基本的地狱世界.py在
#!/usr/bin/env python
import gtk
from gimpfu import *
def plugin_main() :
message = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
message.set_markup("Please Help")
message.run()
gimp.quit()
register(
"helloworld",
"Saying Hi",
"Saying Hello to the World",
"William Crandell <william@crandell.ws>",
"William Crandell <william@crandell.ws>",
"2015",
"Hello Gimp",
"*",
[],
[],
plugin_main,
menu = "<Toolbox>/Hello/"
)
main()
几乎相关的问题GIMP, python-fu: How to disable "Input image" and "Input drawable"
引用http://www.exp-media.com/content/extending-gimp-python-python-fu-plugins-part-4
重要的部分是imagetypes,它是插件框架的一部分请参见:http://www.gimp.org/docs/python/#plugin_framework
使用
"*"
作为“图像类型”,插件期望任何图像作为初始输入的一部分,这意味着当前图像(由于通配符*
)将作为插件启动的一部分提供。将类型更改为""
相当于在启动期间没有图像输入,因此允许插件在没有当前打开的图像的情况下运行。在相关问题 更多 >
编程相关推荐