有没有办法列出 Tkinter 小部件的配置选项?我在 effbot 网站上找到了有关 Tkinter 的内容:
The following dictionary method also works for widgets:
keys() => list
Return a list of all options that can be set for this widget. The name option is not included in this list (it cannot be queried or modified through the dictionary interface anyway, so this doesn’t really matter).
这段代码:
def callback():
listbox.delete(0,END)
for key in b:
listbox.insert(END, key)
#listbox.insert(END,str(b))
b = Button(master, text="Delete", command=callback)
抛出此错误:
return self.tk.call(self._2, 'cget', '-' + key)
TypeError: Can't convert 'int' object to str implicitly
有什么建议吗?
最佳答案
您没有调用keys()
。
def callback():
listbox.delete(0,END)
for key in b.keys():
listbox.insert(END, key)
关于python - TKINTER 小部件的配置选项列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18139990/