Код: Выделить всё
import tkinter as tk
root = tk.Tk()
text = tk.Text()
text.insert(1.0, "foo")
text.pack()
text.bind("", lambda _: print(text.get(1.0, tk.END)))
# text.bind("", lambda _: print(text.winfo_exists())) # returns 0
root.mainloop()
Код: Выделить всё
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\jsh\miniconda3\Lib\tkinter\__init__.py", line 2068, in __call__
return self.func(*args)
~~~~~~~~~^^^^^^^
File "", line 6, in
text.bind("", lambda _: print(text.get(1.0, tk.END)))
~~~~~~~~^^^^^^^^^^^^^
File "C:\Users\jsh\miniconda3\Lib\tkinter\__init__.py", line 3935, in get
return self.tk.call(self._w, 'get', index1, index2)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: invalid command name ".!text"
Подробнее здесь: https://stackoverflow.com/questions/798 ... -destroyed