Skip to content

Commit 1241d59

Browse files
committed
tk: Skip setting cursor if window is unavailable.
This is really optional, and fails in `Figure.savefig` if `plt.show()` is called before it.
1 parent ef0a308 commit 1241d59

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,12 @@ def release_zoom(self, event):
538538

539539
def set_cursor(self, cursor):
540540
window = self.canvas.get_tk_widget().master
541-
window.configure(cursor=cursord[cursor])
542-
window.update_idletasks()
541+
try:
542+
window.configure(cursor=cursord[cursor])
543+
except tkinter.TclError:
544+
pass
545+
else:
546+
window.update_idletasks()
543547

544548
def _Button(self, text, image_file, toggle, command):
545549
image = (tk.PhotoImage(master=self, file=image_file)

0 commit comments

Comments
 (0)