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

📄 ch21_13.htm

📁 by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See
💻 HTM
字号:
<html><head><title>The Scale Widget (Perl in a Nutshell, 2nd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Stephen Spainhour" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly &amp; Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596002416L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Perl in a Nutshell, 2nd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Java and XSLT" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch21_12.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch21_14.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">21.13. The Scale Widget</h2><p><a name="INDEX-3032" /><a name="INDEX-3033" /><a name="INDEX-3034" /><a name="INDEX-3035" />Create a"slider" widget representing anumeric value with the <tt class="literal">Scale</tt> method.</p><blockquote><pre class="code">$parent-&gt;Scale(<em class="replaceable"><tt>options</tt></em>);</pre></blockquote><p>The standard configuration options that apply to<tt class="literal">Scale</tt> are: <tt class="literal">-activebackground</tt>, <tt class="literal">-background</tt>, <tt class="literal">-bg</tt>,<tt class="literal">-borderwidth</tt>, <tt class="literal">-bw</tt>,<tt class="literal">-cursor</tt>, <tt class="literal">-font</tt>,<tt class="literal">-foreground</tt>, <tt class="literal">-fg</tt>,<tt class="literal">-highlight</tt>-<tt class="literal">background</tt>,<tt class="literal">-highlightcolor</tt>,<tt class="literal">-highlightthickness</tt>, <tt class="literal">-relief</tt>,<tt class="literal">-state</tt>, <tt class="literal">-takefocus</tt>, and<tt class="literal">-width</tt>.</p><p>Other options are:</p><dl><dt><b><tt class="literal">-bigincrement =&gt;</tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-3036" />The amount to change the sliderwhen using large increments. Default is <tt class="literal">0</tt>, whichmeans 1/10 of the scale.</p></dd><dt><b><tt class="literal">-command =&gt;</tt> <em class="replaceable">callback</em></b></dt><dd><a name="INDEX-3037" />Pointer to a function that will becalled for every incremental change in the slider.</p></dd><dt><b><tt class="literal">-digits =&gt;</tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-3038" />The number of digits to keep whenconverting from a number to a string.</p></dd><dt><b><tt class="literal">-from =&gt;</tt> <em class="replaceable">n</em></b></dt><dd><a name="INDEX-3039" />Low end of the scale (default is<tt class="literal">0</tt>). </p></dd><dt><b><tt class="literal">-label =&gt;</tt> <em class="replaceable">string</em></b></dt><dd><a name="INDEX-3040" />Thestring to use as a label for the slider.</p></dd><dt><b><tt class="literal">-length =&gt;</tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-3041" />The length of the scale.</p></dd><dt><b><tt class="literal">-orient =&gt;</tt> <em class="replaceable">direction</em></b></dt><dd><a name="INDEX-3042" />Theorientation of the slider. Values can be either<tt class="literal">vertical</tt> (default) or<tt class="literal">horizontal</tt>.</p></dd><dt><b><tt class="literal">-repeatdelay =&gt;</tt> <em class="replaceable">milliseconds</em></b></dt><dd><a name="INDEX-3043" />Determines the number of millisecondsto hold down an arrow before it auto-repeats. Default is<tt class="literal">300</tt>. </p></dd><dt><b><tt class="literal">-repeatinterval =&gt;</tt> <em class="replaceable">milliseconds</em></b></dt><dd><a name="INDEX-3044" />Determines the number of millisecondsbetween auto-repeats once it is started. Default is<tt class="literal">100</tt>. </p></dd><dt><b><tt class="literal">-resolution =&gt;</tt> <em class="replaceable">value</em></b></dt><dd><a name="INDEX-3045" />The increments that the scalewill change by (default is <tt class="literal">1</tt>).</p></dd><dt><b><tt class="literal">-showvalue =&gt;</tt> <em class="replaceable">boolean</em></b></dt><dd><a name="INDEX-3046" />Whether to show the current value of theslider (default is <tt class="literal">1</tt>).</p></dd><dt><b><tt class="literal">-sliderlength =&gt;</tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-3047" />The size of the slider. Defaultis 25 pixels.</p></dd><dt><b><tt class="literal">-tickinterval =&gt;</tt> <em class="replaceable">n</em></b></dt><dd><a name="INDEX-3048" />The number of"ticks" to display for the slider(default is <tt class="literal">0</tt>).</p></dd><dt><b><tt class="literal">-to =&gt;</tt> <em class="replaceable">n</em></b></dt><dd><a name="INDEX-3049" />The top value of the scale (default is<tt class="literal">100</tt>). </p></dd><dt><b><tt class="literal">-troughcolor =&gt;</tt> <em class="replaceable">color</em></b></dt><dd><a name="INDEX-3050" />Changes the color of the trough.</p></dd><dt><b><tt class="literal">-variable =&gt;</tt> <em class="replaceable">\$variable</em></b></dt><dd><a name="INDEX-3051" />Assigns the value of the slider to thespecified variable.</p></dd></dl><a name="perlnut2-CHP-21-SECT-13.1" /><div class="sect2"><h3 class="sect2">21.13.1. Scale Methods</h3><p>In addition to <tt class="literal">configure</tt> and<tt class="literal">cget</tt>, the following methods are defined for theScale widget:</p><dl><dt><b><tt class="literal">get</tt></b></dt><dd><a name="INDEX-3052" />Returns the current value if given noarguments. If given x and y coordinates as the first and secondarguments, returns the value of the scale at that position.</p></dd><dt><b><tt class="literal">set</tt></b></dt><dd><a name="INDEX-3053" />Assigns the value associated with thescale.</p></dd><dt><b><tt class="literal">coords</tt></b></dt><dd><a name="INDEX-3054" />Returns the x and y coordinatesassociated with the value given in the first argument.</p></dd><dt><b><tt class="literal">identify</tt></b></dt><dd><a name="INDEX-3055" />Returns <tt class="literal">"slider"</tt>,<tt class="literal">"trough1"</tt>, <tt class="literal">"trough2"</tt>, or<tt class="literal">""</tt>, depending on which part of the scalecorresponds to the given x, y coordinates.</p></dd></dl></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch21_12.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch21_14.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">21.12. The Canvas Widget</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">21.14. The Menubutton Widget</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright &copy; 2002</a> O'Reilly &amp; Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>

⌨️ 快捷键说明

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