python - TKINTER 小部件的配置选项列表

标签 python python-3.x tkinter

有没有办法列出 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/

相关文章:

python - 如何正确地将base64字符串转换为图像文件?

python - 如何放大导入到 Tkinter Canvas 上的图像?

python - 在 Python 3 中重命名了哪些 tkinter 模块?

python - inspect.getouterframes() 函数的 'index' 术语是什么?

python - 计算在 python 中具有特定术语的子列表

python - 查找用户选择的第一个唯一项目,并按日期按用户选择的顺序对它们进行排名

python - 如何使用 CEFPython 在 Tkinter 窗口中添加 WebBrowser 小部件?

python - 从函数返回 boolean 值的最佳实践 - 硬编码或从变量

python - 将 azure blob 下载到本地文件系统时发生异常

Python 错误 : TypeError: getsockaddrarg: AF_INET address must be tuple, 不是 int