Tkinter 8.5 参考手册: a GUI for Python (五)11 窗口的名称

来源:互联网 发布:软件培训机构排名 编辑:程序博客网 时间:2024/06/16 12:05
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/window-names.html

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.

0 0
原创粉丝点击