📄 137.html
字号:
<HTML><TITLE>Geometry Management: Placing Widgets more Carefully</TITLE><BODY BGCOLOR="#FFF0E0" VLINK="#0FBD0F" TEXT="#101000" LINK="#0F0FDD">
<A NAME="top"><H1>Placing Widgets more Carefully</H1></A>
<P> For those cases in which a widget does not fill its associated slice,
the <TT>pack</TT> geometry manager has a way of positioning widgets within slices.
Similarly, the <TT>grid</TT> geometry manager has a way of positioning widgets within
cells.
<P> Most of the time, the default positioning is just what you want. With
this positioning the widget is placed in the center of the slice or cell.
<P> When the default absolutely will not do, you use a technique that
depends on the geometry manager you are using.
<A NAME="pstnngwdgtswthnslcs">
<H3>Positioning Widgets within Slices</H3></A>
<P> The <TT>-fill</TT> option actually has four possible values: "none" (the
default), "both," "x," and "y." The first two are discussed above in
<A HREF="13.3.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.3.html">Slicing for Size Changes</A>. The <TT>-fill x</TT> option causes the widget to fill its slice in
the horizontal directions but not in the vertical. The <TT>-fill y</TT> option
causes the widget to fill its slice in the vertical directions but not in the
horizontal.
<P> The <TT>pack</TT> command also accepts an <TT><NAME=#S13.7anchorpack>-anchor</A></TT> option that
can be used to pull the widget to one side or corner without making it bigger.
This option has nine possible values: "n," "e," "s," "w," "ne,"
"se," "sw," "nw," and "c." Except for the last one, all these
values represent directions. Think of a slice as a map. The value of
<TT>-anchor</TT> will determine the direction in which you will find the widget
when the slice is larger than the widget. The <TT>c</TT> option is the default
and it means the widget will be centered.
<P><CENTER><TABLE BORDER>
<CAPTION><ADDR>Figure 13.7a: Exercises 13.7a and 13.7b.</ADDR></CAPTION>
<TR ALIGN=center><TD><IMG SRC="F13x7a.JPG" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Figs/F13x7a.JPG">
</TD></TR>
</TABLE></CENTER><P>
<P><A NAME="13.7a">
<STRONG>Exercise 13.7a</STRONG> </A><DL><DD>
Reproduce Figure 13.7a with <TT>pack</TT> and by stretching
the window with your mouse.
<P> My solution uses five frames or boxes.
<P>
<A HREF="13.9.html#Sol13.7a" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.9.html#Sol13.7a">Solution</A></DL>
<A NAME="pstnngwdgtswthnclls">
<H3>Positioning Widgets within Cells</H3></A>
<P> Instead of the <TT>-fill</TT> and <TT>-anchor</TT> options, the <TT>grid</TT> geometry
manager has <TT><NAME=#S13.7stickygrid>-sticky</A></TT>. The value of this option is a string
built up from four letters, "n," "e," "s," and "w," which again
represent directions. A nonempty value of the <TT>-sticky</TT> option for a
widget will cause that widget to stick to each of the indicated sides. If
there is just one letter, <CITE>L</CITE>, then the effect is like <TT>-anchor <CITE>L</CITE></TT>.
If there are multiple letters, the widget will touch every cell side in
every declared direction – stretching as necessary to do so. The value
"news," therefore, makes the widget fill the entire cell.
<P><A NAME="13.7b">
<STRONG>Exercise 13.7b</STRONG> </A><DL><DD>
Reproduce Figure 13.7a with <TT>grid</TT> and by stretching
the window with your mouse. <P>
<A HREF="13.9.html#Sol13.7b" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.9.html#Sol13.7b">Solution</A></DL>
<!-- Linkbar -->
<P><CENTER><FONT SIZE=2><NOBR>
<STRONG>From</STRONG>
<A HREF="javascript:if(confirm('http://www.mapfree.com/sbf/tcl/book/home.html \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.mapfree.com/sbf/tcl/book/home.html'" tppabs="http://www.mapfree.com/sbf/tcl/book/home.html">Tcl/Tk For Programmers</A><WBR>
<STRONG>Previous</STRONG>
<A HREF="13.6.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.6.html">section</A><WBR>
<STRONG>Next</STRONG>
<A HREF="13.8.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.8.html">section</A><WBR>
<STRONG>All</STRONG>
<A HREF="13.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.html">sections</A><WBR>
<STRONG>Author</STRONG>
<A HREF="javascript:if(confirm('http://www.mapfree.com/mp/jaz/home.html \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.mapfree.com/mp/jaz/home.html'" tppabs="http://www.mapfree.com/mp/jaz/home.html">J. A. Zimmer</A><WBR>
<STRONG>Copyright</STRONG>
<A HREF="copyright.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/copyright.html">Notice</A><WBR>
<P>
<I>Jun 17, 1998</I>
</NOBR></FONT></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -