Re: canvas.render doesn't accept None as second parameter
- From: John Coppens <john jcoppens com>
- To: Damon Chaplin <damonachaplin gmail com>
- Cc: goocanvas-list gnome org
- Subject: Re: canvas.render doesn't accept None as second parameter
- Date: Sun, 27 Mar 2016 20:07:19 -0300
On Sun, 27 Mar 2016 20:54:29 +0100
Damon Chaplin <damonachaplin gmail com> wrote:
1) Is this a doc error or a GI/Goocanvas regression?
It looks like there should be an (allow-none) annotation for
introspection. Though it isn't too important as you usually want to use
a bounds rectangle. Or just use the entire canvas bounds.
The problem is that passing references to variables (to receive the
actual bounds from get_bounds() is, AFAIK, not possible in *Python*).
Any assignment to a variable inside a function makes that variable
local. To be sure, I tried to pass variables as arguments, and elements
of a list, but all produce segmentation faults. I do know how to do this
in C with the & operator, of course.
I suspect the get_bounds() method should be changed to return a 4-tuple
in Python (and not through the parameters, but as a return value).
2) I couldn't find a working demo which uses 'render' and SVG|PNG...surfaces in python.
I don't think I've ever tried SVG or PNG surfaces.
Can you get it to work with a PDF surface? The write_pdf_clicked()
function in goocanvas/demo/demo.c shows how to do that in C. (And it
still seems to work!)
I've found a way to do it, by not using get_bounds() and defining the
bounds manually:
side = self.theme.canvas_size * self.zoom
surface = cairo.SVGSurface("demo.svg", side, side)
cr = cairo.Context(surface)
cr.translate(side/2, side/2)
bounds = goo.CanvasBounds()
bounds.x1 = -side/2; bounds.y1 = -side/2
bounds.x2 = side/2; bounds.y2 = side/2
self.canvas.render(cr, bounds, 1)
I still hope someone can show me how to use get_bounds() in the
GooCanvas Python binding!
Thanks for the hints,
John
PS: This seems to work with any surface... Tested with SVG, PS, PDF.
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]