3

I'm just starting out writing GUI apps with Python and selected GTK3 as the platform (switched from QT after it kept crashing with GC errors when using python Threads).

I continue to struggle with the documentation and API references. In this particular case, I want to create an image surface for text. My problem is with definitions and imports.

The docs say to:

from gi.repository import GLib, Gtk, GObject, Pango, cairo, PangoCairo

When I do this, and then try and use:

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 300, 100);

... i get definition errors. However, if I import cairo directly (not from gi.repo), it works fine.

When using only the gi.repo imports, this:

surface = cairo.image_surface_create(cairo.FORMAT_ARGB32, 300, 100)

...doesn't fail on the method definition, but FORMAT_ARGB32 is not defined.

So I guess I have two questions:

First, what is the proper way in GTK3 to import cairo and create an image surface?

Second, where are the authoritative docs for this particular situation?

(I'm developing on Ubuntu 12.04 and python 2.7)

RLI123
  • 487
  • 3
  • 13
  • For documentation you should have a look [here](https://lazka.github.io/pgi-docs/). – elya5 Oct 27 '14 at 11:54
  • The URL quoted doesn't have any documentation for cairo that I can see. I think the gobject translation of cairo is broken. Even if you supply a raw integer for the first arg the call is rejected - "TypeError: image_surface_create() takes exactly 0 arguments (3 given)". – Richard Kettlewell Dec 05 '15 at 19:38

0 Answers0