Home > OS >  Why am I receiving a tkinter.TclError when trying to get the content of a text widget?
Why am I receiving a tkinter.TclError when trying to get the content of a text widget?

Time:06-23

I'm trying to get the input from a tkinter text widget, but it is coming up with the error:

_tkinter.TclError: invalid command name ".!text"

Here is where I define the textbox: textbox = tkinter.Text(main_root)

And this is how I call the get() function: textbox.get("1.0", "end-1c")

Anyone got any ideas what is going on? Usually this works fine.

CodePudding user response:

I was calling textbox.destroy() before calling the get() function. This is what caused the error to be raised.

  • Related