home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / tcl / 2212 < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.8 KB  |  64 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!cs.utexas.edu!torn!nott!bnrgate!bcars6a8!bnr.ca!norm
  3. From: norm@bnr.ca (Norm MacNeil)
  4. Subject: re:suspending events
  5. Message-ID: <1992Dec22.163736.5832@bcars6a8.bnr.ca>
  6. Sender: usenet@bcars6a8.bnr.ca (Use Net)
  7. Nntp-Posting-Host: bcarh1ff
  8. Reply-To: norm@bnr.ca
  9. Organization: Bell-Northern Research Ltd.
  10. Date: Tue, 22 Dec 1992 16:37:36 GMT
  11. Lines: 51
  12.  
  13. In article <1992Dec22.141509.28807@choreo.ca>, you write:
  14. |> I have a tcl/tk script which handles some error processing, and displays
  15. |> a dialog box with the information message to the user when an error occurs.
  16. |> I set focus to the error window.  How do I keep the script from executing
  17. |> until the user presses the OK button?
  18. |>
  19. |> For example
  20. |>
  21. |> if .... {
  22. |>    errorDialog "message"
  23. |>    update
  24. |> }
  25. |>             <- I don't to continue here until an OK button is pressed.
  26. |> more code
  27. |> ...
  28. |>
  29. |>
  30. |> proc errorDialog {} {
  31. |>    ....
  32. |> }
  33.  
  34. I had the same requirements, so I cannabalized (sp?) the mkDialog.tcl in the
  35. .../library/demos directory to do the following...
  36.  
  37. proc error Dialog {Msg} {
  38.  
  39. # make toplevel window called, say, .FooBar
  40. # with a button at the bottom...
  41.  
  42.   button .FooBar.bottom.Ok -text "Cancel" -width 15 -command ".destroy .FooBar"
  43.  
  44. # Other stuff here...
  45.  
  46.   bind .FooBar <Visibility> {focus .FooBar}
  47.   grab .FooBar
  48.   focus .FooBar
  49.   tkwait window .FooBar
  50. }
  51.  
  52. The important line is the last one where tkwait waits until the window specified
  53. no longer exists.
  54.  
  55.  
  56. -- 
  57.   Norm.
  58.  
  59. +-----------------------------------------------------------------------+
  60.  Norm MacNeil                     Phone: (613) 763-3372
  61.  Data Systems                     Fax:   (613) 765-2854
  62.  Bell-Northern Research Ltd.      EMail: norm@bnr.ca (INTERNET)
  63.  #include <disclaimer.std>       "Roller bladers do it in-line!"
  64.