Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions examples/user_interfaces/embedding_in_wx2_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.backends.backend_wx import NavigationToolbar2Wx as NavigationToolbar
from matplotlib.figure import Figure

import numpy as np
Expand Down Expand Up @@ -38,7 +38,7 @@ def __init__(self):
self.add_toolbar() # comment this out for no toolbar

def add_toolbar(self):
self.toolbar = NavigationToolbar2Wx(self.canvas)
self.toolbar = NavigationToolbar(self.canvas)
self.toolbar.Realize()
# By adding toolbar in sizer, we are able to put it at the bottom
# of the frame - so appearance is closer to GTK version.
Expand Down
7 changes: 4 additions & 3 deletions examples/user_interfaces/embedding_in_wx3_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
import matplotlib
import matplotlib.cm as cm
import matplotlib.cbook as cbook
from matplotlib.backends.backend_wxagg import Toolbar, FigureCanvasWxAgg
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar
from matplotlib.figure import Figure
import numpy as np

Expand All @@ -48,8 +49,8 @@ def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)

self.fig = Figure((5, 4), 75)
self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
self.toolbar = Toolbar(self.canvas) # matplotlib toolbar
self.canvas = FigureCanvas(self, -1, self.fig)
self.toolbar = NavigationToolbar(self.canvas) # matplotlib toolbar
self.toolbar.Realize()
# self.toolbar.set_active([0,1])

Expand Down
6 changes: 3 additions & 3 deletions examples/user_interfaces/embedding_in_wx4_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar
from matplotlib.backends.backend_wx import _load_bitmap
from matplotlib.figure import Figure

Expand All @@ -16,14 +16,14 @@
import wx


class MyNavigationToolbar(NavigationToolbar2WxAgg):
class MyNavigationToolbar(NavigationToolbar):
"""
Extend the default wx toolbar with your own event handlers
"""
ON_CUSTOM = wx.NewId()

def __init__(self, canvas, cankill):
NavigationToolbar2WxAgg.__init__(self, canvas)
NavigationToolbar.__init__(self, canvas)

# for simplicity I'm going to reuse a bitmap from wx, you'll
# probably want to add your own.
Expand Down
8 changes: 4 additions & 4 deletions examples/user_interfaces/embedding_in_wx5_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
import wx.aui as aui

import matplotlib as mpl
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2Wx as Toolbar
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar


class Plot(wx.Panel):
def __init__(self, parent, id=-1, dpi=None, **kwargs):
wx.Panel.__init__(self, parent, id=id, **kwargs)
self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
self.canvas = Canvas(self, -1, self.figure)
self.toolbar = Toolbar(self.canvas)
self.canvas = FigureCanvas(self, -1, self.figure)
self.toolbar = NavigationToolbar(self.canvas)
self.toolbar.Realize()

sizer = wx.BoxSizer(wx.VERTICAL)
Expand Down
4 changes: 2 additions & 2 deletions examples/user_interfaces/fourier_demo_wx_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np

import wx
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure


Expand Down Expand Up @@ -123,7 +123,7 @@ def __init__(self, *args, **kwargs):
def createCanvas(self, parent):
self.lines = []
self.figure = Figure()
self.canvas = FigureCanvasWxAgg(parent, -1, self.figure)
self.canvas = FigureCanvas(parent, -1, self.figure)
self.canvas.callbacks.connect('button_press_event', self.mouseDown)
self.canvas.callbacks.connect('motion_notify_event', self.mouseMotion)
self.canvas.callbacks.connect('button_release_event', self.mouseUp)
Expand Down
19 changes: 0 additions & 19 deletions lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1474,25 +1474,6 @@ def updateButtonText(self, lst):
}


class SubplotToolWX(wx.Frame):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API changes (even for "apparently unused" stuff) should nearly always go through a deprecation period unless it's really too hard to keep around. Just decorate the class with @deprecated("2.2").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def __init__(self, targetfig):
wx.Frame.__init__(self, None, -1, "Configure subplots")

toolfig = Figure((6, 3))
canvas = FigureCanvasWx(self, -1, toolfig)

# Create a figure manager to manage things
figmgr = FigureManager(canvas, 1, self)

# Now put all into a sizer
sizer = wx.BoxSizer(wx.VERTICAL)
# This way of adding to sizer allows resizing
sizer.Add(canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizer(sizer)
self.Fit()
tool = SubplotTool(targetfig, toolfig)


class NavigationToolbar2Wx(NavigationToolbar2, wx.ToolBar):
def __init__(self, canvas):
wx.ToolBar.__init__(self, canvas.GetParent(), -1)
Expand Down
11 changes: 2 additions & 9 deletions lib/matplotlib/backends/backend_wxagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from .. import cbook
from . import wx_compat as wxc
from .backend_agg import FigureCanvasAgg
from .backend_wx import (
_BackendWx, _FigureCanvasWxBase, FigureFrameWx, NavigationToolbar2Wx)
from .backend_wx import _BackendWx, _FigureCanvasWxBase, FigureFrameWx
from .backend_wx import NavigationToolbar2Wx as NavigationToolbar2WxAgg


class FigureFrameWxAgg(FigureFrameWx):
Expand Down Expand Up @@ -71,15 +71,8 @@ def blit(self, bbox=None):
filetypes = FigureCanvasAgg.filetypes


@cbook.deprecated("2.2")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave until 3.0 (one minor-release deprecation period at least, usually two).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see that any other NavigationToolbar2 is deprecated, especially not the wx non-Agg one.
With the derived class removed and the modified import NavigationToolbar2Wx as NavigationToolbar2WxAgg things are consistent again (no deprecation).

Not having the Toolbar alias in backend_wxagg can break things, though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a deprecation for the Toolbar alias would require to replace the assignment Toolbar = NavigationToolbar2Wx with a derived and deprecated class. I would now be in favor of having this in wx and wxagg. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derived deprecated class sounds good to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Done, incl. alternatives in deprecation messages.

class NavigationToolbar2WxAgg(NavigationToolbar2Wx):
def get_canvas(self, frame, fig):
return FigureCanvasWxAgg(frame, -1, fig)


# agg/wxPython image conversion functions (wxPython >= 2.8)


def _convert_agg_to_wx_image(agg, bbox):
"""
Convert the region of the agg buffer bounded by bbox to a wx.Image. If
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/backend_wxcairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import wx

from .backend_cairo import cairo, FigureCanvasCairo, RendererCairo
from .backend_wx import (
_BackendWx, _FigureCanvasWxBase, FigureFrameWx, NavigationToolbar2Wx)
from .backend_wx import _BackendWx, _FigureCanvasWxBase, FigureFrameWx
from .backend_wx import NavigationToolbar2Wx as NavigationToolbar2WxCairo

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can go in the previous line (would prefer this) as

from .backend_wx import (
    _BackendWx, _FigureCanvasWxBase, FigureFrameWx,
    NavigationToolbar2Wx as NavigationToolbar2WxCairo)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, also for wxagg.

from . import wx_compat as wxc


Expand Down