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

Move required_interactive_framework to canvas class.#14521

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ivanov merged 1 commit intomatplotlib:masterfromanntzer:rif
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
11 changes: 11 additions & 0 deletionsdoc/api/next_api_changes/2019-06-12-AL.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
API changes
```````````

The ``required_interactive_framework`` attribute of backend modules introduced
in Matplotlib 3.0 has been moved to the FigureCanvas class, in order to let it
be inherited by third-party canvas subclasses and to make it easier to know
what interactive framework is required by a canvas class.

``backend_qt4.FigureCanvasQT5``, which is an alias for
``backend_qt5.FigureCanvasQT`` (but only exists under that name in
``backend_qt4``), has been removed.
30 changes: 15 additions & 15 deletionslib/matplotlib/backend_bases.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1560,8 +1560,12 @@ class FigureCanvasBase:
----------
figure : `matplotlib.figure.Figure`
A high-level figure instance

"""

# Set to one of {"qt5", "qt4", "gtk3", "wx", "tk", "macosx"} if an
# interactive framework is required, or None otherwise.
required_interactive_framework = None

events = [
'resize_event',
'draw_event',
Expand DownExpand Up@@ -1633,8 +1637,7 @@ def _fix_ipython_backend2gui(cls):
# In case we ever move the patch to IPython and remove these APIs,
# don't break on our side.
return
backend_mod = sys.modules[cls.__module__]
rif = getattr(backend_mod, "required_interactive_framework", None)
rif = getattr(cls, "required_interactive_framework", None)
backend2gui_rif = {"qt5": "qt", "qt4": "qt", "gtk3": "gtk3",
"wx": "wx", "macosx": "osx"}.get(rif)
if backend2gui_rif:
Expand DownExpand Up@@ -3255,10 +3258,6 @@ class _Backend:
# class FooBackend(_Backend):
# # override the attributes and methods documented below.

# Set to one of {"qt5", "qt4", "gtk3", "wx", "tk", "macosx"} if an
# interactive framework is required, or None otherwise.
required_interactive_framework = None

# `backend_version` may be overridden by the subclass.
backend_version = "unknown"

Expand DownExpand Up@@ -3341,14 +3340,15 @@ def show(cls, block=None):

@staticmethod
def export(cls):
for name in ["required_interactive_framework",
"backend_version",
"FigureCanvas",
"FigureManager",
"new_figure_manager",
"new_figure_manager_given_figure",
"draw_if_interactive",
"show"]:
for name in [
"backend_version",
"FigureCanvas",
"FigureManager",
"new_figure_manager",
"new_figure_manager_given_figure",
"draw_if_interactive",
"show",
]:
setattr(sys.modules[cls.__module__], name, getattr(cls, name))

# For back-compatibility, generate a shim `Show` class.
Expand Down
3 changes: 2 additions & 1 deletionlib/matplotlib/backends/_backend_tk.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,6 +124,8 @@ def _on_timer(self):


class FigureCanvasTk(FigureCanvasBase):
required_interactive_framework = "tk"

keyvald = {65507: 'control',
65505: 'shift',
65513: 'alt',
Expand DownExpand Up@@ -868,7 +870,6 @@ def trigger(self, *args):

@_Backend.export
class _BackendTk(_Backend):
required_interactive_framework = "tk"
FigureManager = FigureManagerTk

@classmethod
Expand Down
3 changes: 2 additions & 1 deletionlib/matplotlib/backends/backend_gtk3.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,6 +97,8 @@ def _on_timer(self):


class FigureCanvasGTK3(Gtk.DrawingArea, FigureCanvasBase):
required_interactive_framework = "gtk3"

keyvald = {65507: 'control',
65505: 'shift',
65513: 'alt',
Expand DownExpand Up@@ -978,7 +980,6 @@ def error_msg_gtk(msg, parent=None):

@_Backend.export
class _BackendGTK3(_Backend):
required_interactive_framework = "gtk3"
FigureCanvas = FigureCanvasGTK3
FigureManager = FigureManagerGTK3

Expand Down
4 changes: 2 additions & 2 deletionslib/matplotlib/backends/backend_macosx.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,9 +53,10 @@ class FigureCanvasMac(_macosx.FigureCanvas, FigureCanvasAgg):
----------
figure : `matplotlib.figure.Figure`
A high-level Figure instance
"""

required_interactive_framework="macosx"

def__init__(self,figure):
FigureCanvasBase.__init__(self,figure)
width,height=self.get_width_height()
Expand DownExpand Up@@ -172,7 +173,6 @@ def set_message(self, message):

@_Backend.export
class_BackendMac(_Backend):
required_interactive_framework="macosx"
FigureCanvas=FigureCanvasMac
FigureManager=FigureManagerMac

Expand Down
9 changes: 5 additions & 4 deletionslib/matplotlib/backends/backend_qt4.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
from .backend_qt5import (
backend_version,SPECIAL_KEYS,SUPER,ALT,CTRL,SHIFT,MODIFIER_KEYS,
cursord,_create_qApp,_BackendQT5,TimerQT,MainWindow,FigureManagerQT,
NavigationToolbar2QT,SubplotToolQt,error_msg_qt,exception_handler)
from .backend_qt5importFigureCanvasQTasFigureCanvasQT5
cursord,_create_qApp,_BackendQT5,TimerQT,MainWindow,FigureCanvasQT,
FigureManagerQT,NavigationToolbar2QT,SubplotToolQt,error_msg_qt,
exception_handler)


@_BackendQT5.export
class_BackendQT4(_BackendQT5):
required_interactive_framework="qt4"
classFigureCanvas(FigureCanvasQT):
required_interactive_framework="qt4"
3 changes: 2 additions & 1 deletionlib/matplotlib/backends/backend_qt4agg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,4 +8,5 @@

@_BackendQT5Agg.export
class_BackendQT4Agg(_BackendQT5Agg):
required_interactive_framework="qt4"
classFigureCanvas(FigureCanvasQTAgg):
required_interactive_framework="qt4"
5 changes: 3 additions & 2 deletionslib/matplotlib/backends/backend_qt4cairo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
from .backend_qt5cairoimport_BackendQT5Cairo
from .backend_qt5cairoimport_BackendQT5Cairo,FigureCanvasQTCairo


@_BackendQT5Cairo.export
class_BackendQT4Cairo(_BackendQT5Cairo):
required_interactive_framework="qt4"
classFigureCanvas(FigureCanvasQTCairo):
required_interactive_framework="qt4"
2 changes: 1 addition & 1 deletionlib/matplotlib/backends/backend_qt5.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -211,6 +211,7 @@ def _timer_stop(self):


class FigureCanvasQT(QtWidgets.QWidget, FigureCanvasBase):
required_interactive_framework = "qt5"

# map Qt button codes to MouseEvent's ones:
buttond = {QtCore.Qt.LeftButton: MouseButton.LEFT,
Expand DownExpand Up@@ -1029,7 +1030,6 @@ def trigger(self, *args, **kwargs):

@_Backend.export
class _BackendQT5(_Backend):
required_interactive_framework = "qt5"
FigureCanvas = FigureCanvasQT
FigureManager = FigureManagerQT

Expand Down
3 changes: 2 additions & 1 deletionlib/matplotlib/backends/backend_wx.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -519,6 +519,8 @@ class _FigureCanvasWxBase(FigureCanvasBase, wx.Panel):
we give a hint as to our preferred minimum size.
"""

required_interactive_framework = "wx"

keyvald = {
wx.WXK_CONTROL: 'control',
wx.WXK_SHIFT: 'shift',
Expand DownExpand Up@@ -1933,7 +1935,6 @@ def OnPrintPage(self, page):

@_Backend.export
class _BackendWx(_Backend):
required_interactive_framework = "wx"
FigureCanvas = FigureCanvasWx
FigureManager = FigureManagerWx
_frame_class = FigureFrameWx
Expand Down
3 changes: 2 additions & 1 deletionlib/matplotlib/pyplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -224,7 +224,8 @@ def switch_backend(newbackend):
_log.debug("Loaded backend %s version %s.",
newbackend, Backend.backend_version)

required_framework = Backend.required_interactive_framework
required_framework = getattr(
Backend.FigureCanvas, "required_interactive_framework", None)
if required_framework is not None:
current_framework = \
matplotlib.backends._get_running_interactive_framework()
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp