获取 Tkinter 窗口的每个子部件 [英] Getting every child widget of a Tkinter window
本文介绍了获取 Tkinter 窗口的每个子部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以获取 Tkinter 小部件的所有子项,然后获取子项的子项等?
Is it possible to get all of the children of a Tkinter widget, then get the children's children etc.?
基本上我希望在整个窗口中包含所有小部件.
Basically I want all of the widgets within one entire window.
我找到了一个利用 Bryan's line 的解决方案:
Edit : I found a solution utilizing Bryan's line :
def all_children (wid) :
_list = wid.winfo_children()
for item in _list :
if item.winfo_children() :
_list.extend(item.winfo_children())
return _list
推荐答案
您正在寻找的方法是 winfo_children.
The method you are looking for is winfo_children.
这篇关于获取 Tkinter 窗口的每个子部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文