Re: canvas.render doesn't accept None as second parameter



On Sun, 2016-03-27 at 16:27 -0300, John Coppens wrote:
Hi all,

From a demo I found on the 'net, I used:

        surface = cairo.SVGSurface("demo.svg", 9 * 72, 10 * 72)
        cr = cairo.Context(surface)
        self.canvas.render(cr, None, 1)

This prints:

Traceback (most recent call last):
  File "necview.py", line 351, in save_SVG
    self.canvas.render(cr, None, 1)
  File "/usr/lib64/python2.7/site-packages/gi/types.py", line 44, in function
    return info.invoke(*args)
TypeError: argument 2: Must be GooCanvas.CanvasBounds, not NoneType

According to https://lazka.github.io/pgi-docs/GooCanvas-2.0/classes/Canvas.html#GooCanvas.Canvas.render
render should accept None as second parameter.

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.


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!)

Damon




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]