[[ I am tempted to say that you misplaced the parentheses and brackets and broke lines at the wrong place. ]]
Here is a re-ordering of the first "don't work" variant that kind of works: #lang racket (require slideshow racket/class racket/gui/base) (define my-frame (new frame% [label "my frame"] [width 300] [height 300] [alignment '(center center)])) (define my-canvas (new canvas% [parent my-frame])) (define my-dc (send my-canvas get-dc)) (send my-frame show #t) (draw-pict (circle 60) my-dc 40 40) (sleep 1) Stop! This should give you a hint of why you need to have an callback function in this world. In this world, many different events affect the visible canvas and it needs to refresh itself all the time. Omitting the callback says "draw nothing" when you refresh. On Jun 22, 2015, at 2:17 PM, Mianlai Zhou <mianlai.resea...@gmail.com> wrote: > Hi people, > > I am wondering why this segment of code failed to work: > > ; don't work > #lang racket > > (require slideshow racket/class racket/gui/base) > > (define my-frame (new frame% [label "my frame"] > [width 300] [height 300] > [alignment '(center center)] )) > > (define my-canvas > (new canvas% [parent my-frame] > )) > > (define my-dc (send my-canvas get-dc)) > > (draw-pict (circle 60) my-dc 40 40) > > (send my-frame show #t) > > While the following codes *do* work: > > ; do work > #lang racket > > (require slideshow racket/class racket/gui/base) > > (define my-frame (new frame% [label "my frame"] > [width 300] [height 300] > [alignment '(center center)] )) > > (define my-canvas > (new canvas% [parent my-frame] > [paint-callback (lambda (self dc) > (draw-pict (circle 60) dc 40 40) > > )] > )) > > (send my-frame show #t) > > Is there anyway to avoid using redefining paint-callback to draw one or more > pictures on the canvas, as in the first example? > > Thanks in advance for your answer, > > Mianlai > > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.