8000 Backend plt/gcf refactor by tacaswell · Pull Request #2624 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backend plt/gcf refactor #2624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5501f4e
first steps to extract FigureManager* and friends from pyplot
tacaswell Nov 29, 2013
373909d
split backend_qt4 into two parts, with and without Gcf
tacaswell Nov 29, 2013
3014931
split backend_qt4agg into two parts.
tacaswell Nov 29, 2013
37e600e
Added a demo-file to show how to use the FigureManager classes to
tacaswell Nov 29, 2013
82f3dea
removed un-needed import of Gcf
tacaswell Nov 29, 2013
1ad0ebf
pep8 on backend_gtk.py
tacaswell Dec 3, 2013
58ea364
pep8 clean up in backend_gdk
tacaswell Dec 3, 2013
f355c0c
removed un-needed Gcf import
tacaswell Dec 3, 2013
d5e47fb
split backend_gcf into two parts,
tacaswell Dec 3, 2013
87781c5
pep8 on backend_gtkagg.py
tacaswell Dec 3, 2013
ce7c2ac
split backend_gktagg.py in to two parts
tacaswell Dec 3, 2013
ec24d0c
updated exclude list
tacaswell Dec 3, 2013
d3ecb67
pep8 clean up on backend_gtk3.py
tacaswell Dec 3, 2013
26fc122
split backend_gtk3 into two parts
tacaswell Dec 3, 2013
fe7cdc0
updated coding standards
tacaswell Dec 3, 2013
b099ddd
pep8 on backend_gtkcairo.py
tacaswell Dec 4, 2013
70939fe
split backend_gtkcairo.py into Gcf dependent and independent
tacaswell Dec 4, 2013
4ec7908
import from _backend_bases in backend_agg to avoid implicit Gcf import
tacaswell Dec 4, 2013
4f9f5b5
pep8 on backend_agg.py
tacaswell Dec 4, 2013
03e86ee
split backend_gtk3agg.py into two parts, the gcf dependent and
tacaswell Dec 4, 2013
d97d98f
updated coding standards exclude list
tacaswell Dec 4, 2013
83caa44
pep8 on backend_gtk3cairo.py
tacaswell Dec 4, 2013
9e74042
pep8 on backend_cairo.py
tacaswell Dec 4, 2013
51ccd5e
changed backend_cairo.py to import from _backend_bases to avoid
tacaswell Dec 4, 2013
efb1881
updated coding standards
tacaswell Dec 4, 2013
f4bdd22
Split backend_gtk3cairo.py into two parts, one dependent on Gcf
tacaswell Dec 4, 2013
a4bda49
Updated embedding_with_qt4_manager.py
tacaswell Dec 5, 2013
407b1ee
Improved class-aliases in _backend_qt*.py
tacaswell Dec 5, 2013
03c43aa
adjusting imports
fariza Dec 18, 2013
35afa92
renamed _backend_bases.py -> base_backend_bases.py
tacaswell Jan 30, 2014
2b213c0
massive rename operation
tacaswell Jan 30, 2014
93fc457
removed rouge merge notation
tacaswell Jan 30, 2014
6401be2
fixed broken import
tacaswell Jan 30, 2014
3ea9f08
pep8 on backend_tkagg.py
tacaswell Jan 30, 2014
b528125
pep8 conformance
tacaswell Jan 31, 2014
1dde78d
removed files that no longer exist
tacaswell Jan 31, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
massive rename operation
_backend*.py -> base_backend_*.py

Done with the aid of sed.
  • Loading branch information
tacaswell committed Jan 30, 2014
commit 2b213c07f421158ddbb4ec42b394e1de57c5346a
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from matplotlib.path import Path
from matplotlib.transforms import Bbox, BboxBase

from matplotlib.backends._backend_agg import RendererAgg as _RendererAgg
from matplotlib.backends.base_backend_agg import RendererAgg as _RendererAgg
from matplotlib import _png

