8000 wx_compat is no more. · matplotlib/matplotlib@d61b990 · GitHub
[go: up one dir, main page]

Skip to content

Commit d61b990

Browse files
committed
wx_compat is no more.
1 parent 8af1fac commit d61b990

File tree

7 files changed

+114
-254
lines changed

7 files changed

+114
-254
lines changed

doc/api/next_api_changes/2018-02-15-AL-deprecations.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The following modules are deprecated:
55
- :mod:`matplotlib.compat.subprocess`. This was a python 2 workaround, but all
66
the functionality can now be found in the python 3 standard library
77
:mod:`subprocess`.
8+
- :mod:`matplotlib.backends.wx_compat`. Python 3 is only compatible with
9+
wxPython 4, so support for wxPython 3 or earlier can be dropped.
810

911
The following classes, methods, and functions are deprecated:
1012

examples/user_interfaces/mathtext_wx_sgskip.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import matplotlib
1111
matplotlib.use("WxAgg")
1212
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
13-
from matplotlib.backends.backend_wx import NavigationToolbar2Wx, wxc
13+
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
1414
from matplotlib.figure import Figure
1515
import numpy as np
1616

@@ -27,7 +27,7 @@
2727

2828
def mathtext_to_wxbitmap(s):
2929
ftimage, depth = mathtext_parser.parse(s, 150)
30-
return wxc.BitmapFromBuffer(
30+
return wx.Bitmap.FromBufferRGBA(
3131
ftimage.get_width(), ftimage.get_height(),
3232
ftimage.as_rgba_str())
3333
############################################################
@@ -43,7 +43,6 @@ def mathtext_to_wxbitmap(s):
4343
class CanvasFrame(wx.Frame):
4444
def __init__(self, parent, title):
4545
wx.Frame.__init__(self, parent, -1, title, size=(550, 350))
46-
self.SetBackgroundColour(wxc.NamedColour("WHITE"))
4746

4847
self.figure = Figure()
4948
self.axes = self.figure.add_subplot(111)
@@ -71,7 +70,7 @@ def __init__(self, parent, title):
7170
bm = mathtext_to_wxbitmap(mt)
7271
item = wx.MenuItem(menu, 1000 + i, " ")
7372
item.SetBitmap(bm)
74-
menu.AppendItem(item)
73+
menu.Append(item)
7574
self.Bind(wx.EVT_MENU, self.OnChangePlot, item)
7675
menuBar.Append(menu, "&Functions")
7776

examples/user_interfaces/wxcursor_demo_sgskip.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
11-
from matplotlib.backends.backend_wx import NavigationToolbar2Wx, wxc
11+
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
1212
from matplotlib.figure import Figure
1313
import numpy as np
1414

@@ -17,10 +17,7 @@
1717

1818
class CanvasFrame(wx.Frame):
1919
def __init__(self, ):
20-
wx.Frame.__init__(self, None, -1,
21-
'CanvasFrame', size=(550, 350))
22-
23-
self.SetBackgroundColour(wxc.NamedColour("WHITE"))
20+
wx.Frame.__init__(self, None, -1, 'CanvasFrame', size=(550, 350))
2421

2522 self.figure = Figure()
2623
self.axes = self.figure.add_subplot(111)
@@ -33,7 +30,8 @@ def __init__(self, ):
3330
self.figure_canvas = FigureCanvas(self, -1, self.figure)
3431

3532
# Note that event is a MplEvent
36-
self.figure_canvas.mpl_connect('motion_notify_event', self.UpdateStatusBar)
33+
self.figure_canvas.mpl_connect(
34+
'motion_notify_event', self.UpdateStatusBar)
3735
self.figure_canvas.Bind(wx.EVT_ENTER_WINDOW, self.ChangeCursor)
3836

3937
self.sizer = wx.BoxSizer(wx.VERTICAL)
@@ -49,14 +47,12 @@ def __init__(self, ):
4947
self.toolbar.Show()
5048

5149
def ChangeCursor(self, event):
52-
self.figure_canvas.SetCursor(wxc.StockCursor(wx.CURSOR_BULLSEYE))
50+
self.figure_canvas.SetCursor(wx.Cursor(wx.CURSOR_BULLSEYE))
5351

5452
def UpdateStatusBar(self, event):
5553
if event.inaxes:
56-
x, y = event.xdata, event.ydata
57-
self.statusBar.SetStatusText(("x= " + str(x) +
58-
" y=" + str(y)),
59-
0)
54+
self.statusBar.SetStatusText(
55+
"x={} y={}".format(event.xdata, event.ydata))
6056

6157

6258
class App(wx.App):

lib/matplotlib/animation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,7 @@ def grab_frame(self, **savefig_kwargs):
383383
dpi=self.dpi, **savefig_kwargs)
384384
except (RuntimeError, IOError) as e:
385385
out, err = self._proc.communicate()
386-
_log.info('MovieWriter -- Error '
387-
'running proc:\n%s\n%s' % (out, err))
386+
_log.info('MovieWriter -- Error running proc:\n%s\n%s', out, err)
388387
raise IOError('Error saving animation to file (cause: {0}) '
389388
'Stdout: {1} StdError: {2}. It may help to re-run '
390389
'with logging level set to '
@@ -537,8 +536,7 @@ def grab_frame(self, **savefig_kwargs):
537536

538537
except RuntimeError:
539538
out, err = self._proc.communicate()
540-
_log.info('MovieWriter -- Error '
541-
'running proc:\n%s\n%s' % (out, err))
539+
_log.info('MovieWriter -- Error running proc:\n%s\n%s', out, err)
542540
raise
543541

544542
def finish(self):

0 commit comments

Comments
 (0)
0