8000 wx_compat is no more. by anntzer · Pull Request #10778 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

wx_compat is no more. #10778

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

Merged
merged 2 commits into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions doc/api/next_api_changes/2018-02-15-AL-deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The following modules are deprecated:
- :mod:`matplotlib.compat.subprocess`. This was a python 2 workaround, but all
the functionality can now be found in the python 3 standard library
:mod:`subprocess`.
- :mod:`matplotlib.backends.wx_compat`. Python 3 is only compatible with
wxPython 4, so support for wxPython 3 or earlier can be dropped.

The following classes, methods, and functions are deprecated:

Expand Down
13 changes: 8 additions & 5 deletions examples/user_interfaces/mathtext_wx_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import matplotlib
matplotlib.use("WxAgg")
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx, wxc
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
import numpy as np

Expand All @@ -27,7 +27,7 @@

def mathtext_to_wxbitmap(s):
ftimage, depth = mathtext_parser.parse(s, 150)
return wxc.BitmapFromBuffer(
return wx.Bitmap.FromBufferRGBA(
ftimage.get_width(), ftimage.get_height(),
ftimage.as_rgba_str())
############################################################
Expand All @@ -43,7 +43,6 @@ def mathtext_to_wxbitmap(s):
class CanvasFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title, size=(550, 350))
self.SetBackgroundColour(wxc.NamedColour("WHITE"))

self.figure = Figure()
self.axes = self.figure.add_subplot(111)
Expand All @@ -61,8 +60,9 @@ def __init__(self, parent, title):

# File Menu
menu = wx.Menu()
menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")
m_exit = menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")
menuBar.Append(menu, "&File")
self.Bind(wx.EVT_MENU, self.OnClose, m_exit)

if IS_GTK or IS_WIN:
# Equation Menu
Expand All @@ -71,7 +71,7 @@ def __init__(self, parent, title):
bm = mathtext_to_wxbitmap(mt)
item = wx.MenuItem(menu, 1000 + i, " ")
item.SetBitmap(bm)
menu.AppendItem(item)
menu.Append(item)
self.Bind(wx.EVT_MENU, self.OnChangePlot, item)
menuBar.Append(menu, "&Functions")

Expand Down Expand Up @@ -113,6 +113,9 @@ def change_plot(self, plot_number):
self.axes.plot(t, s)
self.canvas.draw()

def OnClose(self, event):
self.Destroy()


class MyApp(wx.App):
def OnInit(self):
Expand Down < 8000 /td>
18 changes: 7 additions & 11 deletions examples/user_interfaces/wxcursor_demo_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, wxc
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
import numpy as np

Expand All @@ -17,10 +17,7 @@

class CanvasFrame(wx.Frame):
def __init__(self, ):
wx.Frame.__init__(self, None, -1,
'CanvasFrame', size=(550, 350))

self.SetBackgroundColour(wxc.NamedColour("WHITE"))
wx.Frame.__init__(self, None, -1, 'CanvasFrame', size=(550, 350))

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

# Note that event is a MplEvent
self.figure_canvas.mpl_connect('motion_notify_event', self.UpdateStatusBar)
self.figure_canvas.mpl_connect(
'motion_notify_event', self.UpdateStatusBar)
self.figure_canvas.Bind(wx.EVT_ENTER_WINDOW, self.ChangeCursor)

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

def ChangeCursor(self, event):
self.figure_canvas.SetCursor(wxc.StockCursor(wx.CURSOR_BULLSEYE))
self.figure_canvas.SetCursor(wx.Cursor(wx.CURSOR_BULLSEYE))

def UpdateStatusBar(self, event):
if event.inaxes:
x, y = event.xdata, event.ydata
self.statusBar.SetStatusText(("x= " + str(x) +
" y=" + str(y)),
0)
self.statusBar.SetStatusText(
"x={} y={}".format(event.xdata, event.ydata))


class App(wx.App):
Expand Down
Loading
0