projman/hlp/en/tk/winfo.htm

333 lines
20 KiB
HTML
Raw Normal View History

2015-10-19 13:27:31 +03:00
<HTML><HEAD><TITLE>Tk Built-In Commands - winfo manual page</TITLE></HEAD><BODY>
<DL>
<DD><A HREF="winfo.htm#M2" NAME="L1230">NAME</A>
<DL><DD>winfo - Return window-related information</DL>
<DD><A HREF="winfo.htm#M3" NAME="L1231">SYNOPSIS</A>
<DL>
<DD><B>winfo</B> <I>option </I>?<I>arg arg ...</I>?
</DL>
<DD><A HREF="winfo.htm#M4" NAME="L1232">DESCRIPTION</A>
<DL>
<DD><A HREF="winfo.htm#M5" NAME="L1233"><B>winfo atom </B>?<B>-displayof </B><I>window</I>? <I>name</I></A>
<DD><A HREF="winfo.htm#M6" NAME="L1234"><B>winfo atomname </B>?<B>-displayof </B><I>window</I>? <I>id</I></A>
<DD><A HREF="winfo.htm#M7" NAME="L1235"><B>winfo cells </B><I>window</I></A>
<DD><A HREF="winfo.htm#M8" NAME="L1236"><B>winfo children </B><I>window</I></A>
<DD><A HREF="winfo.htm#M9" NAME="L1237"><B>winfo class </B><I>window</I></A>
<DD><A HREF="winfo.htm#M10" NAME="L1238"><B>winfo colormapfull </B><I>window</I></A>
<DD><A HREF="winfo.htm#M11" NAME="L1239"><B>winfo containing </B>?<B>-displayof </B><I>window</I>? <I>rootX rootY</I></A>
<DD><A HREF="winfo.htm#M12" NAME="L1240"><B>winfo depth </B><I>window</I></A>
<DD><A HREF="winfo.htm#M13" NAME="L1241"><B>winfo exists </B><I>window</I></A>
<DD><A HREF="winfo.htm#M14" NAME="L1242"><B>winfo fpixels </B><I>window</I> <I>number</I></A>
<DD><A HREF="winfo.htm#M15" NAME="L1243"><B>winfo geometry </B><I>window</I></A>
<DD><A HREF="winfo.htm#M16" NAME="L1244"><B>winfo height </B><I>window</I></A>
<DD><A HREF="winfo.htm#M17" NAME="L1245"><B>winfo id </B><I>window</I></A>
<DD><A HREF="winfo.htm#M18" NAME="L1246"><B>winfo interps </B>?<B>-displayof </B><I>window</I>?</A>
<DD><A HREF="winfo.htm#M19" NAME="L1247"><B>winfo ismapped </B><I>window</I></A>
<DD><A HREF="winfo.htm#M20" NAME="L1248"><B>winfo manager </B><I>window</I></A>
<DD><A HREF="winfo.htm#M21" NAME="L1249"><B>winfo name </B><I>window</I></A>
<DD><A HREF="winfo.htm#M22" NAME="L1250"><B>winfo parent </B><I>window</I></A>
<DD><A HREF="winfo.htm#M23" NAME="L1251"><B>winfo pathname </B>?<B>-displayof </B><I>window</I>? <I>id</I></A>
<DD><A HREF="winfo.htm#M24" NAME="L1252"><B>winfo pixels </B><I>window</I> <I>number</I></A>
<DD><A HREF="winfo.htm#M25" NAME="L1253"><B>winfo pointerx </B><I>window</I></A>
<DD><A HREF="winfo.htm#M26" NAME="L1254"><B>winfo pointerxy </B><I>window</I></A>
<DD><A HREF="winfo.htm#M27" NAME="L1255"><B>winfo pointery </B><I>window</I></A>
<DD><A HREF="winfo.htm#M28" NAME="L1256"><B>winfo reqheight </B><I>window</I></A>
<DD><A HREF="winfo.htm#M29" NAME="L1257"><B>winfo reqwidth </B><I>window</I></A>
<DD><A HREF="winfo.htm#M30" NAME="L1258"><B>winfo rgb </B><I>window color</I></A>
<DD><A HREF="winfo.htm#M31" NAME="L1259"><B>winfo rootx </B><I>window</I></A>
<DD><A HREF="winfo.htm#M32" NAME="L1260"><B>winfo rooty </B><I>window</I></A>
<DD><A HREF="winfo.htm#M33" NAME="L1261"><B>winfo screen </B><I>window</I></A>
<DD><A HREF="winfo.htm#M34" NAME="L1262"><B>winfo screencells </B><I>window</I></A>
<DD><A HREF="winfo.htm#M35" NAME="L1263"><B>winfo screendepth </B><I>window</I></A>
<DD><A HREF="winfo.htm#M36" NAME="L1264"><B>winfo screenheight </B><I>window</I></A>
<DD><A HREF="winfo.htm#M37" NAME="L1265"><B>winfo screenmmheight </B><I>window</I></A>
<DD><A HREF="winfo.htm#M38" NAME="L1266"><B>winfo screenmmwidth </B><I>window</I></A>
<DD><A HREF="winfo.htm#M39" NAME="L1267"><B>winfo screenvisual </B><I>window</I></A>
<DD><A HREF="winfo.htm#M40" NAME="L1268"><B>winfo screenwidth </B><I>window</I></A>
<DD><A HREF="winfo.htm#M41" NAME="L1269"><B>winfo server </B><I>window</I></A>
<DD><A HREF="winfo.htm#M42" NAME="L1270"><B>winfo toplevel </B><I>window</I></A>
<DD><A HREF="winfo.htm#M43" NAME="L1271"><B>winfo viewable </B><I>window</I></A>
<DD><A HREF="winfo.htm#M44" NAME="L1272"><B>winfo visual </B><I>window</I></A>
<DD><A HREF="winfo.htm#M45" NAME="L1273"><B>winfo visualid </B><I>window</I></A>
<DD><A HREF="winfo.htm#M46" NAME="L1274"><B>winfo visualsavailable </B><I>window</I> ?<B>includeids</B>?</A>
<DD><A HREF="winfo.htm#M47" NAME="L1275"><B>winfo vrootheight </B><I>window</I></A>
<DD><A HREF="winfo.htm#M48" NAME="L1276"><B>winfo vrootwidth </B><I>window</I></A>
<DD><A HREF="winfo.htm#M49" NAME="L1277"><B>winfo vrootx </B><I>window</I></A>
<DD><A HREF="winfo.htm#M50" NAME="L1278"><B>winfo vrooty </B><I>window</I></A>
<DD><A HREF="winfo.htm#M51" NAME="L1279"><B>winfo width </B><I>window</I></A>
<DD><A HREF="winfo.htm#M52" NAME="L1280"><B>winfo x </B><I>window</I></A>
<DD><A HREF="winfo.htm#M53" NAME="L1281"><B>winfo y </B><I>window</I></A>
</DL>
<DD><A HREF="winfo.htm#M54" NAME="L1282">KEYWORDS</A>
</DL><HR>
<H3><A NAME="M2">NAME</A></H3>
winfo - Return window-related information
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>winfo</B> <I>option </I>?<I>arg arg ...</I>?<BR>
<H3><A NAME="M4">DESCRIPTION</A></H3>
The <B>winfo</B> command is used to retrieve information about windows
managed by Tk. It can take any of a number of different forms,
depending on the <I>option</I> argument. The legal forms are:
<P>
<DL>
<P><DT><A NAME="M5"><B>winfo atom </B>?<B>-displayof </B><I>window</I>? <I>name</I></A><DD>
Returns a decimal string giving the integer identifier for the
atom whose name is <I>name</I>. If no atom exists with the name
<I>name</I> then a new one is created.
If the <B>-displayof</B> option is given then the atom is looked
up on the display of <I>window</I>; otherwise it is looked up on
the display of the application's main window.
<P><DT><A NAME="M6"><B>winfo atomname </B>?<B>-displayof </B><I>window</I>? <I>id</I></A><DD>
Returns the textual name for the atom whose integer identifier is
<I>id</I>.
If the <B>-displayof</B> option is given then the identifier is looked
up on the display of <I>window</I>; otherwise it is looked up on
the display of the application's main window.
This command is the inverse of the <B>winfo atom</B> command.
It generates an error if no such atom exists.
<P><DT><A NAME="M7"><B>winfo cells </B><I>window</I></A><DD>
Returns a decimal string giving the number of cells in the
color map for <I>window</I>.
<P><DT><A NAME="M8"><B>winfo children </B><I>window</I></A><DD>
Returns a list containing the path names of all the children
of <I>window</I>. The list is in stacking order, with the lowest
window first. Top-level windows are returned as children
of their logical parents.
<P><DT><A NAME="M9"><B>winfo class </B><I>window</I></A><DD>
Returns the class name for <I>window</I>.
<P><DT><A NAME="M10"><B>winfo colormapfull </B><I>window</I></A><DD>
Returns 1 if the colormap for <I>window</I> is known to be full, 0
otherwise. The colormap for a window is ``known'' to be full if the last
attempt to allocate a new color on that window failed and this
application hasn't freed any colors in the colormap since the
failed allocation.
<P><DT><A NAME="M11"><B>winfo containing </B>?<B>-displayof </B><I>window</I>? <I>rootX rootY</I></A><DD>
Returns the path name for the window containing the point given
by <I>rootX</I> and <I>rootY</I>.
<I>RootX</I> and <I>rootY</I> are specified in screen units (i.e.
any form acceptable to <B><A HREF="../TclLib/GetPixels.htm">Tk_GetPixels</A></B>) in the coordinate
system of the root window (if a virtual-root window manager is in
use then the coordinate system of the virtual root window is used).
If the <B>-displayof</B> option is given then the coordinates refer
to the screen containing <I>window</I>; otherwise they refer to the
screen of the application's main window.
If no window in this application contains the point then an empty
string is returned.
In selecting the containing window, children are given higher priority
than parents and among siblings the highest one in the stacking order is
chosen.
<P><DT><A NAME="M12"><B>winfo depth </B><I>window</I></A><DD>
Returns a decimal string giving the depth of <I>window</I> (number
of bits per pixel).
<P><DT><A NAME="M13"><B>winfo exists </B><I>window</I></A><DD>
Returns 1 if there exists a window named <I>window</I>, 0 if no such
window exists.
<P><DT><A NAME="M14"><B>winfo fpixels </B><I>window</I> <I>number</I></A><DD>
Returns a floating-point value giving the number of pixels
in <I>window</I> corresponding to the distance given by <I>number</I>.
<I>Number</I> may be specified in any of the forms acceptable
to <B><A HREF="../TclLib/GetPixels.htm">Tk_GetScreenMM</A></B>, such as ``2.0c'' or ``1i''.
The return value may be fractional; for an integer value, use
<B>winfo pixels</B>.
<P><DT><A NAME="M15"><B>winfo geometry </B><I>window</I></A><DD>
Returns the geometry for <I>window</I>, in the form
<I>width</I><B>x</B><I>height</I><B>+</B><I>x</I><B>+</B><I>y</I>. All dimensions are
in pixels.
<P><DT><A NAME="M16"><B>winfo height </B><I>window</I></A><DD>
Returns a decimal string giving <I>window</I>'s height in pixels.
When a window is first created its height will be 1 pixel; the
height will eventually be changed by a geometry manager to fulfill
the window's needs.
If you need the true height immediately after creating a widget,
invoke <B><A HREF="../TkCmd/update.htm">update</A></B> to force the geometry manager to arrange it,
or use <B>winfo reqheight</B> to get the window's requested height
instead of its actual height.
<P><DT><A NAME="M17"><B>winfo id </B><I>window</I></A><DD>
Returns a hexadecimal string giving a low-level platform-specific
identifier for <I>window</I>. On Unix platforms, this is the X
window identifier. Under Windows, this is the Windows
HWND. On the Macintosh the value has no meaning outside Tk.
<P><DT><A NAME="M18"><B>winfo interps </B>?<B>-displayof </B><I>window</I>?</A><DD>
Returns a list whose members are the names of all Tcl interpreters
(e.g. all Tk-based applications) currently registered for a particular display.
If the <B>-displayof</B> option is given then the return value refers
to the display of <I>window</I>; otherwise it refers to
the display of the application's main window.
<P><DT><A NAME="M19"><B>winfo ismapped </B><I>window</I></A><DD>
Returns <B>1</B> if <I>window</I> is currently mapped, <B>0</B> otherwise.
<P><DT><A NAME="M20"><B>winfo manager </B><I>window</I></A><DD>
Returns the name of the geometry manager currently
responsible for <I>window</I>, or an empty string if <I>window</I>
isn't managed by any geometry manager.
The name is usually the name of the Tcl command for the geometry
manager, such as <B><A HREF="../TclCmd/pack.htm">pack</A></B> or <B><A HREF="../TclCmd/place.htm">place</A></B>.
If the geometry manager is a widget, such as canvases or text, the
name is the widget's class command, such as <B><A HREF="../TclCmd/canvas.htm">canvas</A></B>.
<P><DT><A NAME="M21"><B>winfo name </B><I>window</I></A><DD>
Returns <I>window</I>'s name (i.e. its name within its parent, as opposed
to its full path name).
The command <B>winfo name .</B> will return the name of the application.
<P><DT><A NAME="M22"><B>winfo parent </B><I>window</I></A><DD>
Returns the path name of <I>window</I>'s parent, or an empty string
if <I>window</I> is the main window of the application.
<P><DT><A NAME="M23"><B>winfo pathname </B>?<B>-displayof </B><I>window</I>? <I>id</I></A><DD>
Returns the path name of the window whose X identifier is <I>id</I>.
<I>Id</I> must be a decimal, hexadecimal, or octal integer and must
correspond to a window in the invoking application.
If the <B>-displayof</B> option is given then the identifier is looked
up on the display of <I>window</I>; otherwise it is looked up on
the display of the application's main window.
<P><DT><A NAME="M24"><B>winfo pixels </B><I>window</I> <I>number</I></A><DD>
Returns the number of pixels in <I>window</I> corresponding
to the distance given by <I>number</I>.
<I>Number</I> may be specified in any of the forms acceptable
to <B><A HREF="../TclLib/GetPixels.htm">Tk_GetPixels</A></B>, such as ``2.0c'' or ``1i''.
The result is rounded to the nearest integer value; for a
fractional result, use <B>winfo fpixels</B>.
<P><DT><A NAME="M25"><B>winfo pointerx </B><I>window</I></A><DD>
If the mouse pointer is on the same screen as <I>window</I>, returns the
pointer's x coordinate, measured in pixels in the screen's root window.
If a virtual root window is in use on the screen, the position is
measured in the virtual root.
If the mouse pointer isn't on the same screen as <I>window</I> then
-1 is returned.
<P><DT><A NAME="M26"><B>winfo pointerxy </B><I>window</I></A><DD>
If the mouse pointer is on the same screen as <I>window</I>, returns a list
with two elements, which are the pointer's x and y coordinates measured
in pixels in the screen's root window.
If a virtual root window is in use on the screen, the position
is computed in the virtual root.
If the mouse pointer isn't on the same screen as <I>window</I> then
both of the returned coordinates are -1.
<P><DT><A NAME="M27"><B>winfo pointery </B><I>window</I></A><DD>
If the mouse pointer is on the same screen as <I>window</I>, returns the
pointer's y coordinate, measured in pixels in the screen's root window.
If a virtual root window is in use on the screen, the position
is computed in the virtual root.
If the mouse pointer isn't on the same screen as <I>window</I> then
-1 is returned.
<P><DT><A NAME="M28"><B>winfo reqheight </B><I>window</I></A><DD>
Returns a decimal string giving <I>window</I>'s requested height,
in pixels. This is the value used by <I>window</I>'s geometry
manager to compute its geometry.
<P><DT><A NAME="M29"><B>winfo reqwidth </B><I>window</I></A><DD>
Returns a decimal string giving <I>window</I>'s requested width,
in pixels. This is the value used by <I>window</I>'s geometry
manager to compute its geometry.
<P><DT><A NAME="M30"><B>winfo rgb </B><I>window color</I></A><DD>
Returns a list containing three decimal values, which are the
red, green, and blue intensities that correspond to <I>color</I> in
the window given by <I>window</I>. <I>Color</I>
may be specified in any of the forms acceptable for a color
option.
<P><DT><A NAME="M31"><B>winfo rootx </B><I>window</I></A><DD>
Returns a decimal string giving the x-coordinate, in the root
window of the screen, of the
upper-left corner of <I>window</I>'s border (or <I>window</I> if it
has no border).
<P><DT><A NAME="M32"><B>winfo rooty </B><I>window</I></A><DD>
Returns a decimal string giving the y-coordinate, in the root
window of the screen, of the
upper-left corner of <I>window</I>'s border (or <I>window</I> if it
has no border).
<P><DT><A NAME="M33"><B>winfo screen </B><I>window</I></A><DD>
Returns the name of the screen associated with <I>window</I>, in
the form <I>displayName</I>.<I>screenIndex</I>.
<P><DT><A NAME="M34"><B>winfo screencells </B><I>window</I></A><DD>
Returns a decimal string giving the number of cells in the default
color map for <I>window</I>'s screen.
<P><DT><A NAME="M35"><B>winfo screendepth </B><I>window</I></A><DD>
Returns a decimal string giving the depth of the root window
of <I>window</I>'s screen (number of bits per pixel).
<P><DT><A NAME="M36"><B>winfo screenheight </B><I>window</I></A><DD>
Returns a decimal string giving the height of <I>window</I>'s screen,
in pixels.
<P><DT><A NAME="M37"><B>winfo screenmmheight </B><I>window</I></A><DD>
Returns a decimal string giving the height of <I>window</I>'s screen,
in millimeters.
<P><DT><A NAME="M38"><B>winfo screenmmwidth </B><I>window</I></A><DD>
Returns a decimal string giving the width of <I>window</I>'s screen,
in millimeters.
<P><DT><A NAME="M39"><B>winfo screenvisual </B><I>window</I></A><DD>
Returns one of the following strings to indicate the default visual
class for <I>window</I>'s screen: <B>directcolor</B>, <B>grayscale</B>,
<B>pseudocolor</B>, <B>staticcolor</B>, <B>staticgray</B>, or
<B>truecolor</B>.
<P><DT><A NAME="M40"><B>winfo screenwidth </B><I>window</I></A><DD>
Returns a decimal string giving the width of <I>window</I>'s screen,
in pixels.
<P><DT><A NAME="M41"><B>winfo server </B><I>window</I></A><DD>
Returns a string containing information about the server for
<I>window</I>'s display. The exact format of this string may vary
from platform to platform. For X servers the string
has the form ``<B>X</B><I>major</I><B>R</B><I>minor vendor vendorVersion</I>''
where <I>major</I> and <I>minor</I> are the version and revision
numbers provided by the server (e.g., <B>X11R5</B>), <I>vendor</I>
is the name of the vendor for the server, and <I>vendorRelease</I>
is an integer release number provided by the server.
<P><DT><A NAME="M42"><B>winfo toplevel </B><I>window</I></A><DD>
Returns the path name of the top-level window containing <I>window</I>.
<P><DT><A NAME="M43"><B>winfo viewable </B><I>window</I></A><DD>
Returns 1 if <I>window</I> and all of its ancestors up through the
nearest toplevel window are mapped. Returns 0 if any of these
windows are not mapped.
<P><DT><A NAME="M44"><B>winfo visual </B><I>window</I></A><DD>
Returns one of the following strings to indicate the visual
class for <I>window</I>: <B>directcolor</B>, <B>grayscale</B>,
<B>pseudocolor</B>, <B>staticcolor</B>, <B>staticgray</B>, or
<B>truecolor</B>.
<P><DT><A NAME="M45"><B>winfo visualid </B><I>window</I></A><DD>
Returns the X identifier for the visual for <I>window</I>.
<P><DT><A NAME="M46"><B>winfo visualsavailable </B><I>window</I> ?<B>includeids</B>?</A><DD>
Returns a list whose elements describe the visuals available for
<I>window</I>'s screen.
Each element consists of a visual class followed by an integer depth.
The class has the same form as returned by <B>winfo visual</B>.
The depth gives the number of bits per pixel in the visual.
In addition, if the <B>includeids</B> argument is provided, then the
depth is followed by the X identifier for the visual.
<P><DT><A NAME="M47"><B>winfo vrootheight </B><I>window</I></A><DD>
Returns the height of the virtual root window associated with <I>window</I>
if there is one; otherwise returns the height of <I>window</I>'s screen.
<P><DT><A NAME="M48"><B>winfo vrootwidth </B><I>window</I></A><DD>
Returns the width of the virtual root window associated with <I>window</I>
if there is one; otherwise returns the width of <I>window</I>'s screen.
<P><DT><A NAME="M49"><B>winfo vrootx </B><I>window</I></A><DD>
Returns the x-offset of the virtual root window associated with <I>window</I>,
relative to the root window of its screen.
This is normally either zero or negative.
Returns 0 if there is no virtual root window for <I>window</I>.
<P><DT><A NAME="M50"><B>winfo vrooty </B><I>window</I></A><DD>
Returns the y-offset of the virtual root window associated with <I>window</I>,
relative to the root window of its screen.
This is normally either zero or negative.
Returns 0 if there is no virtual root window for <I>window</I>.
<P><DT><A NAME="M51"><B>winfo width </B><I>window</I></A><DD>
Returns a decimal string giving <I>window</I>'s width in pixels.
When a window is first created its width will be 1 pixel; the
width will eventually be changed by a geometry manager to fulfill
the window's needs.
If you need the true width immediately after creating a widget,
invoke <B><A HREF="../TkCmd/update.htm">update</A></B> to force the geometry manager to arrange it,
or use <B>winfo reqwidth</B> to get the window's requested width
instead of its actual width.
<P><DT><A NAME="M52"><B>winfo x </B><I>window</I></A><DD>
Returns a decimal string giving the x-coordinate, in <I>window</I>'s
parent, of the
upper-left corner of <I>window</I>'s border (or <I>window</I> if it
has no border).
<P><DT><A NAME="M53"><B>winfo y </B><I>window</I></A><DD>
Returns a decimal string giving the y-coordinate, in <I>window</I>'s
parent, of the
upper-left corner of <I>window</I>'s border (or <I>window</I> if it
has no border).
<P></DL>
<H3><A NAME="M54">KEYWORDS</A></H3>
<A href="../Keywords/A.htm#atom">atom</A>, <A href="../Keywords/C.htm#children">children</A>, <A href="../Keywords/C.htm#class">class</A>, <A href="../Keywords/G.htm#geometry">geometry</A>, <A href="../Keywords/H.htm#height">height</A>, <A href="../Keywords/I.htm#identifier">identifier</A>, <A href="../Keywords/I.htm#information">information</A>, <A href="../Keywords/I.htm#interpreters">interpreters</A>, <A href="../Keywords/M.htm#mapped">mapped</A>, <A href="../Keywords/P.htm#parent">parent</A>, <A href="../Keywords/P.htm#path name">path name</A>, <A href="../Keywords/S.htm#screen">screen</A>, <A href="../Keywords/V.htm#virtual root">virtual root</A>, <A href="../Keywords/W.htm#width">width</A>, <A href="../Keywords/W.htm#window">window</A>
<HR><PRE>
<A HREF="../copyright.htm">Copyright</A> &#169; 1990-1994 The Regents of the University of California.
<A HREF="../copyright.htm">Copyright</A> &#169; 1994-1997 Sun Microsystems, Inc.
<A HREF="../copyright.htm">Copyright</A> &#169; 1995-1997 Roger E. Critchlow Jr.</PRE>
</BODY></HTML>