1winfo(n) Tk Built-In Commands winfo(n)
2
3
4
5______________________________________________________________________________
6
8 winfo - Return window-related information
9
11 winfo option ?arg arg ...?
12______________________________________________________________________________
13
15 The winfo command is used to retrieve information about windows managed
16 by Tk. It can take any of a number of different forms, depending on
17 the option argument. The legal forms are:
18
19 winfo atom ?-displayof window? name
20 Returns a decimal string giving the integer identifier for the
21 atom whose name is name. If no atom exists with the name name
22 then a new one is created. If the -displayof option is given
23 then the atom is looked up on the display of window; otherwise
24 it is looked up on the display of the application's main window.
25
26 winfo atomname ?-displayof window? id
27 Returns the textual name for the atom whose integer identifier
28 is id. If the -displayof option is given then the identifier is
29 looked up on the display of window; otherwise it is looked up
30 on the display of the application's main window. This command
31 is the inverse of the winfo atom command. It generates an error
32 if no such atom exists.
33
34 winfo cells window
35 Returns a decimal string giving the number of cells in the color
36 map for window.
37
38 winfo children window
39 Returns a list containing the path names of all the children of
40 window. Top-level windows are returned as children of their log‐
41 ical parents. The list is in stacking order, with the lowest
42 window first, except for Top-level windows which are not
43 returned in stacking order. Use the wm stackorder command to
44 query the stacking order of Top-level windows.
45
46 winfo class window
47 Returns the class name for window.
48
49 winfo colormapfull window
50 Returns 1 if the colormap for window is known to be full, 0 oth‐
51 erwise. The colormap for a window is “known” to be full if the
52 last attempt to allocate a new color on that window failed and
53 this application has not freed any colors in the colormap since
54 the failed allocation.
55
56 winfo containing ?-displayof window? rootX rootY
57 Returns the path name for the window containing the point given
58 by rootX and rootY. RootX and rootY are specified in screen
59 units (i.e. any form acceptable to Tk_GetPixels) in the coordi‐
60 nate system of the root window (if a virtual-root window manager
61 is in use then the coordinate system of the virtual root window
62 is used). If the -displayof option is given then the coordi‐
63 nates refer to the screen containing window; otherwise they
64 refer to the screen of the application's main window. If no
65 window in this application contains the point then an empty
66 string is returned. In selecting the containing window, chil‐
67 dren are given higher priority than parents and among siblings
68 the highest one in the stacking order is chosen.
69
70 winfo depth window
71 Returns a decimal string giving the depth of window (number of
72 bits per pixel).
73
74 winfo exists window
75 Returns 1 if there exists a window named window, 0 if no such
76 window exists.
77
78 winfo fpixels window number
79 Returns a floating-point value giving the number of pixels in
80 window corresponding to the distance given by number. Number
81 may be specified in any of the forms acceptable to
82 Tk_GetScreenMM, such as “2.0c” or “1i”. The return value may be
83 fractional; for an integer value, use winfo pixels.
84
85 winfo geometry window
86 Returns the geometry for window, in the form widthxheight+x+y.
87 All dimensions are in pixels.
88
89 winfo height window
90 Returns a decimal string giving window's height in pixels. When
91 a window is first created its height will be 1 pixel; the
92 height will eventually be changed by a geometry manager to ful‐
93 fil the window's needs. If you need the true height immediately
94 after creating a widget, invoke update to force the geometry
95 manager to arrange it, or use winfo reqheight to get the win‐
96 dow's requested height instead of its actual height.
97
98 winfo id window
99 Returns a hexadecimal string giving a low-level platform-spe‐
100 cific identifier for window. On Unix platforms, this is the X
101 window identifier. Under Windows, this is the Windows HWND. On
102 the Macintosh the value has no meaning outside Tk.
103
104 winfo interps ?-displayof window?
105 Returns a list whose members are the names of all Tcl inter‐
106 preters (e.g. all Tk-based applications) currently registered
107 for a particular display. If the -displayof option is given
108 then the return value refers to the display of window; other‐
109 wise it refers to the display of the application's main window.
110
111 winfo ismapped window
112 Returns 1 if window is currently mapped, 0 otherwise.
113
114 winfo manager window
115 Returns the name of the geometry manager currently responsible
116 for window, or an empty string if window is not managed by any
117 geometry manager. The name is usually the name of the Tcl com‐
118 mand for the geometry manager, such as pack or place. If the
119 geometry manager is a widget, such as canvases or text, the name
120 is the widget's class command, such as canvas.
121
122 winfo name window
123 Returns window's name (i.e. its name within its parent, as
124 opposed to its full path name). The command winfo name . will
125 return the name of the application.
126
127 winfo parent window
128 Returns the path name of window's parent, or an empty string if
129 window is the main window of the application.
130
131 winfo pathname ?-displayof window? id
132 Returns the path name of the window whose X identifier is id.
133 Id must be a decimal, hexadecimal, or octal integer and must
134 correspond to a window in the invoking application. If the
135 -displayof option is given then the identifier is looked up on
136 the display of window; otherwise it is looked up on the display
137 of the application's main window.
138
139 winfo pixels window number
140 Returns the number of pixels in window corresponding to the dis‐
141 tance given by number. Number may be specified in any of the
142 forms acceptable to Tk_GetPixels, such as “2.0c” or “1i”. The
143 result is rounded to the nearest integer value; for a frac‐
144 tional result, use winfo fpixels.
145
146 winfo pointerx window
147 If the mouse pointer is on the same screen as window, returns
148 the pointer's x coordinate, measured in pixels in the screen's
149 root window. If a virtual root window is in use on the screen,
150 the position is measured in the virtual root. If the mouse
151 pointer is not on the same screen as window then -1 is returned.
152
153 winfo pointerxy window
154 If the mouse pointer is on the same screen as window, returns a
155 list with two elements, which are the pointer's x and y coordi‐
156 nates measured in pixels in the screen's root window. If a vir‐
157 tual root window is in use on the screen, the position is com‐
158 puted in the virtual root. If the mouse pointer is not on the
159 same screen as window then both of the returned coordinates are
160 -1.
161
162 winfo pointery window
163 If the mouse pointer is on the same screen as window, returns
164 the pointer's y coordinate, measured in pixels in the screen's
165 root window. If a virtual root window is in use on the screen,
166 the position is computed in the virtual root. If the mouse
167 pointer is not on the same screen as window then -1 is returned.
168
169 winfo reqheight window
170 Returns a decimal string giving window's requested height, in
171 pixels. This is the value used by window's geometry manager to
172 compute its geometry.
173
174 winfo reqwidth window
175 Returns a decimal string giving window's requested width, in
176 pixels. This is the value used by window's geometry manager to
177 compute its geometry.
178
179 winfo rgb window color
180 Returns a list containing three decimal values in the range 0 to
181 65535, which are the red, green, and blue intensities that cor‐
182 respond to color in the window given by window. Color may be
183 specified in any of the forms acceptable for a color option.
184
185 winfo rootx window
186 Returns a decimal string giving the x-coordinate, in the root
187 window of the screen, of the upper-left corner of window's bor‐
188 der (or window if it has no border).
189
190 winfo rooty window
191 Returns a decimal string giving the y-coordinate, in the root
192 window of the screen, of the upper-left corner of window's bor‐
193 der (or window if it has no border).
194
195 winfo screen window
196 Returns the name of the screen associated with window, in the
197 form displayName.screenIndex.
198
199 winfo screencells window
200 Returns a decimal string giving the number of cells in the
201 default color map for window's screen.
202
203 winfo screendepth window
204 Returns a decimal string giving the depth of the root window of
205 window's screen (number of bits per pixel).
206
207 winfo screenheight window
208 Returns a decimal string giving the height of window's screen,
209 in pixels.
210
211 winfo screenmmheight window
212 Returns a decimal string giving the height of window's screen,
213 in millimeters.
214
215 winfo screenmmwidth window
216 Returns a decimal string giving the width of window's screen, in
217 millimeters.
218
219 winfo screenvisual window
220 Returns one of the following strings to indicate the default
221 visual class for window's screen: directcolor, grayscale, pseu‐
222 docolor, staticcolor, staticgray, or truecolor.
223
224 winfo screenwidth window
225 Returns a decimal string giving the width of window's screen, in
226 pixels.
227
228 winfo server window
229 Returns a string containing information about the server for
230 window's display. The exact format of this string may vary from
231 platform to platform. For X servers the string has the form
232 “XmajorRminor vendor vendorVersion” where major and minor are
233 the version and revision numbers provided by the server (e.g.,
234 X11R5), vendor is the name of the vendor for the server, and
235 vendorRelease is an integer release number provided by the
236 server.
237
238 winfo toplevel window
239 Returns the path name of the top-of-hierarchy window containing
240 window. In standard Tk this will always be a toplevel widget,
241 but extensions may create other kinds of top-of-hierarchy wid‐
242 gets.
243
244 winfo viewable window
245 Returns 1 if window and all of its ancestors up through the
246 nearest toplevel window are mapped. Returns 0 if any of these
247 windows are not mapped.
248
249 winfo visual window
250 Returns one of the following strings to indicate the visual
251 class for window: directcolor, grayscale, pseudocolor, static‐
252 color, staticgray, or truecolor.
253
254 winfo visualid window
255 Returns the X identifier for the visual for window.
256
257 winfo visualsavailable window ?includeids?
258 Returns a list whose elements describe the visuals available for
259 window's screen. Each element consists of a visual class fol‐
260 lowed by an integer depth. The class has the same form as
261 returned by winfo visual. The depth gives the number of bits
262 per pixel in the visual. In addition, if the includeids argu‐
263 ment is provided, then the depth is followed by the X identifier
264 for the visual.
265
266 winfo vrootheight window
267 Returns the height of the virtual root window associated with
268 window if there is one; otherwise returns the height of win‐
269 dow's screen.
270
271 winfo vrootwidth window
272 Returns the width of the virtual root window associated with
273 window if there is one; otherwise returns the width of window's
274 screen.
275
276 winfo vrootx window
277 Returns the x-offset of the virtual root window associated with
278 window, relative to the root window of its screen. This is nor‐
279 mally either zero or negative. Returns 0 if there is no virtual
280 root window for window.
281
282 winfo vrooty window
283 Returns the y-offset of the virtual root window associated with
284 window, relative to the root window of its screen. This is nor‐
285 mally either zero or negative. Returns 0 if there is no virtual
286 root window for window.
287
288 winfo width window
289 Returns a decimal string giving window's width in pixels. When
290 a window is first created its width will be 1 pixel; the width
291 will eventually be changed by a geometry manager to fulfil the
292 window's needs. If you need the true width immediately after
293 creating a widget, invoke update to force the geometry manager
294 to arrange it, or use winfo reqwidth to get the window's
295 requested width instead of its actual width.
296
297 winfo x window
298 Returns a decimal string giving the x-coordinate, in window's
299 parent, of the upper-left corner of window's border (or window
300 if it has no border).
301
302 winfo y window
303 Returns a decimal string giving the y-coordinate, in window's
304 parent, of the upper-left corner of window's border (or window
305 if it has no border).
306
308 Print where the mouse pointer is and what window it is currently over:
309 lassign [winfo pointerxy .] x y
310 puts -nonewline "Mouse pointer at ($x,$y) which is "
311 set win [winfo containing $x $y]
312 if {$win eq ""} {
313 puts "over no window"
314 } else {
315 puts "over $win"
316 }
317
319 atom, children, class, geometry, height, identifier, information,
320 interpreters, mapped, parent, path name, screen, virtual root, width,
321 window
322
323
324
325Tk 4.3 winfo(n)