home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!sprite.Berkeley.EDU!ouster
- From: ouster@sprite.Berkeley.EDU (John Ousterhout)
- Newsgroups: comp.lang.tcl
- Subject: Re: toplevel message widgets problem
- Date: 16 Dec 1992 16:35:17 GMT
- Organization: U.C. Berkeley Sprite Project
- Lines: 50
- Distribution: world
- Message-ID: <1gnls5INNpi0@agate.berkeley.edu>
- References: <1992Dec15.233825.18609@bcars6a8.bnr.ca>
- NNTP-Posting-Host: tyranny.berkeley.edu
-
- In article <1992Dec15.233825.18609@bcars6a8.bnr.ca>, norm@bnr.ca (Norm MacNeil) writes:
- |> 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...
- |>
- |> 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!"
-
- The inconsistency occurs because window creation and redisplay are delayed
- operations. They don't occur until the application runs out of other work
- to do; if you immediately go off to do something else after creating the
- window, the application doesn't run out of work to do so the window doesn't
- appears on the screen. Putting an "update" after you've created the window
- will help, but even that isn't enough, since that will only *initiate* the
- process of creating the window. The window redisplay is also delayed, so
- it might not complete before the update runs out of things to do (there's
- a round-trip to the server and/or window manager involved, so the application
- may think it's caught up before the window manager has actually mapped the
- window).
-
- The bottom line is that you have to explicitly wait until you *know* that
- the window has been displayed. The way to do this is with the tkwait command.
- Set up a binding for <Expose> on the window you want to see, with the
- binding set to modify a particular variable. Then use tkwait to wait for
- the variable to change to the given value. Once you know the window's up,
- then you can go off and do your other work. Be sure to do one more update
- so that the window gets displayed, and also be sure to remove the binding
- when you're done. Sorry this is so complicated... there should probably
- be a procedure in the Tk script library to do this automatically.
-