@@ -670,30 +670,41 @@ def __init__(self, canvas, parent, coordinates=True):
670670 QtWidgets .QToolBar .__init__ (self , parent )
671671 NavigationToolbar2 .__init__ (self , canvas )
672672
673- def _icon (self , name ):
673+ def _icon (self , name , color = None ):
674674 if is_pyqt5 ():
675675 name = name .replace ('.png' , '_large.png' )
676676 pm = QtGui .QPixmap (os .path .join (self .basedir , name ))
677677 if hasattr (pm , 'setDevicePixelRatio' ):
678678 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 )
679684 return QtGui .QIcon (pm )
680685
681686 def _init_toolbar (self ):
682687 self .basedir = str (cbook ._get_data_path ('images' ))
683688
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+
684694 for text , tooltip_text , image_file , callback in self .toolitems :
685695 if text is None :
686696 self .addSeparator ()
687697 else :
688- a = self .addAction (self ._icon (image_file + '.png' ),
698+ a = self .addAction (self ._icon (image_file + '.png' , icon_color ),
689699 text , getattr (self , callback ))
690700 self ._actions [callback ] = a
691701 if callback in ['zoom' , 'pan' ]:
692702 a .setCheckable (True )
693703 if tooltip_text is not None :
694704 a .setToolTip (tooltip_text )
695705 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 ),
697708 'Customize' , self .edit_parameters )
698709 a .setToolTip ('Edit axis, curve and image parameters' )
699710
0 commit comments