@@ -670,30 +670,41 @@ def __init__(self, canvas, parent, coordinates=True):
670
670
QtWidgets .QToolBar .__init__ (self , parent )
671
671
NavigationToolbar2 .__init__ (self , canvas )
672
672
673
- def _icon (self , name ):
673
+ def _icon (self , name , color = None ):
674
674
if is_pyqt5 ():
675
675
name = name .replace ('.png' , '_large.png' )
676
676
pm = QtGui .QPixmap (os .path .join (self .basedir , name ))
677
677
if hasattr (pm , 'setDevicePixelRatio' ):
678
678
pm .setDevicePixelRatio (self .canvas ._dpi_ratio )
679
+ if color is not None :
680
+ mask = pm .createMaskFromColor (QtGui .QColor ('black' ),
681
+ QtCore .Qt .MaskOutColor )
682
+ pm .fill (color )
683
+ pm .setMask (mask )
679
684
return QtGui .QIcon (pm )
680
685
681
686
def _init_toolbar (self ):
682
687
self .basedir = str (cbook ._get_data_path ('images' ))
683
688
689
+ background_color = self .palette ().color (self .backgroundRole ())
690
+ foreground_color = self .palette ().color (self .foregroundRole ())
691
+ icon_color = (foreground_color
692
+ if background_color .value () < 128 else None )
693
+
684
694
for text , tooltip_text , image_file , callback in self .toolitems :
685
695
if text is None :
686
696
self .addSeparator ()
687
697
else :
688
- a = self .addAction (self ._icon (image_file + '.png' ),
698
+ a = self .addAction (self ._icon (image_file + '.png' , icon_color ),
689
699
text , getattr (self , callback ))
690
700
self ._actions [callback ] = a
691
701
if callback in ['zoom' , 'pan' ]:
692
702
a .setCheckable (True )
693
703
if tooltip_text is not None :
694
704
a .setToolTip (tooltip_text )
695
705
if text == 'Subplots' :
696
- a = self .addAction (self ._icon ("qt4_editor_options.png" ),
706
+ a = self .addAction (self ._icon ("qt4_editor_options.png" ,
707
+ icon_color ),
697
708
'Customize' , self .edit_parameters )
698
709
a .setToolTip ('Edit axis, curve and image parameters' )
699
710
0 commit comments