⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 options.html

📁 perl教程
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>Tk::options - Standard options supported by widgets and their manipulation</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>Tk::options - Standard options supported by widgets and their manipulation</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<ul>

		<li><a href="#creation_options__widget_name_and_class">Creation options: Widget Name and Class</a></li>
		<li><a href="#reconfigurable_options">Reconfigurable options</a></li>
	</ul>

	<li><a href="#see_also">SEE ALSO</a></li>
	<li><a href="#keywords">KEYWORDS</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Tk::options - Standard options supported by widgets and their manipulation</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<em>$value</em> = <em>$widget</em>-&gt;<strong>cget</strong>('<em>-option</em>');</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<em>$widget</em>-&gt;<strong>configure</strong>(<em>-option</em>=&gt;<em>value</em> ?,<em>-option</em>=&gt;<em>value</em> ...?);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<em>@list</em> = <em>$widget</em>-&gt;<strong>configure</strong>('<em>-option</em>');</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<em>@lol</em> = <em>$widget</em>-&gt;<strong>configure</strong>;</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>All widgets, and images have a standard mechanism for setting and querying
attibutes or options. The mechanism is based on two methods <strong>configure</strong>
and <strong>cget</strong>. The behaviour of these methods is as follows:</p>
<dl>
<dt><strong><a name="item_configure"><em>$widget</em>-&gt;<strong>configure</strong>(<em>-option</em>=&gt;<em>value</em> ?,<em>-option</em>=&gt;<em>value</em> ...?);</a></strong>

<dd>
<p>Sets the values of <em>-option</em> to <em>value</em> for each <em>-option</em>=&gt;<em>value</em>
pair. The internal <strong>new</strong> method does an implicit <strong>configure</strong> in this
form with options passed in at widget create time.</p>
</dd>
</li>
<dt><strong><em>$widget</em>-&gt;<strong>configure</strong>('<em>-option</em>')</strong>

<dd>
<p>In array context returns a list of five or two elements.  If <em>-option</em>
is an alias for another options it return a list consisting of the
alias option and the name for the option is is an alias for, e.g.,
<code>('-bg', 'background')</code>.  If <em>-option</em> is not an alias the returned
list has the following five elements:</p>
</dd>
<dl>
<dt><strong><a name="item_option_name"><em>Option Name</em></a></strong>

<dd>
<p>The value of <em>-option</em>, e.g., <strong>-background</strong>.</p>
</dd>
</li>
<dt><strong><a name="item_name"><em>Name</em></a></strong>

<dd>
<p>The option's name in the option database, e.g., <code>background</code>.</p>
</dd>
</li>
<dt><strong><a name="item_class"><em>Class</em></a></strong>

<dd>
<p>The option's class value in the option database, e.g., <code>Background</code>.</p>
</dd>
</li>
<dt><strong><a name="item_default"><em>Default</em></a></strong>

<dd>
<p>The default value for the option if not specified or in the option database,
e.g., <code>grey</code>.</p>
</dd>
</li>
<dt><strong><a name="item_value"><em>Value</em></a></strong>

<dd>
<p>The current value (as returned by <strong>cget</strong>), e.g., <code>white</code>.</p>
</dd>
</li>
</dl>
<dt><strong><em>$widget</em>-&gt;<strong>configure</strong></strong>

<dd>
<p>Returns a list of lists for all the options supported by <em>$widget</em>.
Each sub-list is in the form returned by <strong>configure</strong>('<em>-option</em>').
(This mechanism is used by the <strong>Tk::Derived</strong> class to determine
the options available from base class.)</p>
</dd>
</li>
<dt><strong><a name="item_cget"><em>$widget</em>-&gt;<strong>cget</strong>('<em>-option</em>')</a></strong>

