Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang racket/gui
- (define my-tab-panel%
- (class tab-panel%
- (super-new
- [callback (λ(tp e)
- (send tp active-child (send tp get-selection)))])
- (define child-panels '())
- (define/public (add-child-panel p label)
- (set! child-panels (append child-panels (list p)))
- (send this append label)
- ; without this, all the panels will be shown initially
- ; (we only want the first child to be shown at first)
- (when (> (length child-panels) 1)
- (send this delete-child p)))
- (define/public (active-child n)
- (send this change-children
- (lambda (children)
- (list (list-ref child-panels n)))))
- ))
- (define my-tab%
- (class vertical-panel%
- (init parent)
- (init-field label)
- (super-new [parent parent])
- (send parent add-child-panel this label)
- ))
- (define f (new frame% [label "my-frame"]
- [min-width 200] [min-height 200]))
- (define tp (new my-tab-panel% [parent f]
- [choices '()]))
- (define tab1 (new my-tab% [parent tp] [label "Tab 1"]))
- (define tab2 (new my-tab% [parent tp] [label "Tab 2"]))
- (new button% [parent tab1] [label "Button 1"])
- (new message% [parent tab2] [label "Message"])
- (send f show #t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement