开始在 Racket 中选择 GUI 并立即插入标签。就这样被撞了(求代码不多找毛病,我刚开始学Racket):
#lang racket/gui
(define my-settings-hash (make-hash))
(define my-settings-hash "label" "Test")
(define my-settings-hash "width" 300)
(define my-settings-hash "height" 300)
(define my-tabs-list (list "Tab 0"
"Tab 1"
"Tab 2"))
(define root-wnd (new frame% [label (hash-ref my-settibgs-hash "label")]
[width (hash-ref my-settings-hash "width")]
[height (hash-ref my-settings-hash "height"]))
(define tab-panel (new tab-panel%
(parent root-wnd)
(choices my-tabs-list)
(callback
(lambda (tp e)
(case (send tp get-selection)
((0) (send tp change-children (lambda (children) (list a-panel))))
((1) (send tp change-children (lambda (children) (list b-panel))))
((2) (send tp change-children (lambda (children) (list a-panel)))))))))
(define a-panel (new panel%
(parent tab-panel)
(label "A-panel")))
(define b-panel (new panel%
(parent tab-panel)
(label "b-panel")))
(send frame show #t)
(对不起,如果有额外的括号)。这就是问题所在 - 当程序在两个面板的主窗口中启动时,但只有在开关丢失后,一个单独存在。我哪里钝了?如果您能给出更正或工作示例,我将不胜感激(但请以“头”的决定为准,因为直到非常了解球拍并且我无法理解,或多或少复杂)。先感谢您!