📜  获取 id 小部件 tkinter - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:39.010000             🧑  作者: Mango

代码示例1
You can override the auto-generated name by giving a name when you create a widget, using the 
name parameter. You can then use str to get the name.

For example:

>>> import Tkinter as tk
>>> root = tk.Tk()
>>> f = tk.Frame(root, name="foo")
>>> b1 = tk.Button(f, name="b1")
>>> str(b1)
'.foo.b1'
>>> root.nametowidget(".foo.b1")

>>> b1