File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -643,9 +643,15 @@ def _set_image_for_button(self, button):
643
643
if button ._image_file is None :
644
644
return
645
645
646
+ # Allow _image_file to be relative to Matplotlib's "images" data
647
+ # directory.
648
+ path_regular = cbook ._get_data_path ('images' , button ._image_file )
649
+ path_large = path_regular .with_name (
650
+ path_regular .name .replace ('.png' , '_large.png' ))
646
651
size = button .winfo_pixels ('18p' )
647
- with Image .open (button ._image_file .replace ('.png' , '_large.png' )
648
- if size > 24 else button ._image_file ) as im :
652
+ # Use the high-resolution (48x48 px) icon if it exists and is needed
653
+ with Image .open (path_large if (size > 24 and path_large .exists ())
654
+ else path_regular ) as im :
649
655
image = ImageTk .PhotoImage (im .resize ((size , size )), master = self )
650
656
button .configure (image = image , height = '18p' , width = '18p' )
651
657
button ._ntimage = image # Prevent garbage collection.
You can’t perform that action at this time.
0 commit comments