<dd>
<p>Returns the current value of <em>-option</em> for <em>$widget</em>.</p>
</dd>
<dd>
<p><strong>cget</strong>('<em>-option</em>') is clumsy with the need for <strong>''</strong> due to perl's
parsing rules. Something more subtle using <a href="../../lib/Pod/perlfunc.html#tie">tie</a> might look better.</p>
</dd>
</li>
</dl>
<p>The following paragraphs describe the common configuration options supported by
widgets in the Tk toolkit.  Every widget does not necessarily support every option
(see the the documentation entries for individual widgets for a list of the
standard options supported by that widget), but if a widget does support an option
with one of the names listed below, then the option has exactly the effect
described below.</p>
<p>In the descriptions below, ``Name'' refers to the option's name in the option
database.  ``Class'' refers to the option's class value
in the option database.  ``Switch'' refers to the switch used in widget-creation
and <strong>configure</strong> widget methods to set this value. For example, if an option's
configure option is <strong>-foreground</strong> and there exists a widget <em>$widget</em>, then the
call:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<em>$widget</em>-&gt;<strong>configure</strong>(<strong>-foreground</strong>=&gt;<strong>'black'</strong>)</p>
<p>may be used to specify the value <strong>black</strong> for the option in the widget <em>$widget</em>.
Configure options may be abbreviated, as long as the abbreviation is unambiguous
(abbreviation is deprecated in perl/Tk).</p>
<p>
</p>
<h2><a name="creation_options__widget_name_and_class">Creation options: Widget Name and Class</a></h2>
<p>The <strong>Name</strong> and <strong>-class</strong> options can only be specified when a widget is
created, and cannot be changed with <strong>configure</strong>.  These options determine
the widget's identity and how Tk applies resource values from the
option database (see <a href="../../lib/Tk/option.html">the Tk::option manpage</a>) and so they
cannot be assigned by the options database.</p>
<dl>
<dt><strong><a name="item_name_3a_name">Name:	<em>name</em></a></strong>

<dt><strong><a name="item_switch_3a_name">Switch:	<strong>Name</strong></a></strong>

<dd>
<p>Specifies the path element for the widget.  Names generally begin with a
lowercase letter.</p>
</dd>
<dd>
<p>Each widget has a unique <em>pathname</em> that follows the hierarchy from the
<strong>MainWindow</strong> to the widget itself.  Since the widget's <strong>PathName</strong> is
used to assign options from the options database, it is important to
specify a distinctive <strong>Name</strong> for any widget that will have non-default
options.  See <a href="../../lib/Tk/option.html">the Tk::option manpage</a> for details.</p>
</dd>
</li>
<dt><strong><a name="item_name_3a_class">Name:	<em>class</em></a></strong>

<dt><strong><a name="item_switch_3a__2dclass">Switch:	<strong>-class</strong></a></strong>

<dd>
<p>Specifies a class for the window.  Classes generally begin with an
uppercase letter.</p>
</dd>
<dd>
<p>This class will be used when querying the option database for
the window's other options (see Tk::options), and it will also be used
later for other purposes such as bindings.  One typically assigns a class
to a <strong>TopLevel</strong> or <strong>Frame</strong> so that the class will apply to all of
that widget's children.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="reconfigurable_options">Reconfigurable options</a></h2>
<p>These options can be set at widget creation or changed later via <strong>configure</strong>.</p>
<dl>
<dt><strong><a name="item_name_3a_activebackground">Name:	<strong>activeBackground</strong></a></strong>

<dt><strong><a name="item_class_3a_foreground">Class:	<strong>Foreground</strong></a></strong>

<dt><strong><a name="item_switch_3a__2dactivebackground">Switch:	<strong>-activebackground</strong></a></strong>

<dd>
<p>Specifies background color to use when drawing active elements.
An element (a widget or portion of a widget) is active if the
mouse cursor is positioned over the element and pressing a mouse button
will cause some action to occur.
If strict Motif compliance has been requested by setting the
<strong>$Tk::strictMotif</strong> variable, this option will normally be
ignored;  the normal background color will be used instead.
For some elements on Windows and Macintosh systems, the active color
will only be used while mouse button 1 is pressed over the element.</p>
</dd>
</li>
<dt><strong><a name="item_name_3a_activeborderwidth">Name:	<strong>activeBorderWidth</strong></a></strong>

<dt><strong><a name="item_class_3a_borderwidth">Class:	<strong>BorderWidth</strong></a></strong>

<dt><strong><a name="item_switch_3a__2dactiveborderwidth">Switch:	<strong>-activeborderwidth</strong></a></strong>

