[cairo] Can't draw more

Kalle Vahlman kalle.vahlman at gmail.com
Sun Nov 25 06:13:25 PST 2007


2007/11/24, Gary Jaffe <gfj555 at gmail.com>:
[...]
> Then in my configure_event I'm doing
> ------------------------------------------------------------------------
> x, y, width, height = widget.get_allocation()
> self.context = widget.window.cairo_create()
> self.context.rectangle(x, y, width, height)
> self.context.clip()
> self.context.set_source_surface(self.bkgrndSurface, 0, 0)
> self.context.paint()
> ------------------------------------------------------------------------

This part won't do any good for you, since the expose event is going
to wipe out anything you draw outside the expose handler.

> and in my expose_event I'm doing
> ------------------------------------------------------------------------
> self.context.set_source_surface(self.bkgrndSurface)
> self.context.paint()
> ------------------------------------------------------------------------

This looks ok, assuming that the self.context isn't the same you
create in the configure event...

> What happens upon startup is that my png image flickers on the screen
> for a split second and then the image goes blank.  Can anyone see what
> I'm doing wrong?

...but it sounds like it is. What happens here is that you create a
context in the configure event for the *real* window, and then
anything you draw on it is wiped out by GTK+ in preparation for the
expose handler. In general, you should never store the context for a
GTK+ window outside the expose handler (since it likely will not be
for the surface you actually want to draw on) but instead always
create it inside it.

-- 
Kalle Vahlman, zuh at iki.fi
Powered by http://movial.fi
Interesting stuff at http://syslog.movial.fi


More information about the cairo mailing list