On Wed, 28 May 2003, John Hunter wrote:
>
> I have a several classes, all derived from a single base class Artist,
> which render into a gtk.gdk.Drawable with a call to 'draw'. Artist
> instances can contain instances of Artist children. When an instance
> receives a draw request (may come from interactive use or a timeout)
> it draws into the drawable and then passes the request on to the
> children it contains.
>
> The problem is that this introduces flicker as A draws it's
> background, and then A's children draw over it.
>
Does Artist contain a DrawingArea or inherit from a DrawingArea? If it
inherits from DrawingArea, it should be possible to add a hook onto the
expose handler which checks a enableScreenRefresh variable or something.
(similar to the old freeze()/thaw() combo of CList/CTree).
If it contains the DrawingArea, you might want to inherit your own
ArtistDrawingArea class that does a similar thing and contain that
instead. Again, you can hook into the expose handler.
> Where drawable is a gtk.gdk.Window. What I am currently doing is
> drawing to a pixmap
>
> self.draw(pixmap)
> for child in self.get_artists():
> child.draw(pixmap)
> drawable.draw_drawable(gc, pixmap, 0, 0, 0, 0, self.width, self.height)
>
> This works, and produces flicker free drawings, but I suffer a
> performance hit.
Really? What from? The answer to the question isn't necessarily obvious.
Gtk can store pixmaps and images on the server or on the client. The
server can store pixmaps in the card or in main memory. It is sometimes
hard to unravel what is where.
Gtk is doing the exact same operation as you show underneath the covers.
In order to prevent this, all of my classes which inherit from DrawingArea
have this line in the __init__ method:
self.set_double_buffered(False)
This causes Gtk to turn off double buffering and release the corresponding
memory. Double buffering may be fine for other widgets, but it is almost
never what you want for a DrawingArea.
-a
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/