Created
June 14, 2012 02:36
-
-
Save takikawa/2927751 to your computer and use it in GitHub Desktop.
GUI switching panels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/gui | |
(define frame (make-object frame% "top")) | |
(define parent-panel (make-object panel% frame)) | |
(define panel1 (make-object panel% parent-panel)) | |
(define panel2 (make-object panel% parent-panel)) | |
(send parent-panel delete-child panel2) | |
(new button% | |
[label "Switch to 2"] | |
[parent panel1] | |
[callback | |
(lambda (b e) | |
(cond [(eq? (send e get-event-type) 'button) | |
(send parent-panel delete-child panel1) | |
(send parent-panel add-child panel2)] | |
[else (void)]))]) | |
(new button% | |
[label "Switch to 1"] | |
[parent panel2] | |
[callback | |
(lambda (b e) | |
(cond [(eq? (send e get-event-type) 'button) | |
(send parent-panel delete-child panel2) | |
(send parent-panel add-child panel1)] | |
[else (void)]))]) | |
(send frame show #t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment