📄 ch21_03.htm
字号:
<html><head><title>Common Widget Configuration Options (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 & 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_02.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_04.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">21.3. Common Widget Configuration Options</h2><p><a name="INDEX-2797" /><a name="INDEX-2798" /><a name="INDEX-2799" />In the remainder of thischapter, we'll discuss each widget, the commandsused to create each widget, the options used to configure them, andthe methods for manipulating them.</p><p>You'll find that there are many, many configurationoptions shared by multiple widgets. We could list them individuallyfor each widget, but in the interest of saving a tree or two, we willinstead list the shared options up front rather than repeating themover and over. That way, we can concentrate on the options that arecrucial to the behavior of each particular widget and save the readerfrom being lost in a sea of options.</p><p>The following options are supported by the widgets noted:</p><dl><dt><b><tt class="literal">-activebackground =></tt> <em class="replaceable">color</em></b></dt><dd><a name="INDEX-2800" />Sets the background color when themouse cursor is over the widget. Applicable widgets: Button,Checkbutton, Menu, Menubutton, Optionmenu, Radiobutton, Scale,Scrollbar.</p></dd><dt><b><tt class="literal">-activeborderwidth =></tt> <em class="replaceable">borderwidth</em></b></dt><dd><a name="INDEX-2801" />Sets a 3-D border around activeelements. Applicable widgets: Menu, Menubutton, Optionmenu.</p></dd><dt><b><tt class="literal">-activeforeground =></tt> <em class="replaceable">color</em></b></dt><dd><a name="INDEX-2802" />Sets the text color when the mousecursor is over the widget. Applicable widgets: Button, Checkbutton,Menu, Menubutton, Optionmenu, Radiobutton.</p></dd><dt><b><tt class="literal">-anchor =></tt> <em class="replaceable">position</em></b></dt><dd><a name="INDEX-2803" />Causes thetext to stick to that position in the widget. Values for<em class="replaceable"><tt>position</tt></em> are <tt class="literal">n</tt>,<tt class="literal">ne</tt>, <tt class="literal">e</tt>, <tt class="literal">se</tt>,<tt class="literal">s</tt>, <tt class="literal">sw</tt>, <tt class="literal">w</tt>,<tt class="literal">nw</tt>, and <tt class="literal">center</tt>. Applicablewidgets: Button, Checkbutton, Label, Menubutton, Optionmenu,Radiobutton.</p></dd><dt><b><tt class="literal">-background =></tt> <em class="replaceable">color</em></b></dt><dt><b><tt class="literal">-bg =></tt> <em class="replaceable">color</em></b></dt><dd><a name="INDEX-2804" /><a name="INDEX-2805" />Sets thebackground of the widget to the specified color. Applicable widgets:Button, Canvas, Checkbutton, Entry, Frame, Label, Listbox, Menu,Menubutton, Optionmenu, Radiobutton, Scale, Scrollbar, Text,Toplevel.</p></dd><dt><b><tt class="literal">-bitmap =></tt> <tt class="literal">'</tt><em class="replaceable">bitmapname</em><tt class="literal">'</tt></b></dt><dd><a name="INDEX-2806" />Uses a bitmap instead of text in thewidget. You can specify either a default bitmap or the location of abitmap file (with <tt class="literal">@</tt> in front of the path).Applicable widgets: Button, Checkbutton, Label, Menubutton,Optionmenu, Radiobutton.</p></dd><dt><b><tt class="literal">-borderwidth =></tt> <em class="replaceable">amount</em></b></dt><dt><b><tt class="literal">-bd =></tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-2807" /><a name="INDEX-2808" />Changes thewidth of the edge drawn around the widget. Applicable widgets:Button, Canvas, Checkbutton, Entry, Frame, Label, Listbox, Menu,Menubutton, Optionmenu, Radiobutton, Scale, Scrollbar, Text,Toplevel.</p></dd><dt><b><tt class="literal">-cursor =></tt> <tt class="literal">'</tt><em class="replaceable">cursorname</em><tt class="literal">'</tt></b></dt><dd><a name="INDEX-2809" />Mouse cursor will change to specifiedcursor when over the widget. Applicable widgets: Button, Canvas,Checkbutton, Entry, Frame, Label, Listbox, Menu, Menubutton,Optionmenu, Radiobutton, Scale, Scrollbar, Text, Toplevel.</p></dd><dt><b><tt class="literal">-disabledforeground =></tt> <em class="replaceable">color</em></b></dt><dd><a name="INDEX-2810" />Sets the color of the text when thewidget is disabled. Applicable widgets: Button, Checkbutton, Menu,Menubutton, Optionmenu, Radiobutton.</p></dd><dt><b><tt class="literal">-exportselection =></tt> <em class="replaceable">boolean</em></b></dt><dd><a name="INDEX-2811" />Determines whether selected text isexported to the window system's clipboard. (For alistbox, the default of <tt class="literal">-exportselection => 1</tt>means two listboxes cannot have selections at the same time.)Applicable widgets: Entry, Listbox, Text.</p></dd><dt><b><tt class="literal">-font =></tt> <tt class="literal">'</tt><em class="replaceable">fontname</em><tt class="literal">'</tt></b></dt><dd><a name="INDEX-2812" />Changes the font of all the text onthe widget to <em class="replaceable"><tt>fontname</tt></em>. Applicablewidgets: Button, Checkbutton, Entry, Label, Listbox, Menu,Menubutton, Optionmenu, Radiobutton, Scale, Text.</p></dd><dt><b><tt class="literal">-foreground =></tt> <em class="replaceable">color</em></b></dt><dt><b><tt class="literal">-fg =></tt> <em class="replaceable">color</em></b></dt><dd><a name="INDEX-2813" /><a name="INDEX-2814" />Changesthe text color to <em class="replaceable"><tt>color</tt></em>. Applicablewidgets: Button, Checkbutton, Entry, Label, Listbox, Menu,Menubutton, Optionmenu, Radiobutton, Scale, Text.</p></dd><dt><b><tt class="literal">-height =></tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-2815" />Specifiesthe height of the widget. <em class="replaceable"><tt>amount</tt></em>represents a number of characters if text is displayed, or a screendistance if an image or bitmap is displayed. Applicable widgets:Button, Canvas, Checkbutton, Frame, Label, Listbox, Menubutton,Optionmenu, Radiobutton, Text, Toplevel.</p></dd><dt><b><tt class="literal">-highlightbackground =></tt> <em class="replaceable">color</em></b></dt><dd><a name="INDEX-2816" />Sets the color of a non-focusrectangle. Applicable widgets: Button, Canvas, Checkbutton, Entry,Frame, Label, Listbox, Menubutton, Optionmenu, Radiobutton, Scale,Scrollbar, Text, Toplevel.</p></dd><dt><b><tt class="literal">-highlightcolor =></tt> <em class="replaceable">color</em></b></dt><dd><a name="INDEX-2817" />Setsthe color of the focus rectangle. Applicable widgets: Button, Canvas,Checkbutton, Entry, Frame, Label, Listbox, Menubutton, Optionmenu,Radiobutton, Scale, Scrollbar, Text, Toplevel.</p></dd><dt><b><tt class="literal">-highlightthickness =></tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-2818" />Sets the thickness of the black boxaround the widget that indicates focus. Applicable widgets: Button,Canvas, Checkbutton, Entry, Frame, Label, Listbox, Menubutton,Optionmenu, Radiobutton, Scale, Scrollbar, Text, Toplevel.</p></dd><dt><b><tt class="literal">-image =></tt> <tt class="literal">$</tt><em class="replaceable">imgptr</em></b></dt><dd><a name="INDEX-2819" />Uses an image instead of text.<tt class="literal">$</tt><em class="replaceable"><tt>imgptr</tt></em> is a pointer toa Photo or Image object made using a GIF or PPM file. For example:</p><blockquote><pre class="code">$arrow = $mainwindow->Photo(-file => "image.gif");$mainwindow->Button(-image => $arrow,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -