【问题标题】:How to add an Image on a Frame in the Racket GUI Toolkit?如何在 Racket GUI Toolkit 中的框架上添加图像?
【发布时间】:2021-09-23 13:10:53
【问题描述】:

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

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

【问题讨论】:

  • 这是#racket,与#scheme 无关。请不要混合这些东西。

标签: user-interface racket


【解决方案1】:

使用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)

【讨论】:

    猜你喜欢
    • 2021-09-27
    • 1970-01-01
    • 2013-01-22
    • 1970-01-01
    • 2011-04-07
    • 2020-04-09
    • 1970-01-01
    • 2016-09-11
    • 2013-04-04
    相关资源
    最近更新 更多