Skip to content

Commit c7b2759

Browse files
committed
use pngs for wx icons
svn path=/branches/v0_91_maint/; revision=5119
1 parent 389636a commit c7b2759

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

lib/matplotlib/backends/backend_wx.py

+25-7
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,24 @@ def _load_bitmap(filename):
14521452
bmp =wx.Bitmap(bmpFilename, wx.BITMAP_TYPE_XPM)
14531453
return bmp
14541454

1455+
def _load_pngicon(filename):
1456+
"""
1457+
Load a png icon file from the backends/images subdirectory in which the
1458+
matplotlib library is installed. The filename parameter should not
1459+
contain any path information as this is determined automatically.
1460+
1461+
Returns a wx.Bitmap object
1462+
"""
1463+
1464+
basedir = os.path.join(rcParams['datapath'],'images')
1465+
1466+
pngFilename = os.path.normpath(os.path.join(basedir, filename))
1467+
if not os.path.exists(pngFilename):
1468+
raise IOError('Could not find bitmap file "%s"; dying'%pngFilename)
1469+
1470+
png =wx.Bitmap(pngFilename, wx.BITMAP_TYPE_PNG)
1471+
return png
1472+
14551473
class MenuButtonWx(wx.Button):
14561474
"""
14571475
wxPython does not permit a menu to be incorporated directly into a toolbar.
@@ -1612,24 +1630,24 @@ def _init_toolbar(self):
16121630

16131631
self.SetToolBitmapSize(wx.Size(24,24))
16141632

1615-
self.AddSimpleTool(_NTB2_HOME, _load_bitmap('home.xpm'),
1633+
self.AddSimpleTool(_NTB2_HOME, _load_pngicon('home.png'),
16161634
'Home', 'Reset original view')
1617-
self.AddSimpleTool(self._NTB2_BACK, _load_bitmap('back.xpm'),
1635+
self.AddSimpleTool(self._NTB2_BACK, _load_pngicon('back.png'),
16181636
'Back', 'Back navigation view')
1619-
self.AddSimpleTool(self._NTB2_FORWARD, _load_bitmap('forward.xpm'),
1637+
self.AddSimpleTool(self._NTB2_FORWARD, _load_pngicon('forward.png'),
16201638
'Forward', 'Forward navigation view')
16211639
# todo: get new bitmap
1622-
self.AddCheckTool(self._NTB2_PAN, _load_bitmap('move.xpm'),
1640+
self.AddCheckTool(self._NTB2_PAN, _load_pngicon('move.png'),
16231641
shortHelp='Pan',
16241642
longHelp='Pan with left, zoom with right')
1625-
self.AddCheckTool(self._NTB2_ZOOM, _load_bitmap('zoom_to_rect.xpm'),
1643+
self.AddCheckTool(self._NTB2_ZOOM, _load_pngicon('zoom_to_rect.png'),
16261644
shortHelp='Zoom', longHelp='Zoom to rectangle')
16271645

16281646
self.AddSeparator()
1629-
self.AddSimpleTool(_NTB2_SUBPLOT, _load_bitmap('subplots.xpm'),
1647+
self.AddSimpleTool(_NTB2_SUBPLOT, _load_pngicon('subplots.png'),
16301648
'Configure subplots', 'Configure subplot parameters')
16311649

1632-
self.AddSimpleTool(_NTB2_SAVE, _load_bitmap('filesave.xpm'),
1650+
self.AddSimpleTool(_NTB2_SAVE, _load_pngicon('filesave.png'),
16331651
'Save', 'Save plot contents to file')
16341652

16351653
if wx.VERSION_STRING >= '2.5':

0 commit comments

Comments
 (0)