[cairo] PyGtk Drag and Drop in a gtk.DrawingArea

Bill Spitzak spitzak at gmail.com
Mon Jul 13 09:49:13 PDT 2009



Gerdus van Zyl wrote:
> You are issuing cairo command in the motion-notify-event which won't
> work, do all drawing on expose.  On the motion-notify do a
> self.window.queue_draw_area(int(x), int(y), int(w), int(h)) with a
> dirty rectangle, an area that encloses all the changes, so a smaller
> area needs to be drawn. Also note that the calls to
> self.expose(widget, None) will also not have a visible effect except
> slowing things down.

Yes, doing this is far more important than any other speed issues. It 
will turn "slowness" into "jumpyness" which is a lot less objectionable, 
and then you can work on the drawing speed.

To really minimize the update area, you can record where you last drew 
the dragged object in some static variables. This is done when the 
expose draws the new image. On a mouse-move, just queue that location as 
dirty, not the new location. The problem is that when you actually do 
the expose drawing you have to then indicate the new location is "dirty" 
somehow, depending on the widget library this may be trivial or 
incredibly difficult. But this I have found helps a lot as you avoid 
useless redrawing of the path the dragged object moved "through" but 
never appeared in.


More information about the cairo mailing list