1winfo(n)                     Tk Built-In Commands                     winfo(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       winfo - Return window-related information
9

SYNOPSIS

11       winfo option ?arg arg ...?
12______________________________________________________________________________
13

DESCRIPTION

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.   An  empty string is also returned if the
67              point lies in the title bar or border of its highest  containing
68              toplevel  in this application.  (Note that with some window man‐
69              agers the borders may be invisible.)  In selecting the  contain‐
70              ing  window, children are given higher priority than parents and
71              among siblings the highest one in the stacking order is chosen.
72
73       winfo depth window
74              Returns a decimal string giving the depth of window  (number  of
75              bits per pixel).
76
77       winfo exists window
78              Returns  1  if  there exists a window named window, 0 if no such
79              window exists.
80
81       winfo fpixels window number
82              Returns a floating-point value giving the number  of  pixels  in
83              window  corresponding  to  the distance given by number.  Number
84              may  be  specified  in  any   of   the   forms   acceptable   to
85              Tk_GetScreenMM, such as “2.0c” or “1i”.  The return value may be
86              fractional;  for an integer value, use winfo pixels.
87
88       winfo geometry window
89              Returns the geometry for window, in the  form  widthxheight+x+y.
90              All dimensions are in pixels.
91
92       winfo height window
93              Returns a decimal string giving window's height in pixels.  When
94              a window is first created its  height  will  be  1  pixel;   the
95              height  will eventually be changed by a geometry manager to ful‐
96              fil the window's needs.  If you need the true height immediately
97              after  creating  a  widget,  invoke update to force the geometry
98              manager to arrange it, or use winfo reqheight to  get  the  win‐
99              dow's requested height instead of its actual height.
100
101       winfo id window
102              Returns  a  hexadecimal  string giving a low-level platform-spe‐
103              cific identifier for window.  On Unix platforms, this is  the  X
104              window identifier.  Under Windows, this is the Windows HWND.  On
105              the Macintosh the value has no meaning outside Tk.
106
107       winfo interps ?-displayof window?
108              Returns a list whose members are the names  of  all  Tcl  inter‐
109              preters  (e.g.  all  Tk-based applications) currently registered
110              for a particular display.  If the  -displayof  option  is  given
111              then  the  return value refers to the display of window;  other‐
112              wise it refers to the display of the application's main window.
113
114       winfo ismapped window
115              Returns 1 if window is currently mapped, 0 otherwise.
116
117       winfo manager window
118              Returns the name of the geometry manager  currently  responsible
119              for  window,  or an empty string if window is not managed by any
120              geometry manager.  The name is usually the name of the Tcl  com‐
121              mand  for  the  geometry manager, such as pack or place.  If the
122              geometry manager is a widget, such as canvases or text, the name
123              is the widget's class command, such as canvas.
124
125       winfo name window
126              Returns  window's  name  (i.e.  its  name  within its parent, as
127              opposed to its full path name).  The command winfo name  .  will
128              return the name of the application.
129
130       winfo parent window
131              Returns  the path name of window's parent, or an empty string if
132              window is the main window of the application.
133
134       winfo pathname ?-displayof window? id
135              Returns the path name of the window whose X  identifier  is  id.
136              Id  must  be  a  decimal, hexadecimal, or octal integer and must
137              correspond to a window in  the  invoking  application.   If  the
138              -displayof  option  is given then the identifier is looked up on
139              the display of window;  otherwise it is looked up on the display
140              of the application's main window.
141
142       winfo pixels window number
143              Returns the number of pixels in window corresponding to the dis‐
144              tance given by number.  Number may be specified in  any  of  the
145              forms  acceptable  to Tk_GetPixels, such as “2.0c” or “1i”.  The
146              result is rounded to the nearest integer  value;   for  a  frac‐
147              tional result, use winfo fpixels.
148
149       winfo pointerx window
150              If  the  mouse  pointer is on the same screen as window, returns
151              the pointer's x coordinate, measured in pixels in  the  screen's
152              root  window.  If a virtual root window is in use on the screen,
153              the position is measured in the  virtual  root.   If  the  mouse
154              pointer is not on the same screen as window then -1 is returned.
155
156       winfo pointerxy window
157              If  the mouse pointer is on the same screen as window, returns a
158              list with two elements, which are the pointer's x and y  coordi‐
159              nates measured in pixels in the screen's root window.  If a vir‐
160              tual root window is in use on the screen, the position  is  com‐
161              puted  in  the virtual root.  If the mouse pointer is not on the
162              same screen as window then both of the returned coordinates  are
163              -1.
164
165       winfo pointery window
166              If  the  mouse  pointer is on the same screen as window, returns
167              the pointer's y coordinate, measured in pixels in  the  screen's
168              root  window.  If a virtual root window is in use on the screen,
169              the position is computed in the  virtual  root.   If  the  mouse
170              pointer is not on the same screen as window then -1 is returned.
171
172       winfo reqheight window
173              Returns  a  decimal  string giving window's requested height, in
174              pixels.  This is the value used by window's geometry manager  to
175              compute its geometry.
176
177       winfo reqwidth window
178              Returns  a  decimal  string  giving window's requested width, in
179              pixels.  This is the value used by window's geometry manager  to
180              compute its geometry.
181
182       winfo rgb window color
183              Returns a list containing three decimal values in the range 0 to
184              65535, which are the red, green, and blue intensities that  cor‐
185              respond  to  color  in the window given by window.  Color may be
186              specified in any of the forms acceptable for a color option.
187
188       winfo rootx window
189              Returns a decimal string giving the x-coordinate,  in  the  root
190              window  of the screen, of the upper-left corner of window's bor‐
191              der (or window if it has no border).
192
193       winfo rooty window
194              Returns a decimal string giving the y-coordinate,  in  the  root
195              window  of the screen, of the upper-left corner of window's bor‐
196              der (or window if it has no border).
197
198       winfo screen window
199              Returns the name of the screen associated with  window,  in  the
200              form displayName.screenIndex.
201
202       winfo screencells window
203              Returns  a  decimal  string  giving  the  number of cells in the
204              default color map for window's screen.
205
206       winfo screendepth window
207              Returns a decimal string giving the depth of the root window  of
208              window's screen (number of bits per pixel).
209
210       winfo screenheight window
211              Returns  a  decimal string giving the height of window's screen,
212              in pixels.
213
214       winfo screenmmheight window
215              Returns a decimal string giving the height of  window's  screen,
216              in millimeters.
217
218       winfo screenmmwidth window
219              Returns a decimal string giving the width of window's screen, in
220              millimeters.
221
222       winfo screenvisual window
223              Returns one of the following strings  to  indicate  the  default
224              visual  class for window's screen: directcolor, grayscale, pseu‐
225              docolor, staticcolor, staticgray, or truecolor.
226
227       winfo screenwidth window
228              Returns a decimal string giving the width of window's screen, in
229              pixels.
230
231       winfo server window
232              Returns  a  string  containing  information about the server for
233              window's display.  The exact format of this string may vary from
234              platform  to  platform.   For  X servers the string has the form
235XmajorRminor vendor vendorVersion” where major  and  minor  are
236              the  version  and revision numbers provided by the server (e.g.,
237              X11R5), vendor is the name of the vendor  for  the  server,  and
238              vendorRelease  is  an  integer  release  number  provided by the
239              server.
240
241       winfo toplevel window
242              Returns the path name of the top-of-hierarchy window  containing
243              window.   In  standard Tk this will always be a toplevel widget,
244              but extensions may create other kinds of  top-of-hierarchy  wid‐
245              gets.
246
247       winfo viewable window
248              Returns  1  if  window  and  all of its ancestors up through the
249              nearest toplevel window are mapped.  Returns 0 if any  of  these
250              windows are not mapped.
251
252       winfo visual window
253              Returns  one  of  the  following  strings to indicate the visual
254              class for window: directcolor, grayscale,  pseudocolor,  static‐
255              color, staticgray, or truecolor.
256
257       winfo visualid window
258              Returns the X identifier for the visual for window.
259
260       winfo visualsavailable window ?includeids?
261              Returns a list whose elements describe the visuals available for
262              window's screen.  Each element consists of a visual  class  fol‐
263              lowed  by  an  integer  depth.   The  class has the same form as
264              returned by winfo visual.  The depth gives the  number  of  bits
265              per  pixel  in the visual.  In addition, if the includeids argu‐
266              ment is provided, then the depth is followed by the X identifier
267              for the visual.
268
269       winfo vrootheight window
270              Returns  the  height  of the virtual root window associated with
271              window if there is one;  otherwise returns the  height  of  win‐
272              dow's screen.
273
274       winfo vrootwidth window
275              Returns  the  width  of  the virtual root window associated with
276              window if there is one;  otherwise returns the width of window's
277              screen.
278
279       winfo vrootx window
280              Returns  the x-offset of the virtual root window associated with
281              window, relative to the root window of its screen.  This is nor‐
282              mally either zero or negative.  Returns 0 if there is no virtual
283              root window for window.
284
285       winfo vrooty window
286              Returns the y-offset of the virtual root window associated  with
287              window, relative to the root window of its screen.  This is nor‐
288              mally either zero or negative.  Returns 0 if there is no virtual
289              root window for window.
290
291       winfo width window
292              Returns  a decimal string giving window's width in pixels.  When
293              a window is first created its width will be 1 pixel;  the  width
294              will  eventually  be changed by a geometry manager to fulfil the
295              window's needs.  If you need the true  width  immediately  after
296              creating  a  widget, invoke update to force the geometry manager
297              to arrange it,  or  use  winfo  reqwidth  to  get  the  window's
298              requested width instead of its actual width.
299
300       winfo x window
301              Returns  a  decimal  string giving the x-coordinate, in window's
302              parent, of the upper-left corner of window's border  (or  window
303              if it has no border).
304
305       winfo y window
306              Returns  a  decimal  string giving the y-coordinate, in window's
307              parent, of the upper-left corner of window's border  (or  window
308              if it has no border).
309

EXAMPLE

311       Print where the mouse pointer is and what window it is currently over:
312              lassign [winfo pointerxy .] x y
313              puts -nonewline "Mouse pointer at ($x,$y) which is "
314              set win [winfo containing $x $y]
315              if {$win eq ""} {
316                  puts "over no window"
317              } else {
318                  puts "over $win"
319              }
320

KEYWORDS

322       atom,  children,  class,  geometry,  height,  identifier,  information,
323       interpreters, mapped, parent, path name, screen, virtual  root,  width,
324       window
325
326
327
328Tk                                    4.3                             winfo(n)
Impressum