FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix app icon bug on Windows when running IPython by ayshih · Pull Request #32360 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
38 changes: 21 additions & 17 deletions lib/matplotlib/backends/_backend_tk.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -546,23 +546,6 @@ def create_with_canvas(cls, canvas_class, figure, num):
window = tk.Tk(className="matplotlib")
window.withdraw()

# Put a Matplotlib icon on the window rather than the default tk
# icon. See https://www.tcl.tk/man/tcl/TkCmd/wm.html#M50
#
# `ImageTk` can be replaced with `tk` whenever the minimum
# supported Tk version is increased to 8.6, as Tk 8.6+ natively
# supports PNG images.
icon_fname = str(cbook._get_data_path(
'images/matplotlib_small.png'))
icon_img = ImageTk.PhotoImage(file=icon_fname, master=window)

icon_fname_large = str(cbook._get_data_path(
'images/matplotlib.png'))
icon_img_large = ImageTk.PhotoImage(
file=icon_fname_large, master=window)

window.iconphoto(False, icon_img_large, icon_img)

canvas = canvas_class(figure, master=window)
manager = cls(canvas, num, window)
if mpl.is_interactive():
Expand Down Expand Up @@ -612,6 +595,27 @@ def destroy(*args):
Gcf.destroy(self)
self.window.protocol("WM_DELETE_WINDOW", destroy)
self.window.deiconify()

# Put a Matplotlib icon on the window rather than the default tk
# icon. See https://www.tcl.tk/man/tcl/TkCmd/wm.html#M50
#
# The icon is set after calling deiconify() to avoid a bug when
# running IPython on Windows.
#
# `ImageTk` can be replaced with `tk` whenever the minimum
# supported Tk version is increased to 8.6, as Tk 8.6+ natively
# supports PNG images.
Comment thread
iccir marked this conversation as resolved.
icon_fname = str(cbook._get_data_path(
'images/matplotlib_small.png'))
icon_img = ImageTk.PhotoImage(file=icon_fname, master=self.window)

icon_fname_large = str(cbook._get_data_path(
'images/matplotlib.png'))
icon_img_large = ImageTk.PhotoImage(
file=icon_fname_large, master=self.window)

self.window.iconphoto(False, icon_img_large, icon_img)

self.canvas._tkcanvas.focus_set()
else:
self.canvas.draw_idle()
Expand Down
Loading

Back | FazBrowse Home | New Git URL