如何在 Racket GUI 工具包中的框架上添加图像?

How to add an Image on a Frame in the Racket GUI Toolkit?

如何将图像(例如 png)添加到 frame% 对象上?

#lang racket
(define my-frame (new frame%))
;want to add an image to my-frame

使用a canvas.

(define my-frame (new frame%
                      [label "Example"]
                      [width 300]
                      [height 300]))

(new canvas% 
     [parent my-frame]
     [paint-callback
      (λ (canvas dc)
        (send dc draw-bitmap (read-bitmap "/path/to/image.png") 0 0))])

(send my-frame show #t)