tkinter | TypeError:__init __()从1到2个位置论点,但给出了3个
代码旨在将输入从TKINTER条目窗口小部件CAM1中获取,并分配给CAM1_NAME,然后将其附加到具有关联的回调功能的列表中。显然,它没有并抛出上面的错误。任何帮助将不胜感激。谢谢!
import tkinter as tk
from tkinter import ttk
root = tk.Tk() # my main window
def cam1_name_func():
cam1_name.get()
amendations["camOne"] = cam1_name
cam1_name = tk.StringVar()
cam1 = ttk.Checkbutton(root, cam1_name).pack() # error happens on this line
root.mainloop()
Code is meant to take the input from the tkinter entry widget, cam1, and assign to cam1_name, to then be appended to a list with its associated callback function. Obviously, it does not and throws the error above. Any help would be appreciated. Thanks!
import tkinter as tk
from tkinter import ttk
root = tk.Tk() # my main window
def cam1_name_func():
cam1_name.get()
amendations["camOne"] = cam1_name
cam1_name = tk.StringVar()
cam1 = ttk.Checkbutton(root, cam1_name).pack() # error happens on this line
root.mainloop()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要解决错误,您需要将文本关键字用于
checkbutton
的第二个参数。checkbutton
的所有选项都需要列出为key = value
在父窗口参数之后。To fix the error, you need to use the text keyword for the second argument of
Checkbutton
. All the options forCheckbutton
need to be listed askey=value
after the parent window argument.