get id widget tkinter

Solutions on MaxInterview for get id widget tkinter by the best coders in the world

showing results for - "get id widget tkinter"
Charlotte
02 May 2016
1You can override the auto-generated name by giving a name when you create a widget, using the 
2name parameter. You can then use str to get the name.
3
4For example:
5
6>>> import Tkinter as tk
7>>> root = tk.Tk()
8>>> f = tk.Frame(root, name="foo")
9>>> b1 = tk.Button(f, name="b1")
10>>> str(b1)
11'.foo.b1'
12>>> root.nametowidget(".foo.b1")
13<Tkinter.Button instance at 0x100795488>
14>>> b1
15<Tkinter.Button instance at 0x100795488>