home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / tcl / 2128 < prev    next >
Encoding:
Internet Message Format  |  1992-12-16  |  2.2 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!saffron.CS.Berkeley.EDU!joel
  2. From: joel@saffron.CS.Berkeley.EDU (Joel A. Fine)
  3. Newsgroups: comp.lang.tcl
  4. Subject: Re: toplevel message widgets problem
  5. Date: 16 Dec 1992 18:49:00 GMT
  6. Organization: University of California, Berkeley
  7. Lines: 41
  8. Distribution: world
  9. Message-ID: <1gntmsINNqua@agate.berkeley.edu>
  10. References: <1992Dec15.233825.18609@bcars6a8.bnr.ca> <1gnls5INNpi0@agate.berkeley.edu>
  11. NNTP-Posting-Host: saffron.cs.berkeley.edu
  12.  
  13. In article <1gnls5INNpi0@agate.berkeley.edu>, ouster@sprite.Berkeley.EDU (John Ousterhout) writes:
  14. |> In article <1992Dec15.233825.18609@bcars6a8.bnr.ca>, norm@bnr.ca (Norm MacNeil) writes:
  15. |> |> I wanted to be able to put up a "dialog" box with a message (like "Processing -
  16. |> |> Please wait...") and then allow the program to continue on until such time as
  17. |> |> the internal processing was complete at which time the message box would
  18. |> |> disappear.
  19. |> |> 
  20. |> |> Anyway, sometimes the text appears in the message window and sometimes it
  21. |> |> doesn't.
  22. |> The bottom line is that you have to explicitly wait until you *know* that
  23. |> the window has been displayed.  The way to do this is with the tkwait command.
  24. |> Set up a binding for <Expose> on the window you want to see, with the
  25. |> binding set to modify a particular variable.  Then use tkwait to wait for
  26. |> the variable to change to the given value.  Once you know the window's up,
  27. |> then you can go off and do your other work.  Be sure to do one more update
  28. |> so that the window gets displayed, and also be sure to remove the binding
  29. |> when you're done.  Sorry this is so complicated... there should probably
  30. |> be a procedure in the Tk script library to do this automatically.
  31.  
  32. In the meantime, here's a procedure to do just that:
  33.  
  34. proc waitFor {w} {
  35.   set $w.iHaveBeenExposed 0
  36.   bind $w <Expose> "set $w.iHaveBeenExposed 1"
  37.   tkwait variable $w.iHaveBeenExposed
  38.   bind $w <Expose> ""
  39.   update
  40. }
  41.  
  42.  
  43. And you call it with:
  44.  
  45. toplevel .mywin
  46. addInterestingWidgetsTo .mywin
  47. waitFor .mywin
  48.  
  49. Of course, if you happen to want an actual binding on the Expose event on
  50. the new window, you have to add it back in after the waitFor command.
  51.  
  52. - Joel Fine
  53. joel@cs.berkeley.edu
  54.