Skip to content

Commit 1706dd3

Browse files
pelsonpelson
authored and
pelson
committed
Added a try/except to the tk icon setting.
1 parent c156ce3 commit 1706dd3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/matplotlib/backends/backend_tkagg.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,15 @@ def new_figure_manager(num, *args, **kwargs):
8686
# http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html
8787
icon_fname = os.path.join(rcParams['datapath'], 'images', 'matplotlib.gif')
8888
icon_img = Tk.PhotoImage(file=icon_fname)
89-
window.tk.call('wm', 'iconphoto', window._w, icon_img)
90-
89+
try:
90+
window.tk.call('wm', 'iconphoto', window._w, icon_img)
91+
except (SystemExit, KeyboardInterrupt):
92+
# re-raise exit type Exceptions
93+
raise
94+
except:
95+
# log the failure, but carry on
96+
verbose.report('Could not load matplotlib icon: %s' % sys.exc_info()[1])
97+
9198
canvas = FigureCanvasTkAgg(figure, master=window)
9299
figManager = FigureManagerTkAgg(canvas, num, window)
93100
if matplotlib.is_interactive():

0 commit comments

Comments
 (0)