[racket] Any reason the canvas is still blank?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun May 19 20:27:33 EDT 2013

You need to arrange for this line:

  (send (send canvas get-dc) draw-bitmap (bitmap) 0 0)

to happen whenever the canvas needs to be refreshed, either by overriding
on-paint in canvas% and making the call there, or by using the
paint-callback init arg.

Robby


On Sun, May 19, 2013 at 7:17 PM, Tomás Coiro <tomcoiro at hotmail.com> wrote:

> #lang racket/gui
> (define bitmap (make-parameter #f))
> (define dc (make-parameter #f))
> (define path (make-parameter #f))
>
> (parameterize* ((bitmap (make-bitmap 500 500 #f))
> (dc (let ((temp (new bitmap-dc% (bitmap (bitmap)))))
> (send temp set-pen "black" 2 'solid)
> temp))
> (path (new dc-path%)))
> (define frame (new frame% [min-width (send (bitmap) get-width)]
> [min-height (send (bitmap) get-height)]
> [label "test"]))
> (send (path) move-to 50 50)
> (send (path) line-to 250 250)
> (send (dc) draw-path (path))
> (define canvas (new canvas% [parent frame]))
> (send (send canvas get-dc) draw-bitmap (bitmap) 0 0)
> (send frame show #t))
>
>
> I don't know what i am doing wrong, the bitmap is drawn, if i return it i
> get the line all fine, the problem is that the frame either doesn't get
> updated or never tries to draw. Is this a bug in canvas% or am I doing
> something terribly wrong?
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130519/89f15728/attachment.html>

Posted on the users mailing list.