📄 115.html
字号:
<HTML><TITLE>Overview of Tk: Cleaning Up the Root Window</TITLE><BODY BGCOLOR="#FFF0E0" VLINK="#0FBD0F" TEXT="#101000" LINK="#0F0FDD">
<A NAME="top"><H1>Cleaning Up the Root Window</H1></A>
<P> Learning Tk seems to be easier when you run Tk interactively because then
you can type commands and see their effects. Unfortunately, cleaning up the
messes you make is something you learn how to do at a later time.
<P> One way to clean up your messes is to restart <TT>wish??</TT> a lot. Another
is to load Script S11.5a and run the <TT>cleanTk</TT> procedure.
<P><CENTER><TABLE BORDER>
<CAPTION><ADDR> Script S11.5a: The cleanTk procedure. </ADDR></CAPTION
<TR><TD><PRE>## cleanTk, Script 11.5a of "Tcl/Tk For Programmers"
proc cleanTk {{Master .}} {
<P> ### read all comments before using
<P> if {$Master=="."} {
<P> ### get rid of all widgets other than . with their bindings
<P> eval destroy [winfo children .]
<P> ### get rid of any bindings to .
<P> foreach E [bind .] { bind . $E {} }
<P> ### destroy all images
<P> eval image delete [image names]
<P> ### reset root window's title
<P> global argv0
<P> wm title . $argv0
<P> ### bring root window back to top
<P> raise .
<P> ### restore root's automatic window sizing
<P> wm geometry . {}
<P> pack propagate . 1
<P> } else {
<P> ### get rid of $Master and it's children with all their bindings
<P> destroy $Master
<P> }
<P> ### cleanTk does not restore Tcl things such as variables and procedures
<P> ### to their original state; it also misses a few Tk things such as
<P> ### bindings to new nonwidget tags and colors of the root window
}
</PRE></TD></TR>
</TABLE></CENTER></P>
<!-- 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="11.4.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/11.4.html">section</A><WBR>
<STRONG>Next</STRONG>
<A HREF="11.6.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/11.6.html">section</A><WBR>
<STRONG>All</STRONG>
<A HREF="11.html" tppabs="http://www.mapfree.com/sbf/tcl/book/select/Html/11.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 + -