Skip to content

Commit 804d32e

Browse files
authored
Merge pull request #14689 from anntzer/wxexample
Update embedding_in_wx4 example.
2 parents 59b5e0e + 6e072d1 commit 804d32e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

examples/user_interfaces/embedding_in_wx4_sgskip.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
Embedding in wx #4
44
==================
55
6-
An example of how to use wx or wxagg in an application with a custom toolbar.
6+
An example of how to use wxagg in a wx application with a custom toolbar.
77
"""
88

9-
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
10-
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar
11-
from matplotlib.backends.backend_wx import _load_bitmap
9+
from matplotlib.backends.backend_wxagg import (
10+
FigureCanvasWxAgg as FigureCanvas,
11+
NavigationToolbar2WxAgg as NavigationToolbar,
12+
)
1213
from matplotlib.figure import Figure
1314

1415
import numpy as np
@@ -19,12 +20,11 @@
1920
class MyNavigationToolbar(NavigationToolbar):
2021
"""Extend the default wx toolbar with your own event handlers."""
2122

22-
def __init__(self, canvas, cankill):
23+
def __init__(self, canvas):
2324
NavigationToolbar.__init__(self, canvas)
24-
25-
# for simplicity I'm going to reuse a bitmap from wx, you'll
26-
# probably want to add your own.
27-
tool = self.AddTool(wx.ID_ANY, 'Click me', _load_bitmap('back.png'),
25+
# We use a stock wx bitmap, but you could also use your own image file.
26+
bmp = wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK, wx.ART_TOOLBAR)
27+
tool = self.AddTool(wx.ID_ANY, 'Click me', bmp,
2828
'Activate custom contol')
2929
self.Bind(wx.EVT_TOOL, self._on_custom, id=tool.GetId())
3030

@@ -64,7 +64,7 @@ def __init__(self):
6464
self.sizer = wx.BoxSizer(wx.VERTICAL)
6565
self.sizer.Add(self.canvas, 1, wx.TOP | wx.LEFT | wx.EXPAND)
6666

67-
self.toolbar = MyNavigationToolbar(self.canvas, True)
67+
self.toolbar = MyNavigationToolbar(self.canvas)
6868
self.toolbar.Realize()
6969
# By adding toolbar in sizer, we are able to put it at the bottom
7070
# of the frame - so appearance is closer to GTK version.

0 commit comments

Comments
 (0)