Created
October 3, 2018 18:35
-
-
Save samdphillips/701e20ab306e8a0c0644437102735b9d to your computer and use it in GitHub Desktop.
Tabs Example in Racket GUI
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/base | |
(require racket/class | |
racket/gui) | |
(define frame | |
(new frame% [label "Tabs!"])) | |
(define (change-tab tp event) | |
(when (eq? (send event get-event-type) 'tab-panel) | |
(fill-tab-content tp))) | |
(define (fill-tab-content tp) | |
(define current-tab-name | |
(send tp get-item-label (send tp get-selection))) | |
(send tp change-children | |
(lambda (c*) | |
(list | |
(new message% | |
[label (~a "You have selected: " current-tab-name)] | |
[parent tp]))))) | |
(define tab-panel | |
(new tab-panel% | |
[parent frame] | |
[choices (list "Tab 0" | |
"Tab 1" | |
"Tab 2")] | |
[callback change-tab])) | |
(send frame show #t) | |
(fill-tab-content tab-panel) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you!