Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6821ad2

Browse files
committed
WXCairo backend.
1 parent2274725 commit6821ad2

File tree

7 files changed

+73
-8
lines changed

7 files changed

+73
-8
lines changed

‎doc/api/backend_wxcairo_api.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
:mod:`matplotlib.backends.backend_wxcairo`
3+
==========================================
4+
5+
..automodule::matplotlib.backends.backend_wxcairo
6+
:members:
7+
:undoc-members:
8+
:show-inheritance:

‎doc/api/index_backend_api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ backends
2626
backend_tkagg_api.rst
2727
backend_webagg_api.rst
2828
backend_wxagg_api.rst
29+
backend_wxcairo_api.rst

‎doc/users/whats_new/more-cairo.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cairo rendering for Qt and WX canvases
2+
--------------------------------------
3+
4+
The new ``Qt4Cairo``, ``Qt5Cairo``, and ``WXCairo`` backends allow Qt and WX
5+
canvases to use cairo rendering instead of Agg.

‎doc/users/whats_new/qtcairo.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from __future__import (absolute_import,division,print_function,
2+
unicode_literals)
3+
4+
importsix
5+
6+
from .backend_cairoimportcairo,FigureCanvasCairo,RendererCairo
7+
from .backend_wximport (
8+
_BackendWx,_FigureCanvasWxBase,FigureFrameWx,NavigationToolbar2Wx)
9+
10+
importwx
11+
12+
13+
classFigureFrameWxCairo(FigureFrameWx):
14+
defget_canvas(self,fig):
15+
returnFigureCanvasWxCairo(self,-1,fig)
16+
17+
18+
classFigureCanvasWxCairo(_FigureCanvasWxBase,FigureCanvasCairo):
19+
"""
20+
The FigureCanvas contains the figure and does event handling.
21+
22+
In the wxPython backend, it is derived from wxPanel, and (usually) lives
23+
inside a frame instantiated by a FigureManagerWx. The parent window
24+
probably implements a wxSizer to control the displayed control size - but
25+
we give a hint as to our preferred minimum size.
26+
"""
27+
28+
def__init__(self,parent,id,figure):
29+
# _FigureCanvasWxBase should be fixed to have the same signature as
30+
# every other FigureCanvas and use cooperative inheritance, but in the
31+
# meantime the following will make do.
32+
_FigureCanvasWxBase.__init__(self,parent,id,figure)
33+
FigureCanvasCairo.__init__(self,figure)
34+
self._renderer=RendererCairo(self.figure.dpi)
35+
36+
defdraw(self,drawDC=None):
37+
FigureCanvasCairo.draw(self)
38+
width=int(self.figure.bbox.width)
39+
height=int(self.figure.bbox.height)
40+
surface=cairo.ImageSurface(cairo.FORMAT_ARGB32,width,height)
41+
self._renderer.set_ctx_from_surface(surface)
42+
self._renderer.set_width_height(width,height)
43+
self.figure.draw(self._renderer)
44+
buf=surface.get_data()
45+
self.bitmap=wx.Bitmap.FromBufferRGBA(width,height,buf)
46+
self._isDrawn=True
47+
self.gui_repaint(drawDC=drawDC,origin='WXCairo')
48+
49+
50+
@_BackendWx.export
51+
class_BackendWxCairo(_BackendWx):
52+
FigureCanvas=FigureCanvasWxCairo
53+
_frame_class=FigureFrameWxCairo

‎lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
'Qt4Agg','Qt4Cairo','Qt5Agg','Qt5Cairo',
4040
'TkAgg',
4141
'WebAgg',
42-
'WX','WXAgg']
42+
'WX','WXAgg','WXCairo']
4343
non_interactive_bk= ['agg','cairo','gdk',
4444
'pdf','pgf','ps','svg','template']
4545
all_backends=interactive_bk+non_interactive_bk

‎tutorials/introductory/usage.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,12 @@ def my_plotter(ax, data1, data2, param_dict):
446446
# activated in IPython with ``%matplotlib gtk``.
447447
# GTKCairo Cairo rendering to a :term:`GTK` 2.x canvas (requires PyGTK_,
448448
# and pycairo_ or cairocffi_; Python2 only).
449-
# WXAgg Agg rendering to a :term:`wxWidgets` canvas (requires wxPython_;
449+
# WXAgg Agg rendering to a :term:`wxWidgets` canvas (requires wxPython_ --
450450
# v4.0 (in beta) is required for Python3). This backend can be
451-
# activated in IPython with ``%matplotlib wx``.#
451+
# activated in IPython with ``%matplotlib wx``.
452+
# WXCairo Cairo rendering to a :term:`wxWidgets` canvas (requires wxPython_
453+
# -- v4.0 (in beta) is required for Python3, and pycairo_ or
454+
# cairocffi_).
452455
# ========= ================================================================
453456
#
454457
# .. _`Anti-Grain Geometry`: http://antigrain.com/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp