python tkinter,如何获取root/notebook/Frame中的元素?
python tkinter, how to get elements in root/notebook/Frame?
我使用 tkinter 创建 gui
1、root = tk.Tk()
2、tabControl = ttk.Notebook(root)
//create one notebook
3、tab1 = tk.Frame(tabControl, bg = 'blue', width = '400')
tabControl.add(tab1, text = 'information')
//create one Frame in notebook
4、tree = ttk.Treeview(tab1,columns=ac)
//create one tree view in Frame
例如:
根
- 笔记本
- - 框架
------树
那么,我的问题是:
如果获取root,如何获取root中的元素?
例如,如何获得notebook/Frame/tree?
非常感谢您的帮助
尝试属性children
>>> root.children
{'!notebook': <tkinter.ttk.Notebook object .!notebook>}
>>> tabControl.children
{'!frame': <tkinter.Frame object .!notebook.!frame>}
>>> tab1.children
{'!treeview': <tkinter.ttk.Treeview object .!notebook.!frame.!treeview>}
>>> tree.children
{}
我使用 tkinter 创建 gui
1、root = tk.Tk()
2、tabControl = ttk.Notebook(root)
//create one notebook
3、tab1 = tk.Frame(tabControl, bg = 'blue', width = '400')
tabControl.add(tab1, text = 'information')
//create one Frame in notebook
4、tree = ttk.Treeview(tab1,columns=ac)
//create one tree view in Frame
例如: 根 - 笔记本 - - 框架 ------树
那么,我的问题是:
如果获取root,如何获取root中的元素?
例如,如何获得notebook/Frame/tree?
非常感谢您的帮助
尝试属性children
>>> root.children
{'!notebook': <tkinter.ttk.Notebook object .!notebook>}
>>> tabControl.children
{'!frame': <tkinter.Frame object .!notebook.!frame>}
>>> tab1.children
{'!treeview': <tkinter.ttk.Treeview object .!notebook.!frame.!treeview>}
>>> tree.children
{}