home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!saffron.CS.Berkeley.EDU!joel
- From: joel@saffron.CS.Berkeley.EDU (Joel A. Fine)
- Newsgroups: comp.lang.tcl
- Subject: Re: toplevel message widgets problem
- Date: 16 Dec 1992 18:49:00 GMT
- Organization: University of California, Berkeley
- Lines: 41
- Distribution: world
- Message-ID: <1gntmsINNqua@agate.berkeley.edu>
- References: <1992Dec15.233825.18609@bcars6a8.bnr.ca> <1gnls5INNpi0@agate.berkeley.edu>
- NNTP-Posting-Host: saffron.cs.berkeley.edu
-
- In article <1gnls5INNpi0@agate.berkeley.edu>, ouster@sprite.Berkeley.EDU (John Ousterhout) writes:
- |> 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.
- |> |>
- |> |> Anyway, sometimes the text appears in the message window and sometimes it
- |> |> doesn't.
- |> 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.
-
- In the meantime, here's a procedure to do just that:
-
- proc waitFor {w} {
- set $w.iHaveBeenExposed 0
- bind $w <Expose> "set $w.iHaveBeenExposed 1"
- tkwait variable $w.iHaveBeenExposed
- bind $w <Expose> ""
- update
- }
-
-
- And you call it with:
-
- toplevel .mywin
- addInterestingWidgetsTo .mywin
- waitFor .mywin
-
- Of course, if you happen to want an actual binding on the Expose event on
- the new window, you have to add it back in after the waitFor command.
-
- - Joel Fine
- joel@cs.berkeley.edu
-