[pygtk] PyGTK + Cairo + PNG file in the background
David Ripton
dripton at ripton.net
Sat Sep 12 00:50:02 WST 2009
On 2009.09.11 18:10:02 +0200, Fabrice DELENTE wrote:
> I'm trying to develop a small app to do the following:
>
> I'd like to have a PNG file loaded in the background, rescaled to the width
> of my window, with a vertical scroller; I want to be able to click on the
> PNG and type text at the point where I clicked.
>
> I intend to use pangocairo to type the text, and cairo to render the PNG
> file; however I have trouble to find any leads on how to display a PNG file
> in with cairo (I'm getting mixed up between contexts and surfaces: what is
> the difference?)
A surface is a thing you draw on. A context holds the cairo-specific
state related to drawing on a single surface.
Here are a couple of lines to get you started:
surface = cairo.ImageSurface.create_from_png(path)
ctx = cairo.Context(surface)
--
David Ripton dripton at ripton.net
More information about the pygtk
mailing list