# Tab-panel in the Graphical Interface Toolkit

**URL:** <https://racket.discourse.group/t/tab-panel-in-the-graphical-interface-toolkit/4525>\
**Category:** Questions & Answers\
**Created:** [December 4, 2026, 2:02pm UTC](https://racket.discourse.group/t/tab-panel-in-the-graphical-interface-toolkit/4525 "2026-12-04T14:02:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MickeyKnox](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MickeyKnox](https://racket.discourse.group/u/MickeyKnox)\
**Post date:** [December 4, 2026, 2:02pm UTC](https://racket.discourse.group/t/tab-panel-in-the-graphical-interface-toolkit/4525/1 "2026-12-04T14:02:11Z")

</div>

I have created something working, but I struggled quite a bit with it. This is what I've got:

```scheme
#lang racket

(require racket/gui/base)

(define startmenu (new frame%
                    (label "Test")
                    (min-width 640)
                    (stretchable-width #f)))

(define (change-tab tab-panel event)
  (let ((index (send tab-panel get-selection)))
    (send tab-panel
          change-children
          (lambda (children)
            (list (vector-ref tabs index))))))

(define tab-labels (list " Singleplayer "
                         " Multiplayer "
                         " Settings "))

(define tab-panel (new tab-panel%
                    (parent startmenu)
                    (vert-margin 8)
                    (horiz-margin 8)
                    (callback change-tab)
                    (choices tab-labels)))

(define tabs (vector-map (lambda (label)
                           (new vertical-panel%
                             (parent tab-panel)
                             (spacing 4)
                             (vert-margin 8)
                             (horiz-margin 8)
                             (alignment '(left top))))
                         (list->vector tab-labels)))

(define player-side (new choice%
                      (parent (vector-ref tabs 0))
                      (label "Side: ")
                      (choices (list "Blue" "Red"))))

(define play-button (new button%
                      (parent (vector-ref tabs 0))
                      (label " Play Tutorial ")))

(define address (new text-field%
                     (parent (vector-ref tabs 1))
                     (label "Address: ")))

(define connect-button (new button%
                       (parent (vector-ref tabs 1))
                       (label " Connect ")))

(define fullscreen (new check-box%
                     (parent (vector-ref tabs 2))
                     (label " Fullscreen")))

(define v-sync (new check-box%
                 (parent (vector-ref tabs 2))
                 (label " V-Sync")))

(module+ main
  (send tab-panel
        change-children
        (lambda (children)
          (list (vector-ref tabs 0))))
  (send startmenu show #t))

```

Is this (roughly) how the tab-panel is supposed to be used? Or am I doing something braindead here?

Especially the change-children method with it's filter function argument I found confusing. I'm not sure if I've ever seen an application were upon the selection of a tab did _not_ the entire content area change. Why would I ever want to filter the children?

Also note the call to change-children in the main module. Without it, all widgets would be rendered initially in the "Singleplayer" tab.

Thus my question: am I demonstrating a profound misunderstanding of how the tab-panel is supposed to be used?

---

<div class="post-metadata">

**Author:** ![jjsimpso](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jjsimpso/32/602_2.png) [@jjsimpso](https://racket.discourse.group/u/jjsimpso)\
**Post date:** [December 4, 2026, 8:59pm UTC](https://racket.discourse.group/t/tab-panel-in-the-graphical-interface-toolkit/4525/2 "2026-12-04T20:59:04Z")

</div>

I think you are doing it correctly. `change-children` is used to set the contents of the visible tab. In the code I have using a tab panel, the only time I use the `children` argument to the filter function is in a function that is adding a find-in-page widget to the bottom of the tab's contents(see below). For comparison, here are a few functions I wrote to do similar stuff:

```scheme
(define (change-tab tp tab-index)
  ;(eprintf "changing to tab ~a~n" tab-index)
  (fill-tab-content tp)
  (define tab-canvas (find-tab-canvas tab-index))
  (when tab-canvas
    ; this will set the status bar's message to the current status of the new tab
    (send tab-canvas update-status)
    (send tab-canvas focus))
  void)

(define (fill-tab-content tp)
  (define current-tab-index (send tp get-selection))
  (send tp change-children
        (lambda (c*)
          ;; return contents of the tab as a list
          (list (tab-info-contents (find-tab-at-index current-tab-index))))))

(define (unhide-find-panel tp)
  (define tab (find-tab-at-index (send tp get-selection)))
  (when tab
    (define find-panel (tab-info-find-panel tab))
    (define tab-contents (tab-info-contents tab))
    (send tab-contents change-children
          (lambda (children)
            ;(define-values (front end) (split-at-right children 1))
            (append children (list find-panel))))
    (send find-panel focus)))

```
