📄 ch21_02.htm
字号:
</p></dd><dt><b><tt class="literal">-in =></tt> <tt class="literal">$</tt><em class="replaceable">window</em></b></dt><dd><a name="INDEX-2731" />Grids widget inside another windowinstead of its parent.</p></dd><dt><b><tt class="literal">-ipadx =></tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-2732" />Increases the size of the widgethorizontally by <em class="replaceable"><tt>amount</tt></em> x 2.<em class="replaceable"><tt>amount</tt></em> can be represented as a numberfollowed by <tt class="literal">c</tt> (centimeters), <tt class="literal">i</tt>(inches), <tt class="literal">m</tt> (millimeters), and<tt class="literal">p</tt> (printer points). Pixels are the default units.</p></dd><dt><b><tt class="literal">-ipady =></tt> <em class="replaceable">amount</em></b></dt><dd>Increases the size of the widget vertically by<em class="replaceable"><tt>amount</tt></em> x 2.<em class="replaceable"><tt>amount</tt></em> can be represented as a numberfollowed by <tt class="literal">c</tt> (centimeters), <tt class="literal">i</tt>(inches), <tt class="literal">m</tt> (millimeters), and<tt class="literal">p</tt> (printer points). Pixels are the default units.</p></dd><dt><b><tt class="literal">-padx =></tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-2733" />Places padding on the left and rightof the widget. <em class="replaceable"><tt>amount</tt></em> can be representedas a number followed by <tt class="literal">c</tt> (centimeters),<tt class="literal">i</tt> (inches), <tt class="literal">m</tt> (millimeters),and <tt class="literal">p</tt> (printer points). Pixels are the defaultunits.</p></dd><dt><b><tt class="literal">-pady</tt> <em class="replaceable">amount</em></b></dt><dd>Places padding on the top and bottom of the widget.<em class="replaceable"><tt>amount</tt></em> can be represented as a numberfollowed by <tt class="literal">c</tt> (centimeters), <tt class="literal">i</tt>(inches), <tt class="literal">m</tt> (millimeters), and<tt class="literal">p</tt> (printer points). Pixels are the default units.</p></dd></dl><a name="perlnut2-CHP-21-SECT-2.2.1" /><div class="sect3"><h3 class="sect3">21.2.2.1. grid methods</h3><p>The following methods are associated with widgets managed by<tt class="literal">grid</tt>:</p><dl><dt><b><tt class="literal">gridColumnconfigure</tt></b></dt><dd><a name="INDEX-2734" />Configures the column specified by thefirst argument using <tt class="literal">-weight</tt> and<tt class="literal">-minsize</tt> arguments. The <tt class="literal">-weight</tt>argument determines the amount of space to allocate to that column,and the <tt class="literal">-minsize</tt> argument sets the minimum size inpixels. For example:</p><blockquote><pre class="code">$widget->gridColumnconfigure(3, -weight => 1);</pre></blockquote></dd><dt><b><tt class="literal">gridRowconfigure</tt></b></dt><dd><a name="INDEX-2735" />Configures the row specified by thefirst argument using <tt class="literal">-weight</tt> and<tt class="literal">-minsize</tt> arguments. The <tt class="literal">-weight</tt>argument determines the amount of space to allocate to that row, andthe <tt class="literal">-minsize</tt> argument sets the minimum size inpixels. For example:</p><blockquote><pre class="code">$widget->gridRowconfigure(3, -weight => 1);</pre></blockquote></dd><dt><b><tt class="literal">gridRemove</tt></b></dt><dd><a name="INDEX-2736" />Removeseach of the <tt class="literal">$slaves</tt> from <tt class="literal">grid</tt>for its master and unmaps their windows. The slaves will no longer bemanaged by the <tt class="literal">grid</tt> geometry manager.<tt class="literal">gridRemove</tt> remembers the previous configurationoptions for the window. So, if <tt class="literal">$slave</tt> is managedonce more by the <tt class="literal">grid</tt> geometry manager, theprevious values will be retained.</p></dd><dt><b><tt class="literal">gridBbox</tt></b></dt><dd><a name="INDEX-2737" />Returns thebounding box in pixels for the space occupied by the specified gridposition (in the order of column, row). For example:</p><blockquote><pre class="code">$widget->gridBbox(3,2);</pre></blockquote></dd><dt><b><tt class="literal">gridForget</tt></b></dt><dd><a name="INDEX-2738" />Causes thewidget(s) to be removed from view. Additional widgets can bespecified as arguments.</p><blockquote><pre class="code">$widget1->gridForget($widget2, widget3, ...);</pre></blockquote></dd><dt><b><tt class="literal">gridInfo</tt></b></dt><dd><a name="INDEX-2739" />Returnsinformation about the widget in list format:</p><blockquote><pre class="code">$widget->gridInfo;</pre></blockquote></dd><dt><b><tt class="literal">gridLocation</tt></b></dt><dd><a name="INDEX-2740" />Returnsthe column and row of the widget nearest the specified x,ycoordinates (in pixels):</p><blockquote><pre class="code">$widget->gridLocation(120, 32);</pre></blockquote></dd><dt><b><tt class="literal">gridPropagate</tt></b></dt><dd><a name="INDEX-2741" />Turnsoff automatic resizing of the widget:</p><blockquote><pre class="code">$widget->gridPropagate;</pre></blockquote></dd><dt><b><tt class="literal">gridSize</tt></b></dt><dd><a name="INDEX-2742" />Returns thesize of the grid, i.e., the number of columns and rows:</p><blockquote><pre class="code">$widget->gridSize;</pre></blockquote></dd><dt><b><tt class="literal">gridSlaves</tt></b></dt><dd><a name="INDEX-2743" />Returns alist of all widgets contained within a master widget. Optional<tt class="literal">-row</tt> and <tt class="literal">-column</tt> argumentsrestrict the response to the widget(s) within that row or column:</p><blockquote><pre class="code">@children = $widget->gridSlaves(-row => 2);</pre></blockquote></dd></dl></div><a name="INDEX-2744" /></div><a name="perlnut2-CHP-21-SECT-2.3" /><div class="sect2"><h3 class="sect2">21.2.3. The place Geometry Manager</h3><p><a name="INDEX-2745" />The<tt class="literal">place</tt> geometry manager lets you position a windowat explicit x,y coordinates. With <tt class="literal">place</tt>, you canoverlap widgets, which isn't allowed with<tt class="literal">grid</tt> or <tt class="literal">pack</tt>. For example, toposition a button widget at the upper-left corner of a window:</p><blockquote><pre class="code">$button->place(-x => 0, -y => 0);</pre></blockquote><p>Options to <tt class="literal">place</tt> are:</p><dl><dt><b><tt class="literal">-anchor =></tt> <em class="replaceable">position</em></b></dt><dd><a name="INDEX-2746" />The position in the widget that willbe placed at the coordinates specified. 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>. Default is<tt class="literal">nw</tt>.</p></dd><dt><b><tt class="literal">-bordermode =></tt> <em class="replaceable">location</em></b></dt><dd><a name="INDEX-2747" />Determines whether the border portionof the widget is included in the coordinate system. Values for<em class="replaceable"><tt>location</tt></em> are <tt class="literal">inside</tt>,<tt class="literal">outside</tt>, and <tt class="literal">ignore</tt>.</p></dd><dt><b><tt class="literal">-height =></tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-2748" />Absolute height of the widget.<em class="replaceable"><tt>amount</tt></em> can be represented as a numberfollowed by <tt class="literal">c</tt> (centimeters), <tt class="literal">i</tt>(inches), <tt class="literal">m</tt> (millimeters), and<tt class="literal">p</tt> (printer points). Pixels are the default units.</p></dd><dt><b><tt class="literal">-in =></tt> <tt class="literal">$</tt><em class="replaceable">window</em></b></dt><dd><a name="INDEX-2749" />The child widget will be packed insidethe specified window instead of the parent that created it. Anyrelative coordinates or sizes will still refer to the parent.</p></dd><dt><b><tt class="literal">-relheight =></tt> <em class="replaceable">ratio</em></b></dt><dd><a name="INDEX-2750" />The height of the widget relates to theparent widget's height by the specified ratio.</p></dd><dt><b><tt class="literal">-relwidth =></tt> <em class="replaceable">ratio</em></b></dt><dd>The width of the widget relates to the parentwidget's width by the specified ratio.</p></dd><dt><b><tt class="literal">-relx =></tt> <em class="replaceable">xratio</em></b></dt><dd><a name="INDEX-2751" />The widget will be placed relative toits parent by the specified ratio. <em class="replaceable"><tt>xratio</tt></em>is a floating point number from 0.0 to 1.0, with 0.0 representing theleft side of the parent widget and 1.0 representing the right side.</p></dd><dt><b><tt class="literal">-rely =></tt> <em class="replaceable">yratio</em></b></dt><dd>The widget will be placed relative to its parent by the specifiedratio. <em class="replaceable"><tt>yratio</tt></em> is a floating point numberfrom 0.0 to 1.0, with 0.0 representing the top of the parent widgetand 1.0 representing the bottom.</p></dd><dt><b><tt class="literal">-width =></tt> <em class="replaceable">amount</em></b></dt><dd><a name="INDEX-2752" />The width of the widget will be thespecified amount. <em class="replaceable"><tt>amount</tt></em> can berepresented as a number followed by <tt class="literal">c</tt>(centimeters), <tt class="literal">i</tt> (inches), <tt class="literal">m</tt>(millimeters), and <tt class="literal">p</tt> (printer points). Pixels arethe default units.</p></dd><dt><b><tt class="literal">-x =></tt> <em class="replaceable">xcoord</em></b></dt><dd><a name="INDEX-2753" />The widget willbe placed at the specified x coordinate.</p></dd><dt><b><tt class="literal">-y =></tt> <em class="replaceable">ycoord</em></b></dt><dd><a name="INDEX-2754" />The widget willbe placed at the specified y coordinate.</p></dd></dl><p>The following methods are associated with widgets managed by<tt class="literal">place</tt>:</p><dl><dt><b><tt class="literal">placeForget</tt></b></dt><dd><a name="INDEX-2755" />Causes the widget to be removed fromview.</p></dd><dt><b><tt class="literal">placeInfo</tt></b></dt><dd>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -