widget.html

来自「perl教程」· HTML 代码 · 共 854 行 · 第 1/3 页

HTML
854
字号
</li>
<dt><strong><a name="item_getimage"><em>$widget</em>-&gt;<strong>Getimage</strong>(<em>name</em>)</a></strong>

<dd>
<p>Given <em>name</em>, look for an image file with that base name and return
a <a href="../../lib/Tk/Image.html">the Tk::Image manpage</a>.  File extensions are tried in this order: <em>xpm</em>,
<em>gif</em>, <em>ppm</em>, <em>xbm</em> until a valid iamge is found.  If no image is
found, try a builtin image with that name.</p>
</dd>
</li>
<dt><strong><a name="item_geometry"><em>$widget</em>-&gt;<strong>geometry</strong></a></strong>

<dd>
<p>Returns the geometry for <em>$widget</em>, in the form
<em>width</em><strong>x</strong><em>height</em><strong>+</strong><em>x</em><strong>+</strong><em>y</em>.  All dimensions are
in pixels.</p>
</dd>
</li>
<dt><strong><a name="item_height"><em>$widget</em>-&gt;<strong>height</strong></a></strong>

<dd>
<p>Returns a decimal string giving <em>$widget</em>'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 <strong>update</strong> to force the geometry manager to arrange it,
or use <em>$widget</em>-&gt;<strong>reqheight</strong> to get the window's requested height
instead of its actual height.</p>
</dd>
</li>
<dt><strong><a name="item_id"><em>$widget</em>-&gt;<strong>id</strong></a></strong>

<dd>
<p>Returns a hexadecimal string giving a low-level platform-specific
identifier for $widget.  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>
</dd>
</li>
<dt><strong><a name="item_idletasks"><em>$widget</em>-&gt;<strong>idletasks</strong></a></strong>

<dd>
<p>One of two methods which are used to bring the application ``up to date''
by entering the event loop repeated until all pending events
(including idle callbacks) have been processed.</p>
</dd>
<dd>
<p>If the <strong>idletasks</strong> method is specified, then no new events or errors
are processed; only idle callbacks are invoked. This causes operations
that are normally deferred, such as display updates and window layout
calculations, to be performed immediately.</p>
</dd>
<dd>
<p>The <strong>idletasks</strong> command is useful in scripts where changes have been
made to the application's state and you want those changes to appear
on the display immediately, rather than waiting for the script to
complete. Most display updates are performed as idle callbacks, so
<strong>idletasks</strong> will cause them to run. However, there are some kinds of
updates that only happen in response to events, such as those
triggered by window size changes; these updates will not occur in
<strong>idletasks</strong>.</p>
</dd>
</li>
<dt><strong><a name="item_interps"><em>$widget</em>-&gt;<strong>interps</strong></a></strong>

<dd>
<p>Returns a list whose members are the names of all Tcl interpreters
(e.g. all Tk-based applications) currently registered for
a particular display.
The return value refers
to the display of <em>$widget</em>.</p>
</dd>
</li>
<dt><strong><a name="item_ismapped"><em>$widget</em>-&gt;<strong>ismapped</strong></a></strong>

<dd>
<p>Returns <strong>1</strong> if <em>$widget</em> is currently mapped, <strong>0</strong> otherwise.</p>
</dd>
</li>
<dt><strong><a name="item_lower"><em>$widget-</em>&gt;<strong>lower</strong>(?<em>belowThis</em>?)</a></strong>

<dd>
<p>If the <em>belowThis</em> argument is omitted then the command lowers
$widget so that it is below all of its siblings in the stacking
order (it will be obscured by any siblings that overlap it and
will not obscure any siblings).
If <em>belowThis</em> is specified then it must be the path name of
a window that is either a sibling of $widget or the descendant
of a sibling of $widget.
In this case the <strong>lower</strong> command will insert
$widget into the stacking order just below <em>belowThis</em>
(or the ancestor of <em>belowThis</em> that is a sibling of $widget);
this could end up either raising or lowering $widget.</p>
</dd>
</li>
<dt><strong><a name="item_mapwindow"><em>$widget</em>-&gt;<strong>MapWindow</strong></a></strong>

