首页 > 解决方案 > TypeError: __call__() 得到了一个意外的关键字参数“文本”

问题描述

当我遇到这个问题时,我正在使用带有 gui 的自动点击器:TypeError: call () got an unexpected keyword argument 'text'

不知道怎么解决,我都试过了

完整代码:https ://codeshare.io/axY39N

Label(window, text="Tan AutoClicker", fg="white", bg="#1589d6", font="none 
20", width=30).grid(row=0, column=0)
Label(window, text="Keybind:", fg="white", bg="#1589d6", font="none 
10").grid(row=3, column=0)
binding = Entry(window, bg="white", width=10)
binding.grid(row=4, column=0)
Button (window, text="Submit", width=6, height=1, 
command=set_keybind).grid(row=5, column=0)

标签: pythontkinter

解决方案


由于您尚未发布完整的堆栈跟踪,我猜这是问题所在,在您的代码中

from tkinter import *
# ...
from pynput.mouse import Button, Controller

后来你有了

Button (window, text="Submit", width=6, height=1, command=set_keybind).grid(row=5, column=0)

所以,我认为这Button实际上是 a pynput.mouse.Button,而不是tkinter.Button你所期望的,并且与额外的参数(确切地说)pynput.mouse.Button混淆了。text

from package import *除了可读性误解之外,这是避免这样做的原因之一。


推荐阅读