try:
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/backend_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import matplotlib
# pull in everything from the backing file, should probably be more selective
from ._backend_gtk import (new_figure_manager,
from .base_backend_gtk import (new_figure_manager,
new_figure_manager_given_figure,
TimerGTK,
FigureCanvasGTK,
Expand All @@ -17,7 +17,7 @@
backend_version)

# import gtk from the backing file
from ._backend_gtk import gtk
from .base_backend_gtk import gtk
# pull in Gcf
from matplotlib._pylab_helpers import Gcf

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from matplotlib.backend_bases import (ShowBase,
key_press_handler)
# pull in Gcf free parts
from ._backend_gtk3 import (TimerGTK3,
from .base_backend_gtk3 import (TimerGTK3,
FigureCanvasGTK3,
FigureManagerGTK3,
NavigationToolbar2GTK3,
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/backend_gtk3agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import warnings

from matplotlib._pylab_helpers import Gcf
from ._backend_gtk3agg import (FigureCanvasGTK3Agg,
from .base_backend_gtk3agg import (FigureCanvasGTK3Agg,
new_figure_manager,
new_figure_manager_given_figure
)

from ._backend_gtk3 import FigureManagerGTK3
from .base_backend_gtk3 import FigureManagerGTK3
from .backend_gtk3 import (show,
draw_if_interactive,
_gtk_cleanup,
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/backend_gtk3cairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

import six
import warnings
from ._backend_gtk3cairo import (RendererGTK3Cairo,
from .base_backend_gtk3cairo import (RendererGTK3Cairo,
FigureCanvasGTK3Cairo,
new_figure_manager,
new_figure_manager_given_figure)
from ._backend_gtk3 import (FigureManagerGTK3)
from .base_backend_gtk3 import (FigureManagerGTK3)

from matplotlib._pylab_helpers import Gcf
from .backend_gtk3 import (show,
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_gtkagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from matplotlib._pylab_helpers import Gcf
# import the Gcf free parts
from ._backend_gtkagg import (gtk,
from .base_backend_gtkagg import (gtk,
FigureCanvasGTKAgg,
FigureManagerGTKAgg,
NavigationToolbar2GTKAgg,
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_gtkcairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
_gtk_cleanup,
key_press_handler)

from ._backend_gtkcairo import (gtk,
from .base_backend_gtkcairo import (gtk,
new_figure_manager,
new_figure_manager_given_figure,
RendererGTKCairo,
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .qt4_compat import QtCore, QtGui, _getSaveFileName, __version__

# pull in QT specific part
from ._backend_qt4 import (new_figure_manager,
from .base_backend_qt4 import (new_figure_manager,
new_figure_manager_given_figure,
TimerQT,
FigureCanvasQT,
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/backend_qt4agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
from .backend_qt4 import FigureManagerQT


from ._backend_qt4 import (TimerQT,
from .base_backend_qt4 import (TimerQT,
SubplotToolQt,
backend_version)


# import qtAgg stuff
from ._backend_qt4agg import (new_figure_manager,
from .base_backend_qt4agg import (new_figure_manager,
new_figure_manager_given_figure,
NavigationToolbar2QT,
FigureCanvasQTAgg)
Expand Down
10000
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,32 @@
import sys
import warnings

from . import backend_agg
from . import backend_gtk3

from .backend_cairo import cairo, HAS_CAIRO_CFFI
from matplotlib.figure import Figure
from matplotlib import transforms

from base_backend_gtk3 import (FigureCanvasGTK3,
FigureManagerGTK3)
from backend_agg import FigureCanvasAgg

if six.PY3 and not HAS_CAIRO_CFFI:
warnings.warn(
"The Gtk3Agg backend is known to not work on Python 3.x with pycairo. "
"Try installing cairocffi.")


class FigureCanvasGTK3Agg(backend_gtk3.FigureCanvasGTK3,
backend_agg.FigureCanvasAgg):
class FigureCanvasGTK3Agg(FigureCanvasGTK3,
FigureCanvasAgg):
def __init__(self, figure):
backend_gtk3.FigureCanvasGTK3.__init__(self, figure)
FigureCanvasGTK3.__init__(self, figure)
self._bbox_queue = []

def _renderer_init(self):
pass

def _render_figure(self, width, height):
backend_agg.FigureCanvasAgg.draw(self)
FigureCanvasAgg.draw(self)

def on_draw_event(self, widget, ctx):
""" GtkDrawable draw event, like expose_event in GTK 2.X
Expand Down Expand Up @@ -91,7 +94,7 @@ def blit(self, bbox=None):

def print_png(self, filename, *args, **kwargs):
# Do this so we can save the resolution of figure in the PNG file
agg = self.switch_backends(backend_agg.FigureCanvasAgg)
agg = self.switch_backends(FigureCanvasAgg)
return agg.print_png(filename, *args, **kwargs)


Expand All @@ -109,9 +112,9 @@ def new_figure_manager_given_figure(num, figure):
Create a new figure manager instance for the given figure.
"""
canvas = FigureCanvasGTK3Agg(figure)
manager = _backend_gtk3.FigureManagerGTK3(canvas, num)
manager = FigureManagerGTK3(canvas, num)
return manager


FigureCanvas = FigureCanvasGTK3Agg
FigureManager = _backend_gtk3.FigureManagerGTK3
FigureManager = FigureManagerGTK3
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

import six
import warnings
from . import backend_gtk3
from . import backend_cairo
from .backend_cairo import cairo, HAS_CAIRO_CFFI
from base_backend_gtk3 import (FigureCanvasGTK3,
FigureManagerGTK3)

from .backend_cairo import (cairo, HAS_CAIRO_CFFI,
FigureCanvasCairo,
RendererCairo)
from matplotlib.figure import Figure


class RendererGTK3Cairo(backend_cairo.RendererCairo):
class RendererGTK3Cairo(RendererCairo):
def set_context(self, ctx):
if HAS_CAIRO_CFFI:
ctx = cairo.Context._from_pointer(
Expand All @@ -21,10 +24,10 @@ def set_context(self, ctx):
self.gc.ctx = ctx


class FigureCanvasGTK3Cairo(backend_gtk3.FigureCanvasGTK3,
backend_cairo.FigureCanvasCairo):
class FigureCanvasGTK3Cairo(FigureCanvasGTK3,
FigureCanvasCairo):
def __init__(self, figure):
backend_gtk3.FigureCanvasGTK3.__init__(self, figure)
FigureCanvasGTK3.__init__(self, figure)

def _renderer_init(self):
"""use cairo renderer"""
Expand All @@ -50,7 +53,7 @@ def on_draw_event(self, widget, ctx):
return False # finish event propagation?


class FigureManagerGTK3Cairo(backend_gtk3.FigureManagerGTK3):
class FigureManagerGTK3Cairo(FigureManagerGTK3):
pass


Expand All @@ -73,4 +76,4 @@ def new_figure_manager_given_figure(num, figure):


FigureCanvas = FigureCanvasGTK3Cairo
FigureManager = _backend_gtk3.FigureManagerGTK3
FigureManager = FigureManagerGTK3
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import matplotlib
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg
from ._backend_gtk import (gtk,
from .base_backend_gtk import (gtk,
FigureManagerGTK, FigureCanvasGTK,
error_msg_gtk, PIXELS_PER_INCH,
backend_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import cairo.gtk

from matplotlib.backends import backend_cairo
from ._backend_gtk import (FigureCanvasGTK,
from .base_backend_gtk import (FigureCanvasGTK,
FigureManagerGTK,
NavigationToolbar2GTK,
fn_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from .qt4_compat import QtCore, QtGui

# grab the Gcf-less qt4 classes
from ._backend_qt4 import FigureManagerQT
from ._backend_qt4 import FigureCanvasQT
from ._backend_qt4 import NavigationToolbar2QT
from .base_backend_qt4 import FigureManagerQT
from .base_backend_qt4 import FigureCanvasQT
from .base_backend_qt4 import NavigationToolbar2QT

DEBUG = False

Expand Down
0