Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2e5011

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 4f95512 commit c2e5011

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
@@ -541,8 +541,12 @@ def release_zoom(self, event):
541541

542542
def set_cursor(self, cursor):
543543
window = self.canvas.get_tk_widget().master
544-
window.configure(cursor=cursord[cursor])
545-
window.update_idletasks()
544+
try:
545+
window.configure(cursor=cursord[cursor])
546+
except tkinter.TclError:
547+
pass
548+
else:
549+
window.update_idletasks()
546550

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

0 commit comments

Comments
 (0)