我目前正在尝试使用球拍图形界面工具在球拍中创建一个信息网格。唯一可用的真实表格是列表框%(参考链接)
要填写表格,我需要使用:
(send a-list-box set choices ...) → void?
choices : (listof label-string?)
选择是列表,是每列的列表。问题是我有可变数量的列。我当前的数据格式如下(list (list 1 2 3) (list 4 5 6))
。目标是执行此命令:(send table set (list 1 2 3) (list 4 5 6)
我已经尝试过的
我做了一个函数,女巫给了我这个输出:"(list 1 2 3) (list 4 5 6)"
想法是然后使用以下命令执行这个字符串命令:
(send table set (eval (call-with-input-string "(list 1 2 3) (list 4 5 6)" read)
我也试过这个:
(eval (call-with-input-string "(send table set (list 1 2 3) (list 4 5 6))" read)
但这给了我一个错误table: undefined;
cannot reference an identifier before its definition
如果您没有看到问题,但现在使用内置 GUI 在球拍中显示数据网格的另一种方式,请分享。谢谢
测试代码
`#lang racket
(require racket/gui/base)
(define frame (new frame%
[label "myTable"]
[width 800]
[height 600]
))
(define table (new list-box%
[parent frame]
[choices (list )]
[label "Test"]
[style (list 'single 'column-headers 'variable-columns)]
[columns (list "C1" "C2" "C3")]))
(define data (list (list "1" "2" "3")
(list "4" "5" "6")
(list "6" "8" "9")))
(send table set (list-ref data 0) (list-ref data 1) (list-ref data 2));--> Works but needs to be aple to handle variable lengtho of data
;(apply send table set data) ;--> ERROR: send: bad syntax
;(map (lambda (element)
; (send table set element)) ;--> ERROR: set in list-box%: column count doesn't match argument count column count: 3 argument count: 1
; data)
(send frame show #t)`