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

Skip to content

Commit 898fbaa

Browse files
Merge pull request #12861 from anntzer/wxnewid
Don't use deprecated wx.NewId().
2 parents 2c1cd6b + 8882f3c commit 898fbaa

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

examples/user_interfaces/embedding_in_wx4_sgskip.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,16 @@
1717

1818

1919
class MyNavigationToolbar(NavigationToolbar):
20-
"""
21-
Extend the default wx toolbar with your own event handlers
22-
"""
23-
ON_CUSTOM = wx.NewId()
20+
"""Extend the default wx toolbar with your own event handlers."""
2421

2522
def __init__(self, canvas, cankill):
2623
NavigationToolbar.__init__(self, canvas)
2724

2825
# for simplicity I'm going to reuse a bitmap from wx, you'll
2926
# probably want to add your own.
30-
self.AddTool(self.ON_CUSTOM, 'Click me', _load_bitmap('back.png'),
31-
'Activate custom contol')
32-
self.Bind(wx.EVT_TOOL, self._on_custom, id=self.ON_CUSTOM)
27+
tool = self.AddTool(wx.ID_ANY, 'Click me', _load_bitmap('back.png'),
28+
'Activate custom contol')
29+
self.Bind(wx.EVT_TOOL, self._on_custom, id=tool.GetId())
3330

3431
def _on_custom(self, evt):
3532
# add some text to the axes in a random location in axes (0,1)

lib/matplotlib/backends/backend_wx.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,10 @@ def start_event_loop(self, timeout=0):
713713
"""
714714
if hasattr(self, '_event_loop'):
715715
raise RuntimeError("Event loop already running")
716-
id = wx.NewId()
717-
timer = wx.Timer(self, id=id)
716+
timer = wx.Timer(self, id=wx.ID_ANY)
718717
if timeout > 0:
719718
timer.Start(timeout * 1000, oneShot=True)
720-
self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=id)
719+
self.Bind(wx.EVT_TIMER, self.stop_event_loop, id=timer.GetId())
721720

722721
# Event loop handler for start/stop event loop
723722
self._event_loop = wx.GUIEventLoop()
@@ -1292,26 +1291,6 @@ def resize(self, width, height):
12921291
self.canvas.SetInitialSize(wx.Size(width, height))
12931292
self.window.GetSizer().Fit(self.window)
12941293

1295-
# Identifiers for toolbar controls - images_wx contains bitmaps for the images
1296-
# used in the controls. wxWindows does not provide any stock images, so I've
1297-
# 'stolen' those from GTK2, and transformed them into the appropriate format.
1298-
# import images_wx
1299-
1300-
1301-
_NTB_AXISMENU = wx.NewId()
1302-
_NTB_AXISMENU_BUTTON = wx.NewId()
1303-
_NTB_X_PAN_LEFT = wx.NewId()
1304-
_NTB_X_PAN_RIGHT = wx.NewId()
1305-
_NTB_X_ZOOMIN = wx.NewId()
1306-
_NTB_X_ZOOMOUT = wx.NewId()
1307-
_NTB_Y_PAN_UP = wx.NewId()
1308-
_NTB_Y_PAN_DOWN = wx.NewId()
1309-
_NTB_Y_ZOOMIN = wx.NewId()
1310-
_NTB_Y_ZOOMOUT = wx.NewId()
1311-
# _NTB_SUBPLOT =wx.NewId()
1312-
_NTB_SAVE = wx.NewId()
1313-
_NTB_CLOSE = wx.NewId()
1314-
13151294

13161295
def _load_bitmap(filename):
13171296
"""
@@ -1355,7 +1334,7 @@ class MenuButtonWx(wx.Button):
13551334

13561335
def __init__(self, parent):
13571336

1358-
wx.Button.__init__(self, parent, _NTB_AXISMENU_BUTTON, "Axes: ",
1337+
wx.Button.__init__(self, parent, wx.ID_ANY, "Axes: ",
13591338
style=wx.BU_EXACTFIT)
13601339
self._toolbar = parent
13611340
self._menu = wx.Menu()
@@ -1368,7 +1347,7 @@ def __init__(self, parent):
13681347
False)
13691348
self._menu.AppendSeparator()
13701349

1371-
self.Bind(wx.EVT_BUTTON, self._onMenuButton, id=_NTB_AXISMENU_BUTTON)
1350+
self.Bind(wx.EVT_BUTTON, self._onMenuButton, id=self.GetId())
13721351
self.Bind(wx.EVT_MENU, self._handleSelectAllAxes, id=self._allId)
13731352
self.Bind(wx.EVT_MENU, self._handleInvertAxesSelected,
13741353
id=self._invertId)

0 commit comments

Comments
 (0)