The term window describes a rectangular area on the desktop.
A top-level or root window is a window that has an independent existence under the window manager. It is decorated with the window manager's decorations, and can be moved and resized independently. Your application can use any number of top-level windows.
The term “window” also applies to any widget that is part of a top-level window.
Tkinter names all these windows using a hierarchical window path name.
The root window's name is '.'
.
Child windows have names of the form '.
, where n
'
is some integer
in string form. For example, a window named n
'.135932060'
is a child of the root window
('.'
).
Child windows within child windows have names of the
form '
where p
.n
'
is the name of
the parent window and p
is some
integer. For example, a window named n
'.135932060.137304468'
has parent window
'.135932060'
, so it is a grandchild of
the root window.
The relative name of a window
is the part past the last '.'
in the
path name. To continue the previous example, the
grandchild window has a relative name '137304468'
.
To get the path name for a widget
, use w
str(
.
w
)
See also Section 26, “Universal widget methods” for methods you can
use to operate on window names, especially the .winfo_name
,
.winfo_parent
, and .winfo_pathname
methods.