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 the
53              last attempt to allocate a new color on that window  failed  and
54              this  application has not freed any colors in the colormap since
55              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 may be
84              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 is not 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”.   The
144              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 is not 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 is not  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 is not 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
233XmajorRminor  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-of-hierarchy window containing
241              window.  In standard Tk this will always be a  toplevel  widget,
242              but  extensions  may create other kinds of top-of-hierarchy wid‐
243              gets.
244
245       winfo viewable window
246              Returns 1 if window and all of  its  ancestors  up  through  the
247              nearest  toplevel  window are mapped.  Returns 0 if any of these
248              windows are not mapped.
249
250       winfo visual window
251              Returns one of the following  strings  to  indicate  the  visual
252              class  for  window: directcolor, grayscale, pseudocolor, static‐
253              color, staticgray, or truecolor.
254
255       winfo visualid window
256              Returns the X identifier for the visual for window.
257
258       winfo visualsavailable window ?includeids?
259              Returns a list whose elements describe the visuals available for
260              window's  screen.   Each element consists of a visual class fol‐
261              lowed by an integer depth.  The  class  has  the  same  form  as
262              returned  by  winfo  visual.  The depth gives the number of bits
263              per pixel in the visual.  In addition, if the  includeids  argu‐
264              ment is provided, then the depth is followed by the X identifier
265              for the visual.
266
267       winfo vrootheight window
268              Returns the height of the virtual root  window  associated  with
269              window  if  there  is one;  otherwise returns the height of win‐
270              dow's screen.
271
272       winfo vrootwidth window
273              Returns the width of the virtual  root  window  associated  with
274              window if there is one;  otherwise returns the width of window's
275              screen.
276
277       winfo vrootx window
278              Returns the x-offset of the virtual root window associated  with
279              window, relative to the root window of its screen.  This is nor‐
280              mally either zero or negative.  Returns 0 if there is no virtual
281              root window for window.
282
283       winfo vrooty window
284              Returns  the y-offset of the virtual root window associated with
285              window, relative to the root window of its screen.  This is nor‐
286              mally either zero or negative.  Returns 0 if there is no virtual
287              root window for window.
288
289       winfo width window
290              Returns a decimal string giving window's width in pixels.   When
291              a  window is first created its width will be 1 pixel;  the width
292              will eventually be changed by a geometry manager to fulfill  the
293              window's  needs.   If  you need the true width immediately after
294              creating a widget, invoke update to force the  geometry  manager
295              to  arrange  it,  or  use  winfo  reqwidth  to  get the window's
296              requested width instead of its actual width.
297
298       winfo x window
299              Returns a decimal string giving the  x-coordinate,  in  window's
300              parent,  of  the upper-left corner of window's border (or window
301              if it has no border).
302
303       winfo y window
304              Returns a decimal string giving the  y-coordinate,  in  window's
305              parent,  of  the upper-left corner of window's border (or window
306              if it has no border).
307

EXAMPLE

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

KEYWORDS

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