首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError缺少3个必需的位置参数

TypeError缺少3个必需的位置参数
EN

Stack Overflow用户
提问于 2017-05-08 14:32:30
回答 1查看 2.5K关注 0票数 0

我有一个tkinter按钮,当按下命令“nadir修补程序”时调用它。当我按下按钮时,会得到以下错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 1699, in __call__
    return self.func(*args)
TypeError: nadirpatch() missing 3 required positional arguments: 'photoSphere', 'nadir', and 'photospherePath'

下面是我为“nadir修补程序”编写的代码:(已经定义了变量)

代码语言:javascript
复制
def nadirpatch(photoSphere, nadir, photospherePath):
    for photospherePath in photospherePath:
        photoSphere = Image.open(photospherePath) 
        nadir = Image.open(nadirPath)
        nadir = nadir.resize((photoSphere.size), resample=0)
        photoSphere.paste(nadir, (0, 0), nadir) 
        photoSphere.save((stitchedPath+"/patchedsphere"+(str(fileNum+1))+".jpeg"), "JPEG")
        fileNum +=1

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-08 14:51:43

您需要在Button定义中传递参数,如下所示:

代码语言:javascript
复制
# Sample code
button = Tk.Button(master=frame, text='press', command= lambda: nadirpatch(photoSphere, nadir, photospherePath))
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43850351

复制
相关文章

相似问题

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