Next / Previous / Contents

5.11. Window names

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 '.n', where n is some integer in string form. For example, a window named '.135932060' is a child of the root window ('.').

  • Child windows within child windows have names of the form 'p.n' where p is the name of the parent window and n is some integer. For example, a window named '.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 w, use 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.