backend_wxcairo.py 848 B

1234567891011121314151617181920212223
  1. import wx.lib.wxcairo as wxcairo
  2. from .backend_cairo import cairo, FigureCanvasCairo
  3. from .backend_wx import _BackendWx, _FigureCanvasWxBase
  4. from .backend_wx import ( # noqa: F401 # pylint: disable=W0611
  5. NavigationToolbar2Wx as NavigationToolbar2WxCairo)
  6. class FigureCanvasWxCairo(FigureCanvasCairo, _FigureCanvasWxBase):
  7. def draw(self, drawDC=None):
  8. size = self.figure.bbox.size.astype(int)
  9. surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, *size)
  10. self._renderer.set_context(cairo.Context(surface))
  11. self._renderer.dpi = self.figure.dpi
  12. self.figure.draw(self._renderer)
  13. self.bitmap = wxcairo.BitmapFromImageSurface(surface)
  14. self._isDrawn = True
  15. self.gui_repaint(drawDC=drawDC)
  16. @_BackendWx.export
  17. class _BackendWxCairo(_BackendWx):
  18. FigureCanvas = FigureCanvasWxCairo