<dd>
<p>Cause <em>$widget</em> to be &quot;mapped&quot; i.e. made visible on the display.
May confuse the geometry manager (pack, grid, place, ...)
that thinks it is managing the widget.</p>
</dd>
</li>
<dt><strong><a name="item_manager"><em>$widget</em>-&gt;<strong>manager</strong></a></strong>

<dd>
<p>Returns the name of the geometry manager currently
responsible for <em>$widget</em>, or an empty string if <em>$widget</em>
isn't managed by any geometry manager.
The name is usually the name of the method for the geometry
manager, such as <strong>pack</strong> or <strong>place</strong>.
If the geometry manager is a widget, such as canvases or text, the
name is the widget's class command, such as <strong>canvas</strong>.</p>
</dd>
</li>
<dt><strong><a name="item_name"><em>$widget</em>-&gt;<strong>name</strong></a></strong>

<dd>
<p>Returns <em>$widget</em>'s name (i.e. its name within its parent, as opposed
to its full path name).
The command <em>$mainwin</em>-&gt;<strong>name</strong> will return the name of the application.</p>
</dd>
</li>
<dt><strong><a name="item_ondestroy"><em>$widget</em>-&gt;<strong>OnDestroy</strong>(<em>callback</em>);</a></strong>

<dd>
<p>OnDestroy accepts a standard perl/Tk <em>callback</em>.
When the window associated with <em>$widget</em> is destroyed then
the callback is invoked. Unlike <em>$widget-</em>&gt;bind('&lt;Destroy&gt;',...)
the widgets methods are still available when <em>callback</em> is executed,
so (for example) a <strong>Text</strong> widget can save its contents to a file.</p>
</dd>
<dd>
<p>OnDestroy was required for new <strong>after</strong> mechanism.</p>
</dd>
</li>
<dt><strong><a name="item_parent"><em>$widget</em>-&gt;<strong>parent</strong></a></strong>

<dd>
<p>Returns <em>$widget</em>'s parent, or an empty string
if <em>$widget</em> is the main window of the application.</p>
</dd>
</li>
<dt><strong><a name="item_pathname"><em>$widget</em>-&gt;<strong>PathName</strong></a></strong>

<dd>
<p>Returns the tk path name of <em>$widget</em>. (This is an import from the
C interface.)</p>
</dd>
</li>
<dt><strong><a name="item_pathname"><em>$widget</em>-&gt;<strong>pathname</strong>(<em>id</em>)</a></strong>

<dd>
<p>Returns an object whose X identifier is <em>id</em>.
The identifier is looked up on the display of <em>$widget</em>.
<em>Id</em> must be a decimal, hexadecimal, or octal integer and must
correspond to a window in the invoking application, or an error
occurs which can be trapped with <a href="../../lib/Pod/perlfunc.html#item_eval"><code>eval { }</code></a> or <code>Tk::catch { }</code>.
If the window belongs to the application, but is not an object
(for example wrapper windows, HList header, etc.) then <a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a>
is returned.</p>
</dd>
</li>
<dt><strong><a name="item_pixels"><em>$widget</em>-&gt;<strong>pixels</strong>(<em>number</em>)</a></strong>

<dd>
<p>Returns the number of pixels in <em>$widget</em> corresponding
to the distance given by <em>number</em>.
<em>Number</em> may be specified in any of the forms acceptable
to <strong>Tk_GetPixels</strong>, such as ``2.0c'' or ``1i''.
The result is rounded to the nearest integer value;  for a
fractional result, use <em>$widget</em>-&gt;<strong>fpixels</strong>.</p>
</dd>
</li>
<dt><strong><a name="item_pointerx"><em>$widget</em>-&gt;<strong>pointerx</strong></a></strong>

<dd>
<p>If the mouse pointer is on the same screen as <em>$widget</em>, 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 <em>$widget</em> then
-1 is returned.</p>
</dd>
</li>
<dt><strong><a name="item_pointerxy"><em>$widget</em>-&gt;<strong>pointerxy</strong></a></strong>

