首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError: export_png()恰好接受3个参数(给定4个)

TypeError: export_png()恰好接受3个参数(给定4个)
EN

Stack Overflow用户
提问于 2017-11-24 06:12:45
回答 0查看 547关注 0票数 0

当我尝试通过GIMP的gui运行以下python脚本时:

代码语言:javascript
复制
#!/usr/bin/env python

from gimpfu import *

def export_png(image, drawable, self):
    filename=image.name
    interlace=0
    compression=0
    bkgd=0
    gama=0
    off=0
    phys=0
    time=0

    pdb.file_png_save(image, drawable, filename, raw_filename, interlace, compression, bkgd, gama, offs, phys, time)

register(
        "python_fu_export_png",
        "Exports the current image as png",
        "Exports the current image as png",
        "HHP",
        "HHP",
        "2017",
        "<Image>/Image/Export as png",
        "*",
        [
        (PF_IMAGE, "image", "takes current image", None),
        (PF_DRAWABLE,"drawable", "input layer",None),
        ],
        [],
        export_png
        )

main()

我得到了这个错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "/Applications/GIMP.app/Contents/Resources/lib/gimp/2.0/python/gimpfu.py", line 736, in response
    dialog.res = run_script(params)
  File "/Applications/GIMP.app/Contents/Resources/lib/gimp/2.0/python/gimpfu.py", line 361, in run_script
    return apply(function, params)
TypeError: export_png() takes exactly 3 arguments (4 given)

为什么会这样呢?我以为我只是把PF_Image和PF_DRAWABLE传递给函数,为什么它说我给了四个参数呢?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47463859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档