def on_clicked(button): svgview = View(view.canvas) svgview.painter = ItemPainter() # Update bounding boxes with a temporaly CairoContext # (used for stuff like calculating font metrics) tmpsurface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 0, 0) tmpcr = cairo.Context(tmpsurface) svgview.update_bounding_box(tmpcr) tmpcr.show_page() tmpsurface.flush() w, h = svgview.bounding_box.width, svgview.bounding_box.height surface = cairo.SVGSurface("demo.svg", w, h) cr = cairo.Context(surface) svgview.matrix.translate(-svgview.bounding_box.x, -svgview.bounding_box.y) svgview.paint(cr) cr.show_page() surface.flush() surface.finish()
def setUp(self): super(SimpleItemTestCase, self).setUp() self.view = View(self.diagram.canvas)
def setUp(self): super().setUp() self.view = View(self.diagram.canvas)