Is there a cairo like surface for the screen without the window hassle

Nobody nobody at nowhere.invalid
Tue Feb 3 07:17:07 EST 2015


On Mon, 02 Feb 2015 14:20:56 +0100, Antoon Pardon wrote:

> I need to have a program construct a number of designs. Of course I can
> directly use a pfd surface and later use a pdf viewer to check. But that
> becomes rather cumbersome fast. But if I use a cairo-surface for on the
> screen I suddenly have to cope with expose events and all such things I
> am not really interested in.

If you're writing a GUI application, something has to deal with those
events regardless of which rendering API you use.

> So does someone know of a package that provides a cairo like surface but
> that would take care of the events in a rather straight forward matter,
> so that my program could make it's design in a window on the screen just
> as if it is designing it in a pdf file.

What exactly is the issue here? That you want to be able to construct a
graphical representation then discard the data used to construct it,
rather than having to keep it around in order to handle subsequent expose
events?

If that's the case, the simplest solution is probably to render to an
image surface then handle expose events by drawing the image onto the
screen (or handing the image to some kind of "widget" which does this for
you).

Or, if you want to support dynamic scaling, you can "render" to an SVG
surface instead, but widgets which can display SVG aren't as common as
those which deal with raster formats.

Another solution is to render to a recording surface. This can then be
used as a source surface, so handling expose events boils down to a single
cairo_paint() operation with the recording surface as the source surface
and the window as the destination surface. Maybe there's even a widget
somewhere which does this, but I don't know of one.




More information about the Python-list mailing list