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

Gerdus van Zyl gerdusvanzyl at gmail.com
Sat Jul 11 02:32:31 PDT 2009


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.

~Gerdus

On Sat, Jul 11, 2009 at 9:28 AM, Donn<donn.ingle at gmail.com> wrote:
> On Saturday, 11 July 2009 05:05:21 Antoni Boucher wrote:
>> I want to use drag and drop in a gtk.DrawingArea, but when I use it, it is
>> very slow
> Python is pretty slow. GTK on top of Python is slow. Cairo on top of Python is
> slowish. Doing an intense loop that must draw stuff so quickly that the mouse
> is the measure is going to fail.
>
> You can do things to maximise the speed. Before your main drawing loop (where
> you use cairo on the context):
> 1. Pre-calculate as many things as you can.
> 2. Have the least number of if commands possible.
>
> Also I see you using surfaces in your code. I have noticed that those (via
> Python-Cairo) are actually *very* slow. It's faster to draw things in pure
> vectors, even if that means more python-cairo commands!
>
> hth
> \d
> --
> home: http://otherwise.relics.co.za/
> 2D vector animation : https://savannah.nongnu.org/projects/things/
> Font manager : https://savannah.nongnu.org/projects/fontypython/
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>


More information about the cairo mailing list