stk/Help/winfo.n.html

321 lines
15 KiB
HTML

<HTML><HEAD><TITLE>Tk Built-In Commands - winfo manual page</TITLE></HEAD>
<BR>
<BODY bgcolor = #c3c3ff>
<H2><IMG ALIGN=BOTTOM SRC="./Img/ManPageBlue.gif"> winfo</H2>
<I>Return window-related information</I><P><IMG ALIGN=TOP SRC="./Img/line-red.gif">
<H3><A NAME="M2">SYNOPSIS</A></H3>
(<B>winfo</B> <I>option </I>?<I>arg arg ...</I>?)<BR>
<H3><A NAME="M3">DESCRIPTION</A></H3>
The <B>winfo</B> procedure 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>
<DT><A NAME="M4">(<B>winfo 'atom </B> <I>name</I>)</A><DD>
<DT><A NAME="M5">(<B>winfo 'atom </B><B>:displayof </B><I>window</I> <I>name</I>)</A><DD>
Returns a 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> <I>id</I>)</A><DD>
<DT><A NAME="M7">(<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 procedure is the inverse of the <B>winfo atom</B> procedure.
It generates an error if no such atom exists.
<P>
<DT><A NAME="M8">(<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="M9">(<B>winfo 'children </B><I>window</I>)</A><DD>
Returns a list containing the path names of all the children
of <I>window</I>. Top-level windows are returned as children
of their logical parents.
<P>
<DT><A NAME="M10">(<B>winfo 'class </B><I>window</I>)</A><DD>
Returns the class name for <I>window</I>.
<P>
<DT><A NAME="M11">(<B>winfo 'colormapfull </B><I>window</I>)</A><DD>
Returns <B>#t</B> if the colormap for <I>window</I> is known to be full, <B>#f</B>
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="M12">(<B>winfo 'containing </B> <I>rootX rootY</I>)</A><DD>
<DT><A NAME="M13">(<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>Tk_GetPixels</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
list 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="M14">(<B>winfo 'depth </B><I>window</I>)</A><DD>
Returns an integer giving the depth of <I>window</I> (number
of bits per pixel).
<P>
<DT><A NAME="M15">(<B>winfo 'exists </B><I>window</I>)</A><DD>
Returns #t if there exists a window named <I>window</I>, #f if no such
window exists.
<P>
<DT><A NAME="M16">(<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>Tk_GetScreenMM</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="M17">(<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="M18">(<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="./update.n.html">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="M19">(<B>winfo 'id </B><I>window</I>)</A><DD>
Returns an integer indicating the X identifier for <I>window</I>.
<P>
<DT><A NAME="M20">(<B>winfo 'interps </B>)</A><DD>
<DT><A NAME="M21">(<B>winfo 'interps </B><B>:displayof </B><I>window</I>)</A><DD>
Returns a list whose members are the names of all STk 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="M22">(<B>winfo 'ismapped </B><I>window</I>)</A><DD>
Returns <B>#t</B> if <I>window</I> is currently mapped, <B>#f</B> otherwise.
<P>
<DT><A NAME="M23">(<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 list if <I>window</I>
isn't managed by any geometry manager.
The name is usually the name of the STk procedure for the geometry
manager, such as <B><A HREF="./pack.n.html">pack</A></B> or <B><A HREF="./place.n.html">place</A></B>.
If the geometry manager is a widget, such as canvases or text, the
name is the widget's class procedure, such as <B><A HREF="./canvas.n.html">canvas</A></B>.
<P>
<DT><A NAME="M24">(<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 procedure <B>(winfo name *root*)</B> will return the name of the application.
<P>
<DT><A NAME="M25">(<B>winfo 'parent </B><I>window</I>)</A><DD>
Returns the path name of <I>window</I>'s parent, or an empty list
if <I>window</I> is the main window of the application.
<P>
<DT><A NAME="M26">(<B>winfo 'pathname </B> <I>id</I>)</A><DD>
<DT><A NAME="M27">(<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="M28">(<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>Tk_GetPixels</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="M29">(<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="M30">(<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="M31">(<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="M32">(<B>winfo 'reqheight </B><I>window</I>)</A><DD>
Returns an integer 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="M33">(<B>winfo 'reqwidth </B><I>window</I>)</A><DD>
Returns an integer 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="M34">(<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="M35">(<B>winfo 'rootx </B><I>window</I>)</A><DD>
Returns an integer 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="M36">(<B>winfo 'rooty </B><I>window</I>)</A><DD>
Returns an integer 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="M37">(<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="M38">(<B>winfo 'screencells </B><I>window</I>)</A><DD>
Returns an integer giving the number of cells in the default
color map for <I>window</I>'s screen.
<P>
<DT><A NAME="M39">(<B>winfo 'screendepth </B><I>window</I>)</A><DD>
Returns an integer giving the depth of the root window
of <I>window</I>'s screen (number of bits per pixel).
<P>
<DT><A NAME="M40">(<B>winfo 'screenheight </B><I>window</I>)</A><DD>
Returns an integer giving the height of <I>window</I>'s screen,
in pixels.
<P>
<DT><A NAME="M41">(<B>winfo 'screenmmheight </B><I>window</I>)</A><DD>
Returns an integer giving the height of <I>window</I>'s screen,
in millimeters.
<P>
<DT><A NAME="M42"><B>winfo screenmmwidth </B><I>window</I></A><DD>
Returns an integer giving the width of <I>window</I>'s screen,
in millimeters.
<P>
<DT><A NAME="M43">(<B>winfo 'screenvisual </B><I>window</I>)</A><DD>
Returns one of the following symbol 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="M44">(<B>winfo 'screenwidth </B><I>window</I>)</A><DD>
Returns an integer giving the width of <I>window</I>'s screen,
in pixels.
<P>
<DT><A NAME="M45">(<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="M46">(<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="M47">(<B>winfo 'viewable </B><I>window</I>)</A><DD>
Returns <B>#t</B> if <I>window</I> and all of its ancestors up through the
nearest toplevel window are mapped. Returns <B>#f</B> if any of these
windows are not mapped.
<P>
<DT><A NAME="M48">(<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="M49">(<B>winfo 'visualid </B><I>window</I>)</A><DD>
Returns the X identifier for the visual for <I>window</I>.
<P>
<DT><A NAME="M50">(<B>winfo 'visualsavailable </B><I>window</I>)</A><DD>
<DT><A NAME="M51">(<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="M52">(<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="M53">(<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="M54">(<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="M55">(<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="M56">(<B>winfo 'width </B><I>window</I>)</A><DD>
Returns an integer 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="./update.n.html">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="M57">(<B>winfo 'x </B><I>window</I>)</A><DD>
Returns an integer 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="M58">(<B>winfo 'y </B><I>window</I>)</A><DD>
Returns an integer 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>
<P><IMG ALIGN=TOP SRC="./Img/line-red.gif"><P>
<A HREF=./STk-hlp.html><IMG ALIGN=BOTTOM SRC="./Img/RefBookBlue.gif"> Back to the <B>STk</B> main page</A>
</BODY></HTML>