8000 Merge pull request #18889 from QuLogic/tk-png · matplotlib/matplotlib@07145c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 07145c2

Browse files
authored
Merge pull request #18889 from QuLogic/tk-png
Switch Tk to using PNG files for buttons
2 parents b6c43c4 + 959a7bc commit 07145c2

20 files changed

+6
-4
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def __init__(self, canvas, window, *, pack_toolbar=True):
502502
else:
503503
self._buttons[text] = button = self._Button(
504504
text,
505-
str(cbook._get_data_path(f"images/{image_file}.gif")),
505+
str(cbook._get_data_path(f"images/{image_file}.png")),
506506
toggle=callback in ["zoom", "pan"],
507507
command=getattr(self, callback),
508508
)
@@ -567,7 +567,11 @@ def set_cursor(self, cursor):
567567
pass
568568

569569
def _Button(self, text, image_file, toggle, command):
570-
image = (tk.PhotoImage(master=self, file=image_file)
570+
if tk.TkVersion >= 8.6:
571+
PhotoImage = tk.PhotoImage
572+
else:
573+
from PIL.ImageTk import PhotoImage
574+
image = (PhotoImage(master=self, file=image_file)
571575
if image_file is not None else None)
572576
if not toggle:
573577
b = tk.Button(master=self, text=text, image=image, command=command)
@@ -718,8 +722,6 @@ def set_cursor(self, cursor):
718722

719723

720724
class ToolbarTk(ToolContainerBase, tk.Frame):
721-
_icon_extension = '.gif'
722-
723725
def __init__(self, toolmanager, window):
724726
ToolContainerBase.__init__(self, toolmanager)
725727
xmin, xmax = self.toolmanager.canvas.figure.bbox.intervalx
-608 Bytes
Binary file not shown.
-799 Bytes
Binary file not shown.
-723 Bytes
Binary file not shown.
-1.46 KB
Binary file not shown.
-590 Bytes
Binary file not shown.
-786 Bytes
Binary file not shown.
-1.24 KB
Binary file not shown.
-973 Bytes
Binary file not shown.
-564 Bytes
Binary file not shown.
-1.7 KB
Binary file not shown.
-6.76 KB
Binary file not shown.
-666 Bytes
Binary file not shown.
-1.39 KB
Binary file not shown.
-679 Bytes
Binary file not shown.
-951 Bytes
Binary file not shown.
-691 Bytes
Binary file not shown.
-1.32 KB
Binary file not shown.
-696 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)
0