Skip to content

Instantly share code, notes, and snippets.

@samdphillips
Created October 3, 2018 18:35
Show Gist options
  • Save samdphillips/701e20ab306e8a0c0644437102735b9d to your computer and use it in GitHub Desktop.
Save samdphillips/701e20ab306e8a0c0644437102735b9d to your computer and use it in GitHub Desktop.
Tabs Example in Racket GUI
#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)
@Mega-Barto
Copy link

thx

@KyrylMikheiev
Copy link

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment