8000 input() caused _tkinter.TclError: invalid command name XXX after plot.close() · Issue #17104 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
input() caused _tkinter.TclError: invalid command name XXX after plot.close() #17104
Closed
@davidhcefx

Description

@davidhcefx

Bug report

Bug summary

By calling the built-in input() function after closing the plot within an animation object, I got a Tkinter exception.

Code for reproduction

import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig, ax = plt.subplots()
graph, = ax.plot([], [])
def update_plt(t):
	print(t)
	graph.axes.plot([1,2], [4, t])
	if t == 4:
		plt.close()
	return graph,

ani = animation.FuncAnimation(fig, update_plt, [r for r in range(10)],
							blit=False, interval=500, repeat=False)
plt.show()
x = input()  # <-- comment out, no exception.
print('Done.')

Actual outcome

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\davidhcefx\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "C:\Users\davidhcefx\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 804, in callit
    func(*args)
  File "C:\Users\davidhcefx\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backends\_backend_tk.py", line 270, in idle_draw
    self.draw()
  File "C:\Users\davidhcefx\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 10, in draw
    _backend_tk.blit(self._tkphoto, self.renderer._renderer, (0, 1, 2, 3))
  File "C:\Users\davidhcefx\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\backends\_backend_tk.py", line 76, in blit
    photoimage.blank()
  File "C:\Users\davidhcefx\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 4065, in blank
    self.tk.call(self.name, 'blank')
_tkinter.TclError: invalid command name "pyimage10"

Expected outcome

No exception regarding Tkinter been thrown.

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 3.2.1
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.8.2
  • Other libraries: -

I installed matplotlib via python -m pip install matplotlib.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0