@@ -1452,6 +1452,24 @@ def _load_bitmap(filename):
1452
1452
bmp = wx .Bitmap (bmpFilename , wx .BITMAP_TYPE_XPM )
1453
1453
return bmp
1454
1454
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
+
1455
1473
class MenuButtonWx (wx .Button ):
1456
1474
"""
1457
1475
wxPython does not permit a menu to be incorporated directly into a toolbar.
@@ -1612,24 +1630,24 @@ def _init_toolbar(self):
1612
1630
1613
1631
self .SetToolBitmapSize (wx .Size (24 ,24 ))
1614
1632
1615
- self .AddSimpleTool (_NTB2_HOME , _load_bitmap ('home.xpm ' ),
1633
+ self .AddSimpleTool (_NTB2_HOME , _load_pngicon ('home.png ' ),
1616
1634
'Home' , 'Reset original view' )
1617
- self .AddSimpleTool (self ._NTB2_BACK , _load_bitmap ('back.xpm ' ),
1635
+ self .AddSimpleTool (self ._NTB2_BACK , _load_pngicon ('back.png ' ),
1618
1636
'Back' , 'Back navigation view' )
1619
- self .AddSimpleTool (self ._NTB2_FORWARD , _load_bitmap ('forward.xpm ' ),
1637
+ self .AddSimpleTool (self ._NTB2_FORWARD , _load_pngicon ('forward.png ' ),
1620
1638
'Forward' , 'Forward navigation view' )
1621
1639
# todo: get new bitmap
1622
- self .AddCheckTool (self ._NTB2_PAN , _load_bitmap ('move.xpm ' ),
1640
+ self .AddCheckTool (self ._NTB2_PAN , _load_pngicon ('move.png ' ),
1623
1641
shortHelp = 'Pan' ,
1624
1642
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 ' ),
1626
1644
shortHelp = 'Zoom' , longHelp = 'Zoom to rectangle' )
1627
1645
1628
1646
self .AddSeparator ()
1629
- self .AddSimpleTool (_NTB2_SUBPLOT , _load_bitmap ('subplots.xpm ' ),
1647
+ self .AddSimpleTool (_NTB2_SUBPLOT , _load_pngicon ('subplots.png ' ),
1630
1648
'Configure subplots' , 'Configure subplot parameters' )
1631
1649
1632
- self .AddSimpleTool (_NTB2_SAVE , _load_bitmap ('filesave.xpm ' ),
1650
+ self .AddSimpleTool (_NTB2_SAVE , _load_pngicon ('filesave.png ' ),
1633
1651
'Save' , 'Save plot contents to file' )
1634
1652
1635
1653
if wx .VERSION_STRING >= '2.5' :
0 commit comments