File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -1058,8 +1058,21 @@ def _icon(name):
1058
1058
*name*, including the extension and relative to Matplotlib's "images"
1059
1059
data directory.
1060
1060
"""
1061
- return wx .BitmapBundle .FromSVGFile (str (cbook ._get_data_path ("images" , name )),
1062
- wx .ArtProvider ().GetDIPSizeHint (wx .ART_TOOLBAR ))
1061
+ svg = cbook ._get_data_path ("images" , name ).read_bytes ()
1062
+ try :
1063
+ dark = wx .SystemSettings .GetAppearance ().IsDark ()
1064
+ except AttributeError : # wxpython < 4.1
1065
+ # copied from wx's IsUsingDarkBackground / GetLuminance.
1066
+ bg = wx .SystemSettings .GetColour (wx .SYS_COLOUR_WINDOW )
1067
+ fg = wx .SystemSettings .GetColour (wx .SYS_COLOUR_WINDOWTEXT )
1068
+ # See wx.Colour.GetLuminance.
1069
+ bg_lum = (.299 * bg .red + .587 * bg .green + .114 * bg .blue ) / 255
1070
+ fg_lum = (.299 * fg .red + .587 * fg .green + .114 * fg .blue ) / 255
1071
+ dark = fg_lum - bg_lum > .2
1072
+ if dark :
1073
+ svg = svg .replace (b'style="fill:black;"' , b'style="fill:white;"' )
1074
+ toolbarIconSize = wx .ArtProvider ().GetDIPSizeHint (wx .ART_TOOLBAR )
1075
+ return wx .BitmapBundle .FromSVG (svg , toolbarIconSize )
1063
1076
1064
1077
def _update_buttons_checked (self ):
1065
1078
if "Pan" in self .wx_ids :
You can’t perform that action at this time.
0 commit comments