The number 50109912
is the unique Python object id of the button widget:
>>> from tkinter import *
>>> root = Tk()
>>> mybutton = Button(root, text="Click Me", command=root.destroy)
>>> print(mybutton)
.38321104
>>> id(mybutton)
38321104
>>>
Moreover, the string .50109912
is the button widget's window path name. Window path names are used internally by the TCL interpreter to keep track of widgets as well as what their parents are. In other words, they are paths for the interpreter to follow in order to reach particular widgets.
You'll notice too that 50109912
is the same number returned by the winfo_name
method:
>>> mybutton.winfo_name()
'38321104'
>>>
Note however that winfo_name
only returns the last portion of a widget's window path name (its object id). To get the full path, you need to call widget.__str__()
by doing either str(widget)
or print(widget)
.
The documentation for calling widget.__str__()
can found through help
:
>>> import tkinter
>>> help(tkinter.Button.__str__)
Help on function __str__ in module tkinter:
__str__(self)
Return the window path name of this widget.
>>>
In addition, you may be interested in the Basic Widget Methods page over on Effbot (specifically, the section which talks about the .winfo_*
methods). It contains information about how to get specific parts of a widget's window path name.
Also, if you want the Python representation of the object, you can use repr
:
>>> from tkinter import *
>>> root = Tk()
>>> mybutton = Button(root, text="Click Me", command=root.destroy)
>>> print(repr(mybutton))
<tkinter.Button object at 0x0248BBD0>
>>>
__str__
methods to return a decimal-looking string instead of the usual<Tkinter.Button instance at ...>
that you usually see when you print an object. But I'm guessing what you're really asking is "what do these numbers represent?". I have no idea.