I am creating a little hobby project with Racket GUI classes. For that I got 
the following code, which creates a frame%:

#lang racket/gui

(require table-panel
         "vocabulary.rkt")
(provide build-gui)


(define (clear-children an-area-container)
  (for ([child (send an-area-container get-children)])
    (send an-area-container delete-child child)))


(define (build-gui)
  ; Make a frame by instantiating the frame% class
  (define frame (new frame%
                     [label "Example"]
                     [alignment (list 'center 'center)]
                     [min-width 320]
                     [min-height 240]))
  (define tab-panel (new tab-panel%
                         [parent frame]
                         [choices (map (lambda (voc) (get-vocabulary-identifier 
voc))
                                       VOCABULARY)]
                         [callback
                          (lambda (widget event)
                            (let* ([tab-selection-index (send tab-panel
                                                              get-selection)]
                                   [tab-label (send tab-panel
                                                    get-item-label
                                                    tab-selection-index)])
                              (set-tab-panel-content tab-panel tab-label)))]))
  (define (set-tab-panel-content a-tab-panel a-label)
    (clear-children a-tab-panel)
    (define progress
      (exact-floor
       (* 100
          (get-vocabulary-learn-progress
           (first (get-vocabularies-by-identifier a-label))))))
    (define progress-gauge
      (new gauge%
           [label (string-append "Progress (" (number->string (/ progress 
100.0)) "%): ")]
           [range 10000]
           [parent a-tab-panel]
           [min-width 100]))
    (define table-panel
      (new table-panel%
          [parent tab-panel]
          [alignment '(center center)]
          [dimensions '(4 2)]))
    (define (initialize-widgets)
      (send progress-gauge set-value progress)
      (for ((i (in-range 4)))
        (let ([child-table (new table-panel%
                                [parent table-panel]
                                [style '(border)]
                                [dimensions (list 4 3)]
                                [column-stretchability (if (memq i '(0 1)) #t 
#f)]
                                [row-stretchability (if (memq i '(0 2)) #t 
#f)])])
          (for ([label-string (list "1" "2" "3"
                                    "4" "5" "6"
                                    "7" "8" "9"
                                    "*" "0" "#")])
            (new button%
                 [parent child-table]
                 [label label-string]
                 [stretchable-width #t]
                 [stretchable-height #t]
                 [callback
                  (lambda (button event)
                    (displayln (send button get-label)))])))))
    (initialize-widgets))

  (define (set-initial-gui-state)
    (set-tab-panel-content tab-panel
                           (send tab-panel get-item-label 0)))

  ;; initialize things
  (set-initial-gui-state)

  ;; return the frame
  frame)

When I `show` this frame using:

(send frame show true)

It at first renders the table-panel fine, but when I switch the tabs in the 
tab-panel, I get weird errors:

compute-sizes: undefined;
 cannot use field before initialization
  context...:
   /home/xiaolong/.racket/6.8/pkgs/table-panel/main.rkt:340:4: container-size 
method in table-panel%
   /usr/share/racket/collects/racket/private/more-scheme.rkt:148:2: 
call-with-break-parameterization
   /usr/share/racket/pkgs/gui-lib/mred/private/wxcontainer.rkt:20:31: 
get-graphical-min-size method in ...vate/wxcontainer.rkt:13:4
   /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:347:8: get-min-size 
method in .../private/wxpanel.rkt:71:4
   /usr/share/racket/pkgs/gui-lib/mred/private/wxitem.rkt:155:10: get-info 
method in ...d/private/wxitem.rkt:34:6
   /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:255:8: 
get-children-info method in .../private/wxpanel.rkt:71:4
   /usr/share/racket/pkgs/gui-lib/mred/private/wxcontainer.rkt:20:31: 
get-graphical-min-size method in ...vate/wxcontainer.rkt:13:4
   /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:347:8: get-min-size 
method in .../private/wxpanel.rkt:71:4
   /usr/share/racket/pkgs/gui-lib/mred/private/wxitem.rkt:155:10: get-info 
method in ...d/private/wxitem.rkt:34:6
   /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:255:8: 
get-children-info method in .../private/wxpanel.rkt:71:4
   /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:287:8: 
do-graphical-size method in .../private/wxpanel.rkt:71:4
   /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:347:8: get-min-size 
method in .../private/wxpanel.rkt:71:4
   /usr/share/racket/pkgs/gui-lib/mred/private/wxitem.rkt:155:10: get-info 
method in ...d/private/wxitem.rkt:34:6
   /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:255:8: 
get-children-info method in .../private/wxpanel.rkt:71:4
   /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:287:8: 
do-graphical-size method in .../private/wxpanel.rkt:71:4
   /usr/share/racket/pkgs/gui-lib/mred/private/wxpanel.rkt:347:8: get-min-size 
method in .../private/wxpanel.rkt:71:4
   ...

Is this a bug in the table-panel% ? If it is in my code, what is causing this? 
Can you help me out? I can also consider alternatives to the table-panel%, 
which might work.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to