From: "Daniel P. Zepeda" Date: 2003-01-28T08:00:40+09:00 Subject: Re: [FXRuby] How to force a paint on a canvas. On Tue, 28 Jan 2003 07:28:34 +0900 Steve Tuckner wrote: > Hello all, > > I am working on a simple turtle graphics demonstration program that I > can use to give a demonstration to several classes of 1st graders. The > problem I am having is that I can draw on the canvas widget, but I can't > force it repaint after I draw. The canvas code looks like below: > > @outputCanvas.connect(SEL_PAINT) do |sender, sel, event| > dc = FXDCWindow.new(@outputCanvas) > dc.background = FXColor::White > dc.foreground = FXColor::White > dc.fillRectangle(event.rect.x, event.rect.y, event.rect.w, > event.rect.h) > dc.foreground = FXColor::Red > @actions.each do |action| > action.do(dc) > end > # dc.fillRectangle(0,0,@x,@y) > # @x += 10; @y += 10 > dc.end > end > > on a paint it iterates through a list of actions which do lines and > turns (for now). It works fine except that I have to cover and uncover > the window to see the results. > > I tried FXWindow#repaint and FXApplication#repaint to no avail. > > Any ideas? Try @outputCanvas.update, although you probably want to reorganize your code and connect it to SEL_MOTION instead of SEL_PAINT. As you are seeing, SEL_PAINT only gets sent when the window has been obscured and is uncovered. Look at scribble.rb in the 'examples' directory of the distribution. > > Thanks, > > Steve Tuckner > > -- "Daniel P. Zepeda" (Remove commas for address)