;; tkwait, used for waiting for dialog input

(define tkwait-label #f)

(define make-panel 
  (lambda ()
    (toplevel '.top)
    (button '.top.ok :text "OK" :command 
	    '(begin
	       (set! tkwait-label "ok")
	       (destroy .top)))
    (button '.top.cancel :text "Cancel" :command 
	    '(begin
		(set! tkwait-label "cancel")
		(destroy .top)))
    (pack .top.ok .top.cancel :side "left" :padx "10" :pady "10")
    (grab 'set .top)
    (tkwait 'window .top)
    tkwait-label))

(button ".b" :text "Try pressing me!" 
	:command 
	'(let ([x (make-panel)])
	   (format (current-output-port) "You pressed ~a\n" x)))

(pack .b)
