I'm currently trying to create a a grid of information in Racket using the Racket Graphical Interface Tooling. The only real table that is available is the list-box% (link to reference)
To fill the table I need to use:
(send a-list-box set choices ...) → void?
choices : (listof label-string?)
choices being list being a list of each column. The problem is that I have a variable amount of collumns. My current data is formated like (list (list 1 2 3) (list 4 5 6))
.
The goal is te execute this command: (send table set (list 1 2 3) (list 4 5 6)
What I already tried
I made a function witch gives me this output: "(list 1 2 3) (list 4 5 6)"
The idea was to then execute this string command using:
(send table set (eval (call-with-input-string "(list 1 2 3) (list 4 5 6)" read)
I also tried this:
(eval (call-with-input-string "(send table set (list 1 2 3) (list 4 5 6))" read)
But this gives me an error table: undefined;
cannot reference an identifier before its definition
If you don't see a problem but now an other way to display a grid of data in racket using the build in GUI, please share. Thanks
Test Code
`#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)`