;; Use gui.ss teachpack ;; This example illustrates the use of most of the gui.ss functions ;; Note in particular how every button has a callback function ;; associated with it (passed as the second argument to make-button) ;; silly-sample-gui: (Listof String) -> true ;; creates a simple GUI that doesn't do anything worthwhile (define (silly-sample-gui choices) {local [(define choice-menu (make-choice choices)) (define msg-field1 (make-message "Welcome ")) (define msg-field2 (make-message "This is a silly GUI")) (define close-button (make-button "Close" hide-window)) (define choose-button (make-button "Choose" (lambda (event) (draw-message msg-field1 (string-append "You chose " (list-ref choices (choice-index choice-menu))))))) (define text-field (make-text "Enter some text: ")) (define echo-button (make-button "Echo Text" (lambda (event) (draw-message msg-field2 (text-contents text-field)))))] (create-window (list (list choice-menu text-field) (list msg-field1 msg-field2) (list choose-button echo-button) (list close-button)))}) ;; run it (silly-sample-gui (list "What" "Where" "When" "Why" "How"))