【问题标题】:TypeError missing 3 required positional argumentsTypeError 缺少 3 个必需的位置参数
【发布时间】:2017-05-15 03:32:36
【问题描述】:

我有一个 tkinter 按钮,按下时会调用命令“nadirpatch”。当我按下按钮时,我收到以下错误:

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'

这是我的“nadirpatch”代码:(变量已经定义)

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

谢谢!

【问题讨论】:

    标签: python tkinter typeerror


    【解决方案1】:

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

    # Sample code
    button = Tk.Button(master=frame, text='press', command= lambda: nadirpatch(photoSphere, nadir, photospherePath))
    

    【讨论】:

      猜你喜欢
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      • 2013-07-06
      • 2019-06-25
      • 2013-10-02
      • 2021-02-08
      • 2020-06-13
      • 2021-07-25
      相关资源
      最近更新 更多