<dd>
<p>If the mouse pointer is on the same screen as <em>$widget</em>, 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 <em>$widget</em> then
both of the returned coordinates are -1.</p>
</dd>
</li>
<dt><strong><a name="item_pointery"><em>$widget</em>-&gt;<strong>pointery</strong></a></strong>

<dd>
<p>If the mouse pointer is on the same screen as <em>$widget</em>, 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 <em>$widget</em> then
-1 is returned.</p>
</dd>
</li>
<dt><strong><a name="item_raise"><em>$widget</em>-&gt;<strong>raise</strong>(?<em>aboveThis</em>?)</a></strong>

<dd>
<p>If the <em>aboveThis</em> argument is omitted then the command raises
$widget so that it is above all of its siblings in the stacking
order (it will not be obscured by any siblings and will obscure
any siblings that overlap it).
If <em>aboveThis</em> is specified then it must be the path name of
a window that is either a sibling of $widget or the descendant
of a sibling of $widget.
In this case the <strong>raise</strong> command will insert
$widget into the stacking order just above <em>aboveThis</em>
(or the ancestor of <em>aboveThis</em> that is a sibling of $widget);
this could end up either raising or lowering $widget.</p>
</dd>
</li>
<dt><strong><a name="item_reqheight"><em>$widget</em>-&gt;<strong>reqheight</strong></a></strong>

<dd>
<p>Returns a decimal string giving <em>$widget</em>'s requested height,
in pixels.  This is the value used by <em>$widget</em>'s geometry
manager to compute its geometry.</p>
</dd>
</li>
<dt><strong><a name="item_reqwidth"><em>$widget</em>-&gt;<strong>reqwidth</strong></a></strong>

<dd>
<p>Returns a decimal string giving <em>$widget</em>'s requested width,
in pixels.  This is the value used by <em>$widget</em>'s geometry
manager to compute its geometry.</p>
</dd>
</li>
<dt><strong><a name="item_rgb"><em>$widget</em>-&gt;<strong>rgb</strong>(<em>color</em>)</a></strong>

<dd>
<p>Returns a list containing three decimal values, which are the
red, green, and blue intensities that correspond to <em>color</em> in
the window given by <em>$widget</em>.  <em>Color</em>
may be specified in any of the forms acceptable for a color
option.</p>
</dd>
</li>
<dt><strong><a name="item_rootx"><em>$widget</em>-&gt;<strong>rootx</strong></a></strong>

<dd>
<p>Returns a decimal string giving the x-coordinate, in the root
window of the screen, of the
upper-left corner of <em>$widget</em>'s border (or <em>$widget</em> if it
has no border).</p>
</dd>
</li>
<dt><strong><a name="item_rooty"><em>$widget</em>-&gt;<strong>rooty</strong></a></strong>

<dd>
<p>Returns a decimal string giving the y-coordinate, in the root
window of the screen, of the
upper-left corner of <em>$widget</em>'s border (or <em>$widget</em> if it
has no border).</p>
</dd>
</li>
<dt><strong><a name="item_scaling"><strong>scaling</strong></a></strong>

<dt><strong><em>$widget</em>-&gt;<strong>scaling</strong>?(<em>number</em>)?</strong>

<dd>
<p>Sets and queries the current scaling factor used by Tk to convert between
physical units (for example, points, inches, or millimeters) and pixels.  The
<em>number</em> argument is a floating point number that specifies the number of
pixels per point on $widget's display. If the <em>number</em> argument is
omitted, the current value of the scaling factor is returned.</p>
</dd>
<dd>
<p>A ``point'' is a unit of measurement equal to 1/72 inch.  A scaling factor
of 1.0 corresponds to 1 pixel per point, which is equivalent to a standard
72 dpi monitor.  A scaling factor of 1.25 would mean 1.25 pixels per point,
which is the setting for a 90 dpi monitor; setting the scaling factor to

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?