1Tk_Name(3) Tk Library Procedures Tk_Name(3)
2
3
4
5______________________________________________________________________________
6
8 Tk_Name, Tk_PathName, Tk_NameToWindow - convert between names and win‐
9 dow tokens
10
12 #include <tk.h>
13
14 Tk_Uid
15 Tk_Name(tkwin)
16
17 char *
18 Tk_PathName(tkwin)
19
20 Tk_Window
21 Tk_NameToWindow(interp, pathName, tkwin)
22
24 Tk_Window tkwin (in) Token for window.
25
26 Tcl_Interp *interp (out) Interpreter to use for error report‐
27 ing.
28
29 CONST char *pathName (in) Character string containing path
30 name of window.
31_________________________________________________________________
32
33
35 Each window managed by Tk has two names, a short name that identifies a
36 window among children of the same parent, and a path name that identi‐
37 fies the window uniquely among all the windows belonging to the same
38 main window. The path name is used more often in Tk than the short
39 name; many commands, like bind, expect path names as arguments.
40
41 The Tk_Name macro returns a window's short name, which is the same as
42 the name argument passed to Tk_CreateWindow when the window was cre‐
43 ated. The value is returned as a Tk_Uid, which may be used just like a
44 string pointer but also has the properties of a unique identifier (see
45 the manual entry for Tk_GetUid for details).
46
47 The Tk_PathName macro returns a hierarchical name for tkwin. Path
48 names have a structure similar to file names in Unix but with dots
49 between elements instead of slashes: the main window for an applica‐
50 tion has the path name ``.''; its children have names like ``.a'' and
51 ``.b''; their children have names like ``.a.aa'' and ``.b.bb''; and so
52 on. A window is considered to be be a child of another window for nam‐
53 ing purposes if the second window was named as the first window's par‐
54 ent when the first window was created. This is not always the same as
55 the X window hierarchy. For example, a pop-up is created as a child of
56 the root window, but its logical parent will usually be a window within
57 the application.
58
59 The procedure Tk_NameToWindow returns the token for a window given its
60 path name (the pathName argument) and another window belonging to the
61 same main window (tkwin). It normally returns a token for the named
62 window, but if no such window exists Tk_NameToWindow leaves an error
63 message in interp->result and returns NULL. The tkwin argument to
64 Tk_NameToWindow is needed because path names are only unique within a
65 single application hierarchy. If, for example, a single process has
66 opened two main windows, each will have a separate naming hierarchy and
67 the same path name might appear in each of the hierarchies. Normally
68 tkwin is the main window of the desired hierarchy, but this need not be
69 the case: any window in the desired hierarchy may be used.
70
71
73 name, path name, token, window
74
75
76
77Tk Tk_Name(3)