1# 2# a dialog box with a global grab (called by 'widget') 3# 4class TkDialog_Demo2 < TkDialog 5 ############### 6 private 7 ############### 8 def title 9 "Dialog with global grab" 10 end 11 12 def message 13 "This dialog box uses a global grab, so it prevents you from interacting with anything on your display until you invoke one of the buttons below. Global grabs are almost always a bad idea; don't use them unless you're truly desperate." 14 end 15 16 def bitmap 17 'info' 18 end 19 20 def default_button 21 0 22 end 23 24 def buttons 25 ["OK", "Cancel", "Show Code"] 26 end 27end 28 29ret = TkDialog_Demo2.new('message_config'=>{'wraplength'=>'4i'}, 30 'prev_command'=>proc{|dialog| 31 Tk.after 100, proc{dialog.grab('global')} 32 }).value 33case ret 34when 0 35 print "\You pressed OK\n" 36when 1 37 print "You pressed Cancel\n" 38when 2 39 showCode 'dialog2' 40end 41 42