gpt4 book ai didi

user-interface - 如何在 Racket GUI Toolkit 中的框架上添加图像?

转载 作者:行者123 更新时间:2023-12-04 07:23:04 25 4
gpt4 key购买 nike

如何将图像(例如 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)

关于user-interface - 如何在 Racket GUI Toolkit 中的框架上添加图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68380048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com