Posted to tcl by schelte at Mon Oct 20 13:54:10 GMT 2008view pretty
# This program brings up two toplevels. The Quit button on top2 does not work # because of the grab on .tree1. After bringing up the combobox list and then # clicking outside the list to hide it again the Quit button of top2 becomes # active. This happens because the [grab .tree1] command performed by the # combobox bindings fails ("grab failed: window not viewable"). However, the # same command executed by pressing F2 has no problems to set the grab on # .tree1, even though it is still not viewable. Pressing F1 will show which # widget currently has the grab, if any. wm withdraw . frame .tree1 toplevel .tree1.top ttk::combobox .tree1.top.box -state readonly \ -values {"Option 1" "Option 2" "Option 3"} label .tree1.top.grab -textvariable grab button .tree1.top.quit -text Quit -command exit grid .tree1.top.box -padx 8 -pady 8 -sticky nwe grid .tree1.top.grab -padx 8 -pady 8 grid .tree1.top.quit -padx 8 -pady 8 toplevel .top2 button .top2.quit -text Quit -command exit grid .top2.quit -padx 8 -pady 8 grab .tree1 bind all <F1> {set grab [grab current]} bind all <F2> {grab .tree1}