1

I've made a program that resembles MS Paint in that you can create a painting with various colors and line widths, as well as saving and loading files. Every so often I will be using the program and I will encounter an issue when the terminal repeatedly spits out an error reading:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python37-32\lib\tkinter\__init__.py", line 332, in __del__
    if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
RuntimeError: main thread is not in main loop
Exception ignored in: <function Variable.__del__ at 0x0D7CF4F8>

This spits out roughly every half second for 10 seconds until the pygame window suddenly closes and I get one final error reading "Tcl_AsyncDelete: async handler deleted by the wrong thread".

I suspect this is something to do with PySimpleGui due to the repeating error being a tkinter Traceback (PySimpleGui is built upon tkinter), but other than that I have no idea what part of the program could be causing the issue.

I would show some code here, but I can't pinpoint a specific spot to show. If anyone has any suggestions I will by all means use their advice to look for a spot to show - The errors occur when no GUI window is open - Just the base pygame window used for drawing.

If anyone has any advice as to how to fix this or where to look for further help, it would be very much appreciated.

Thanks in advance!

  • 1
    error shows something about `threads`. Most GUI frameworks don't like threads and you can't create window/widgets in one thread and change its content in other threads. – furas Oct 12 '19 at 08:38
  • 1
    Sounds like it might be the same problem as outlined in [this StackOverflow answer](https://stackoverflow.com/a/14695007/5287638). – Jack Taylor Oct 12 '19 at 08:42
  • A fix is on the way.... In the meantime, if the only PySimpleGUI windows you are using are those under your complete control (i.e. you are not using popups, etc), then right after you close your window, also delete the window object. If your variable name is `window`, then do a `window.close()` followed by `del window` – Mike from PSG Oct 20 '19 at 17:02
  • @MikeyB Thank you! I'll be see to do that! – PhysicsLover999 Oct 20 '19 at 17:49
  • Please come back and post how it goes!!! – Mike from PSG Oct 20 '19 at 18:29
  • @MikeyB That seems to work - The error wasn't caused by anything specific before so I can't be sure, but I have tried it out multiple times with no issues. Thanks!! :) – PhysicsLover999 Oct 20 '19 at 20:07

1 Answers1

1

You can use del to delete a window after closing it:

#Open window, display, etc.
window.close()
del window

This should solve the issue.