GIMP, python-fu: How to disable “Input image” and “Input drawable”

爷,独闯天下 提交于 2019-12-13 02:39:54

问题


i am confused a little about the art of how gimp generates the gui for python plug-ins.

gimp generates two, for my script, needless fields. "Input image" and "Input drawable". how can i disable them?

I didn't find anything about it in the standart documetation.

my register method:

register(
  "fixPngColors",
  "fixPngColors",
  "fixPngColors",
  "Author",
  "Author",
  "2013",
  "<Image>/plug-ins/BATCH PNG Color Fix",
  "",
  [
  (PF_DIRNAME, "png_input_directory", "Png directory(INPUT)", ""),
  (PF_DIRNAME, "png_output_directory", "Png directory(OUTPUT)", ""),
  (PF_INT, "c_count", "Max Colors", "255"),
  ],
  [],
  launcher
  )

like you can see, nothing about the other two.


回答1:


It's because of

"<Image>/plug-ins/BATCH PNG Color Fix",

in the register function!

Had the same Problem. Move the menu to another place like

"<Toolbox>/MyScripts/BATCH PNG Color Fix",

and you dont need an input image anymore.

If you place an plug-in under "Image", Gimp assumes you need an image and a drawable as input. This seems to override everything else.




回答2:


Indeed - you solution is the way to fix it

The docs are outdated actually - it used to work this way - and still does, due to backward compatibility: the first part of the menu path indicates teh context were your plug-in shows up - and python-fu automatically generates the field(s) for that context. (, , )

Due to the confusion and non-explicit side-effects this casued, this form of calling register is deprecated. Instead, on that 8th parameter, one should pass only the Menu entry name for the script - "BATCH PNG Color Fix" - in this case, and you should add a named parameter "menu='/plug-ins/BATCH PNG Color Fix' parameter to the register call. (IIRC this last parameter can be a list, and your plug-in can show up in multiple palces in the menus - but I've never tried it).



来源:https://stackoverflow.com/questions/16418389/gimp-python-fu-how-to-disable-input-image-and-input-drawable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!