python - 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)
解决方案
由于您尚未发布完整的堆栈跟踪,我猜这是问题所在,在您的代码中
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 *
除了可读性误解之外,这是避免这样做的原因之一。
推荐阅读
- reactjs - 使用反应路由器通量返回时如何重新渲染或刷新上一个屏幕
- reactjs - React Material-UI 换行符在 Chrome 中有效,但在 Safari 中无效
- eclipse - Eclipse CDT isConst 检查
- lua - 不添加到变量“breakpin”
- java - 未调用 Android ViewBinding onItemClickListener
- python - 将特定草图移动到 Python Turtle 模块中的特定点
- laravel - 未收到 Slack 交互式有效负载
- botframework - 如何从 Microsoft 团队会议中捕获语音和/或文字记录?
- robotframework - 如何验证 Robot 框架代码的语法
- algorithm - 算法伪代码