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
14

DESCRIPTION

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

EXAMPLE

306       Print where the mouse pointer is and what window it is currently over:
307              set x [winfo pointerx .]
308              set y [winfo pointery .]
309              puts -nonewline "Mouse pointer at ($x,$y) which is "
310              set win [winfo containing $x $y]
311              if {$win eq ""} {
312                  puts "over no window"
313              } else {
314                  puts "over $win"
315              }
316
317

KEYWORDS

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)
Impressum