home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: bnr.lang.tcl,comp.lang.tcl
- Path: sparky!uunet!cs.utexas.edu!torn!nott!bnrgate!bcars6a8!bnr.ca!norm
- From: norm@bnr.ca (Norm MacNeil)
- Subject: toplevel message widgets problem
- Message-ID: <1992Dec15.233825.18609@bcars6a8.bnr.ca>
- Sender: usenet@bcars6a8.bnr.ca (Use Net)
- Nntp-Posting-Host: bcarh1ff
- Reply-To: norm@bnr.ca
- Organization: Bell-Northern Research Ltd.
- Date: Tue, 15 Dec 1992 23:38:25 GMT
- Lines: 71
-
- I wanted to be able to put up a "dialog" box with a message (like "Processing -
- Please wait...") and then allow the program to continue on until such time as
- the internal processing was complete at which time the message box would
- disappear. So I wrote a little procedure...
-
- proc MsgCntl {Op Msg} {
- if {$Op == "END"} {
- catch {destroy .MsgCntl}
- } else {
- # Update any existing windows before continuing...
- update
-
- # Determine the size and placement of the window
- global .
-
- set WinHeight 175
- set WinWidth 350
-
- # Center the box in the existing "." window
- set WinX [expr {([winfo width .]/2)-($WinWidth/2)+[winfo x .]}]
- set WinY [expr {([winfo height .]/2)-($WinHeight/2)+[winfo y .]}]
-
- # Create the toplevel window
- toplevel .MsgCntl -class MsgCntl
- wm geometry .MsgCntl ${WinWidth}x${WinHeight}+${WinX}+${WinY}
- wm title .MsgCntl "Message"
- wm iconname .MsgCntl "Msg"
-
- # Create a dummy frame
- frame .MsgCntl.top -borderwidth 3 -relief raised
-
- # Create the message widget
- message .MsgCntl.top.msg -justify center
- .MsgCntl.top.msg configure -text [join $Msg]
- pack append .MsgCntl.top .MsgCntl.top.msg {top expand fill}
- pack append .MsgCntl .MsgCntl.top {top expand fill}
-
- # Now show the message window
- update
-
- # Now bind all actions to this window
- focus .MsgCntl
- bind .MsgCntl <Visibility> {grab .MsgCntl; focus .MsgCntl}
- grab .MsgCntl
- }
-
- }
-
-
- So in the program, it would be used like...
-
- MsgCntl BEGIN "Processing - please wait..."
- #life happens here
- MsgCntl END ""
-
- Anyway, sometimes the text appears in the message window and sometimes it
- doesn't. The above code is littled hacked up from the number of iterations of
- trying to get this to work. One test, I got the message windows to display the
- text, exited from the program, and restarted it, and this time the text did NOT
- appear so I know it's not from code-fiddling.
-
- What gives on the apparent inconsistency in displaying the text?
-
- Thanks much in advance,
- Norm.
- --
- +-----------------------------------------------------------------------+
- Norm MacNeil Phone: (613) 763-7497
- Data Systems Fax: (613) 765-2854
- Bell-Northern Research Ltd. EMail: norm@bnr.ca (INTERNET)
- #include <disclaimer.std> "Roller bladers do it in-line!"
-