Typed Racket 扩展 gui 类

Typed Racket extend gui classes

我想扩展 class horizontal-panel%但不知何故我收到此错误消息:

class has init `stretchable-height' that is not in expected type in: (class horizontal-panel% (super-new))

到目前为止,这是我的代码:

#lang typed/racket
(require typed/racket/gui)

(define-type Graph-Tab%
  (Class #:implements  Horizontal-Panel%

         ))
(: graph-tab% : Graph-Tab%)
(define graph-tab%
  (class horizontal-panel%
    (super-new)

    ))

你可能会说我是球拍的新手,我还在学习中。

我很确定该错误消息的意思是您需要“初始化”class 中的所有内容。

一个有用的方法是将类型定义中的 #:implements 更改为 #:implements/inits 并在缺失值上调用 init(在本例中为 stretchable-height) .

如果您不确切知道这些是什么,您可以简单地输入 (init-rest),这样就可以了。

(这里是 Initialization Variables and also for horizontal-panel% 的文档)