<dd>
<p>Specifies a non-negative value indicating
the width of the 3-D border drawn around active elements.
See above for definition of active elements.
The value may have any of the forms acceptable to <strong>Tk_GetPixels</strong>.
This option is typically only available in widgets displaying more
than one element at a time (e.g. menus but not buttons).</p>
</dd>
</li>
<dt><strong><a name="item_name_3a_activeforeground">Name:	<strong>activeForeground</strong></a></strong>

<dt><strong><a name="item_class_3a_background">Class:	<strong>Background</strong></a></strong>

<dt><strong><a name="item_switch_3a__2dactiveforeground">Switch:	<strong>-activeforeground</strong></a></strong>

<dd>
<p>Specifies foreground color to use when drawing active elements.
See above for definition of active elements.</p>
</dd>
</li>
<dt><strong><a name="item_name_3a_activetile">Name:	<strong>activetile</strong></a></strong>

<dt><strong><a name="item_class_3a_tile">Class:	<strong>Tile</strong></a></strong>

<dt><strong><a name="item_switch_3a__2dactivetile">Switch:	<strong>-activetile</strong></a></strong>

<dd>
<p>Specifies image used to display inside active elements of the widget.
See above for definition of active elements.</p>
</dd>
</li>
<dt><strong><a name="item_name_3a_anchor">Name:	<strong>anchor</strong></a></strong>

<dt><strong><a name="item_class_3a_anchor">Class:	<strong>Anchor</strong></a></strong>

<dt><strong><a name="item_switch_3a__2danchor">Switch:	<strong>-anchor</strong></a></strong>

<dd>
<p>Specifies how the information in a widget (e.g. text or a bitmap)
is to be displayed in the widget.
Must be one of the values <strong>n</strong>, <strong>ne</strong>, <strong>e</strong>, <strong>se</strong>,
<strong>s</strong>, <strong>sw</strong>, <strong>w</strong>, <strong>nw</strong>, or <strong>center</strong>.
For example, <strong>nw</strong> means display the information such that its
top-left corner is at the top-left corner of the widget.</p>
</dd>
</li>
<dt><strong><a name="item_name_3a_background">Name:	<strong>background</strong></a></strong>

<dt><strong>Class:	<strong>Background</strong></strong>

<dt><strong><a name="item_switch_3a__2dbackground">Switch:	<strong>-background</strong></a></strong>

<dt><strong><a name="item_alias_3a__2dbg">Alias:	<strong>-bg</strong></a></strong>

<dd>
<p>Specifies the normal background color to use when displaying the
widget.</p>
</dd>
</li>
<dt><strong><a name="item_name_3a_bitmap">Name:	<strong>bitmap</strong></a></strong>

<dt><strong><a name="item_class_3a_bitmap">Class:	<strong>Bitmap</strong></a></strong>

<dt><strong><a name="item_switch_3a__2dbitmap">Switch:	<strong>-bitmap</strong></a></strong>

<dd>
<p>Specifies a bitmap to display in the widget, in any of the forms
acceptable to <strong>Tk_GetBitmap</strong>.
The exact way in which the bitmap is displayed may be affected by
other options such as <strong>-anchor</strong> or <strong>-justify</strong>.
Typically, if this option is specified then it overrides other
options that specify a textual value to display in the widget;
the <strong>-bitmap</strong> option may be reset to an empty string to re-enable
a text display.
In widgets that support both <strong>-bitmap</strong> and <strong>-image</strong> options,
<strong>-image</strong> will usually override <strong>-bitmap</strong>.</p>
</dd>
</li>
<dt><strong><a name="item_name_3a_borderwidth">Name:	<strong>borderWidth</strong></a></strong>

<dt><strong>Class:	<strong>BorderWidth</strong></strong>

<dt><strong><a name="item_switch_3a__2dborderwidth">Switch:	<strong>-borderwidth</strong></a></strong>

<dt><strong><a name="item_alias_3a__2dbd">Alias:	<strong>-bd</strong></a></strong>

<dd>
<p>Specifies a non-negative value indicating the width

⌨️ 快捷键说明

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