From 7221a8da3cbf3ba7438fed50416f12c97bf09d23 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Sun, 14 Aug 2011 17:58:53 -0400 Subject: [PATCH] button for the upcoming tool --- button-with-alternatives.rkt | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 button-with-alternatives.rkt diff --git a/button-with-alternatives.rkt b/button-with-alternatives.rkt new file mode 100644 index 0000000..f4f3c55 --- /dev/null +++ b/button-with-alternatives.rkt @@ -0,0 +1,49 @@ +#lang racket/base + +;; Implements a button with alternatives. + +(require racket/gui/base + racket/class) + +(define (whalesong-tool-ui parent-widget + #:on-browser (on-browser + (lambda () + (void))) + #:on-build-package (on-build-package + (lambda () + (void)))) + (define container (new horizontal-pane% + [parent parent-widget])) + (define b (new button% + [label "Whalesong"] + [callback (lambda (b ce) + (define selection + (send ch get-selection)) + (cond + [(= selection 0) + (on-browser)] + [(= selection 1) + (on-build-package)] + [else + (void)]))] + [parent container])) + (define ch (new choice% + [label ""] + [choices (list "Run in browser" + "Build smartphone package")] + [style '(horizontal-label)] + [parent container])) + container) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define f (new frame% [label "test frame"])) +(whalesong-tool-ui f + #:on-browser + (lambda () + (printf "on-browser\n")) + + #:on-build-package + (lambda () + (printf "on-build-package\n"))) +(send f show #t) \ No newline at end of file