Skip to content

Switch Tk to using PNG files for buttons #18889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def __init__(self, canvas, window, *, pack_toolbar=True):
else:
self._buttons[text] = button = self._Button(
text,
str(cbook._get_data_path(f"images/{image_file}.gif")),
str(cbook._get_data_path(f"images/{image_file}.png")),
toggle=callback in ["zoom", "pan"],
command=getattr(self, callback),
)
Expand Down Expand Up @@ -567,7 +567,11 @@ def set_cursor(self, cursor):
pass

def _Button(self, text, image_file, toggle, command):
image = (tk.PhotoImage(master=self, file=image_file)
if tk.TkVersion >= 8.6:
PhotoImage = tk.PhotoImage
else:
from PIL.ImageTk import PhotoImage
image = (PhotoImage(master=self, file=image_file)
if image_file is not None else None)
if not toggle:
b = tk.Button(master=self, text=text, image=image, command=command)
Expand Down Expand Up @@ -718,8 +722,6 @@ def set_cursor(self, cursor):


class ToolbarTk(ToolContainerBase, tk.Frame):
_icon_extension = '.gif'

def __init__(self, toolmanager, window):
ToolContainerBase.__init__(self, toolmanager)
xmin, xmax = self.toolmanager.canvas.figure.bbox.intervalx
Expand Down
Binary file removed lib/matplotlib/mpl-data/images/back.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/back_large.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/filesave.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/filesave_large.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/forward.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/forward_large.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/hand.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/hand_large.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/help.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/help.ppm
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/help_large.ppm
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/home.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/home_large.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/move.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/move_large.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/subplots.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/subplots_large.gif
Binary file not shown.
Binary file removed lib/matplotlib/mpl-data/images/zoom_to_rect.gif
Binary file not shown.
Binary file not shown.