@@ -1392,6 +1392,24 @@ def _load_bitmap(filename):
1392
1392
bmp = wx .Bitmap (bmpFilename , wx .BITMAP_TYPE_XPM )
1393
1393
return bmp
1394
1394
1395
+ def _load_pngicon (filename ):
1396
+ """
1397
+ Load a png icon file from the backends/images subdirectory in which the
1398
+ matplotlib library is installed. The filename parameter should not
1399
+ contain any path information as this is determined automatically.
1400
+
1401
+ Returns a wx.Bitmap object
1402
+ """
1403
+
1404
+ basedir = os .path .join (rcParams ['datapath' ],'images' )
1405
+
1406
+ pngFilename = os .path .normpath (os .path .join (basedir , filename ))
1407
+ if not os .path .exists (pngFilename ):
1408
+ raise IOError ('Could not find bitmap file "%s"; dying' % pngFilename )
1409
+
1410
+ png = wx .Bitmap (pngFilename , wx .BITMAP_TYPE_PNG )
1411
+ return png
1412
+
1395
1413
class MenuButtonWx (wx .Button ):
1396
1414
"""
1397
1415
wxPython does not permit a menu to be incorporated directly into a toolbar.
@@ -1552,24 +1570,24 @@ def _init_toolbar(self):
1552
1570
1553
1571
self .SetToolBitmapSize (wx .Size (24 ,24 ))
1554
1572
1555
- self .AddSimpleTool (_NTB2_HOME , _load_bitmap ('home.xpm ' ),
1573
+ self .AddSimpleTool (_NTB2_HOME , _load_pngicon ('home.png ' ),
1556
1574
'Home' , 'Reset original view' )
1557
- self .AddSimpleTool (self ._NTB2_BACK , _load_bitmap ('back.xpm ' ),
1575
+ self .AddSimpleTool (self ._NTB2_BACK , _load_pngicon ('back.png ' ),
1558
1576
'Back' , 'Back navigation view' )
1559
- self .AddSimpleTool (self ._NTB2_FORWARD , _load_bitmap ('forward.xpm ' ),
1577
+ self .AddSimpleTool (self ._NTB2_FORWARD , _load_pngicon ('forward.png ' ),
1560
1578
'Forward' , 'Forward navigation view' )
1561
1579
# todo: get new bitmap
1562
- self .AddCheckTool (self ._NTB2_PAN , _load_bitmap ('move.xpm ' ),
1580
+ self .AddCheckTool (self ._NTB2_PAN , _load_pngicon ('move.png ' ),
1563
1581
shortHelp = 'Pan' ,
1564
1582
longHelp = 'Pan with left, zoom with right' )
1565
- self .AddCheckTool (self ._NTB2_ZOOM , _load_bitmap ('zoom_to_rect.xpm ' ),
1583
+ self .AddCheckTool (self ._NTB2_ZOOM , _load_pngicon ('zoom_to_rect.png ' ),
1566
1584
shortHelp = 'Zoom' , longHelp = 'Zoom to rectangle' )
1567
1585
1568
1586
self .AddSeparator ()
1569
- self .AddSimpleTool (_NTB2_SUBPLOT , _load_bitmap ('subplots.xpm ' ),
1587
+ self .AddSimpleTool (_NTB2_SUBPLOT , _load_pngicon ('subplots.png ' ),
1570
1588
'Configure subplots' , 'Configure subplot parameters' )
1571
1589
1572
- self .AddSimpleTool (_NTB2_SAVE , _load_bitmap ('filesave.xpm ' ),
1590
+ self .AddSimpleTool (_NTB2_SAVE , _load_pngicon ('filesave.png ' ),
1573
1591
'Save' , 'Save plot contents to file' )
1574
1592
1575
1593
if wx .VERSION_STRING >= '2.5' :
0 commit comments