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 @@ -636,9 +636,15 @@ def _set_image_for_button(self, button):
636
636
if button ._image_file is None :
637
637
return
638
638
639
+ # Allow _image_file to be relative to Matplotlib's "images" data
640
+ # directory.
641
+ path_regular = cbook ._get_data_path ('images' , button ._image_file )
642
+ path_large = path_regular .with_name (
643
+ path_regular .name .replace ('.png' , '_large.png' ))
639
644
size = button .winfo_pixels ('18p' )
640
- with Image .open (button ._image_file .replace ('.png' , '_large.png' )
641
- if size > 24 else button ._image_file ) as im :
645
+ # Use the high-resolution (48x48 px) icon if it exists and is needed
646
+ with Image .open (path_large if (size > 24 and path_large .exists ())
647
+ else path_regular ) as im :
642
648
image = ImageTk .PhotoImage (im .resize ((size , size )), master = self )
643
649
button .configure (image = image , height = '18p' , width = '18p' )
644
650
button ._ntimage = image # Prevent garbage collection.
You can’t perform that action at this time.
0 commit comments