Posted to tcl by patthoyts at Mon Feb 08 13:57:16 GMT 2010view raw

  1. # tk busy does not mask off the keyboard events so we set the focus on
  2. # a mapped but hidden widget and deny the Tab commands so the focus
  3. # remains in place. If the widget is not mapped, it doesn't receive focus.
  4.  
  5. proc Busy {dlg state} {
  6. variable _busy_$dlg
  7. if {$state} {
  8. set busy $dlg.!busy
  9. if {![winfo exists $busy]} {
  10. frame $busy -takefocus 1; place $busy -x 0 -y 0; lower $busy
  11. bind $busy <Tab> {break}
  12. bind $busy <Shift-Tab> {break}
  13. }
  14. set _busy_$dlg [focus]
  15. focus -force $busy
  16. tk busy hold $dlg
  17. } else {
  18. if {[info exists _busy_$dlg]} {
  19. focus [set _busy_$dlg]
  20. unset _busy_$dlg
  21. }
  22. tk busy forget $dlg
  23. }
  24. }
  25.