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

# tk busy does not mask off the keyboard events so we set the focus on 
# a mapped but hidden widget and deny the Tab commands so the focus
# remains in place. If the widget is not mapped, it doesn't receive focus.

proc Busy {dlg state} {
    variable _busy_$dlg
    if {$state} {
        set busy $dlg.!busy
        if {![winfo exists $busy]} {
            frame $busy -takefocus 1; place $busy -x 0 -y 0; lower $busy
            bind $busy <Tab> {break}
            bind $busy <Shift-Tab> {break}
        }
        set _busy_$dlg [focus]
        focus -force $busy
        tk busy hold $dlg
    } else {
        if {[info exists _busy_$dlg]} {
            focus [set _busy_$dlg]
            unset _busy_$dlg
        }
        tk busy forget $dlg
    }
}