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

📄 138.html

📁 Tcl 语言的入门级图书
💻 HTML
字号:
<HTML><TITLE>Geometry Management: <CITE>Tricks for Using Pack</CITE></TITLE><BODY BGCOLOR="#FFF0E0" VLINK="#0FBD0F" TEXT="#101000" LINK="#0F0FDD">
<A NAME="top"><H1><CITE>Tricks for Using Pack</CITE></H1></A>


<P>  This section contains two tricks.

<A NAME="sngndvdngfrmssspcng">
<H3>Using and Avoiding Frames as Spacing</H3></A>


<P>  Figure 13.8a shows a single frame with three white boxes and two expanding
frames in between.  As shown, the root window has been expanded by the user.
The expanding, but empty, frames serve to keep an even spacing between the
boxes.  This is a fairly common use for a frame.  A very similar example
was given in Exercise 
<A HREF="13.3.html#13.3b" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.3.html#13.3b">13.3b</A>.

<P><CENTER><TABLE BORDER>
<CAPTION><ADDR>Figure 13.8a:  Frames as spacing.</ADDR></CAPTION>
<TR ALIGN=center><TD><IMG SRC="F13x8a.JPG" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Figs/F13x8a.JPG">
</TD></TR>
<TR><TD><PRE>pack [frame .fr] -fill both
pack [box .fr white] -side left
pack [frame .fr.space1] -side left -fill both -expand true
pack [box .fr white] -side left
pack [frame .fr.space2] -side left -fill both -expand true
pack [box .fr white] -side left </PRE></TD></TR>
</TABLE></CENTER><P>

<P>  Frames make good spacing but they are not necessary if what you 
want to do is put a widget on either end of a slice.  To place
two widgets so that they stick on either end of a slice, just
vary the <TT>-side</TT> options to get them there.

<P><A NAME="13.8a">
<STRONG>Exercise 13.8a</STRONG> </A><DL><DD>
  Put four white boxes in the corners of the root window
so that they keep their size and stick to their corners as the window
is expanded.
<P>
<A HREF="13.9.html#Sol13.8a" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.9.html#Sol13.8a">Solution</A></DL>


<A NAME="szngtxtbsdwdgts">
<H3>Sizing Text-Based Widgets</H3></A>


<P>  It sometimes happens that you wish that text-based widgets had height and
width dimensions of the same kind as other widgets instead of height and width
dimensions that are measured in numbers of characters.  You do not get your
wish, but you can ask the text-based widget to conform to other measurements.
Do the following in the order stated:

<OL>

<P> <P><LI> declare a frame of the size you want &#150; say its pathname is i
<CITE>FRAME_PATH</CITE>
<P> <P><LI> execute

<PRE>
pack propagate <CITE>FRAME_PATH</CITE> false
</PRE>

<P> <P><LI> pack the text-based widget in the frame so that it expands in
both dimensions
</OL>

<P>  Normally, the packer calculates the size needed by a master's slaves
and then tries to size the frame accordingly.  The size of the subwindows is
<CITE>propagating</CITE> upwards.  When you use <TT>pack propagate</TT>, the packer will
attempt to keep the widget you name the size you have requested with the
<TT>-height</TT> and <TT>-width</TT> options.

<P><A NAME="13.8b">
<STRONG>Exercise 13.8b</STRONG> </A><DL><DD>
 Create a text widget that is 375 pixels wide and 300 
pixels high.
<P>
<A HREF="13.9.html#Sol13.8b" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.9.html#Sol13.8b">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.7.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.7.html">section</A><WBR>
<STRONG>Next</STRONG>
<A HREF="13.9.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/13.9.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 + -