Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter.TclError
#1
I have been trying to learn python and are using some lessons with small coding exercises. Lately I have gotten this error no matter which program I am using. It refers to lines so far ahead of my 15 to 20 line code examples. How can I stop this error from occurring? Any help would be greatly appreciated.

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 2341, in destroy
self.tk.call('destroy', self._w)
_tkinter.TclError: can't invoke "destroy" command: application has been destroyed
Reply
#2
Post some code What you want to destroy obviously doesn't exist
Reply
#3
These are lines in the tkinter library, not in your program. There is something wrong with you program, but it doesn't result in an unrecoverable error until later. This is very common, so you need to learn how to trace the error back to where it occurred in you code.

You should post your program and the entire error trace.
Reply
#4
That is the problem. I have been doing "lessons" that I retype the code for from the lesson. This error started 15 or 20 lessons ago. I am now on a totally different lesson which does NOT have any tkinter reference. So if I just start a NEW program and say something as simple as print("Hello") I STILL get that error although it will let the print statement execute but then the terminal locks up until I tell it to "run" as a new terminal.
I cannot continue to follow the lessons as this error continues to show up.
Thanks for your reply.

david
Reply
#5
Just tried it again and it seems that everything is back to normal. So I guess the last time I tried to get the program to work it was somehow still in my computers memory. Today when I tried to run a simple line of code, it DID run without the error. Sorry to have bothered you with this mess.
I realized when I saw the code with the reference to lines outside of the lines in the program I was trying to run that it was probably referencing tkinkter.
Again, thank you for your quick reply and for your help.

david
Reply
#6
My take from your post was that you had the same error running any program, but I incorrectly assumed a common theme (and common error) among the programs you were running. So this is a problem with VSCode not running the code in the editor.

Are you using the Run Code option? The Run button can be configured to Run Code, Run Python File, and Debug Python File. The Run Code option is meant to run selected code. If there is no selection, it appears to run some previous selection associated with the file.

Instead of Run Code, use Run Python File to fix the problem.
Reply
#7
I have been using Visual Studio to run the code. There is a Run button as well as a Run in the Menu that includes Run Without Debugging which I had used to get the "bad" code to run before. I am 80 years old and have been trying to learn Python as it looks like fun. Sorry if I sent confusing info as this is new to me. Thanks again for your help as things now seem to be working again so I will take the win and continue.

david
Reply
#8
Visual Studio Code (VSCode) is a much better tool for Python than Visual Studio.
Reply
#9
My mistake, I am using Visual Studio Code, not Visual Studio. I find it really nice as an environment.

david
Reply
#10
(Jun-12-2023, 07:34 PM)foxxrunning Wrote: My mistake, I am using Visual Studio Code, not Visual Studio. I find it really nice as an environment. geometry dash bloodbath

david
I used to use Visual Studio Code and get the same issue. Cry Cry Cry
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug tkinter.TclError: bad window path name "!button" V1ber 2 832 Aug-14-2023, 02:46 PM
Last Post: V1ber

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020