Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Don't use deprecated wx.NewId(). #12861

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 1 commit into from
Dec 1, 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
11 changes: 4 additions & 7 deletions examples/user_interfaces/embedding_in_wx4_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@


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

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

# for simplicity I'm going to reuse a bitmap from wx, you'll
# probably want to add your own.
self.AddTool(self.ON_CUSTOM, 'Click me', _load_bitmap('back.png'),
'Activate custom contol')
self.Bind(wx.EVT_TOOL, self._on_custom, id=self.ON_CUSTOM)
tool = self.AddTool(wx.ID_ANY, 'Click me', _load_bitmap('back.png'),
'Activate custom contol')
self.Bind(wx.EVT_TOOL, self._on_custom, id=tool.GetId())

def _on_custom(self, evt):
# add some text to the axes in a random location in axes (0,1)
Expand Down
29 changes: 4 additions & 25 deletions lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,11 +713,10 @@ def start_event_loop(self, timeout=0):
"""
if hasattr(self, '_event_loop'):
raise RuntimeError("Event loop already running")
id = wx.NewId()
timer = wx.Timer(self, id=id)
timer = wx.Timer(self, id=wx.ID_ANY)
if timeout > 0:
timer.Start(timeout * 1000, oneShot=True)
self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=id)
self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=timer.GetId())

# Event loop handler for start/stop event loop
self._event_loop = wx.GUIEventLoop()
Expand Down Expand Up @@ -1293,26 +1292,6 @@ def resize(self, width, height):
self.canvas.SetInitialSize(wx.Size(width, height))
self.window.GetSizer().Fit(self.window)

# Identifiers for toolbar controls - images_wx contains bitmaps for the images
# used in the controls. wxWindows does not provide any stock images, so I've
# 'stolen' those from GTK2, and transformed them into the appropriate format.
# import images_wx


_NTB_AXISMENU = wx.NewId()
_NTB_AXISMENU_BUTTON = wx.NewId()
_NTB_X_PAN_LEFT = wx.NewId()
_NTB_X_PAN_RIGHT = wx.NewId()
_NTB_X_ZOOMIN = wx.NewId()
_NTB_X_ZOOMOUT = wx.NewId()
_NTB_Y_PAN_UP = wx.NewId()
_NTB_Y_PAN_DOWN = wx.NewId()
_NTB_Y_ZOOMIN = wx.NewId()
_NTB_Y_ZOOMOUT = wx.NewId()
# _NTB_SUBPLOT =wx.NewId()
_NTB_SAVE = wx.NewId()
_NTB_CLOSE = wx.NewId()


def _load_bitmap(filename):
"""
Expand Down Expand Up @@ -1356,7 +1335,7 @@ class MenuButtonWx(wx.Button):

def __init__(self, parent):

wx.Button.__init__(self, parent, _NTB_AXISMENU_BUTTON, "Axes: ",
wx.Button.__init__(self, parent, wx.ID_ANY, "Axes: ",
style=wx.BU_EXACTFIT)
self._toolbar = parent
self._menu = wx.Menu()
Expand All @@ -1369,7 +1348,7 @@ def __init__(self, parent):
False)
self._menu.AppendSeparator()

self.Bind(wx.EVT_BUTTON, self._onMenuButton, id=_NTB_AXISMENU_BUTTON)
self.Bind(wx.EVT_BUTTON, self._onMenuButton, id=self.GetId())
self.Bind(wx.EVT_MENU, self._handleSelectAllAxes, id=self._allId)
self.Bind(wx.EVT_MENU, self._handleInvertAxesSelected,
id=self._invertId)
Expand Down