Hi, On Sun, 15 Dec 2019 18:29:18 +0000 Mike Barnett <mike_barn...@hotmail.com> wrote:
> I've been fighting this error for a couple of years now and just when I > think I've got it understood and "Fixed", it bites me again. > > > > Here's the error: > > > > Exception ignored in: <function Variable.__del__ at 0x0000016CA840C9D0> > > Traceback (most recent call last): > > File "X:\Python\python3.8\lib\tkinter\__init__.py", line 351, in > __del__ > > if self._tk.getboolean(self._tk.call("info", "exists", self._name)): > > RuntimeError: main thread is not in main loop (...) > It happens in programs that are multi-threaded. The threads do NOT > make any tkinter calls and do not touch any variable that has anything > to do with tkinter. > > What appears to be happening is that tkinter objects are marked to be > deleted and then when Python's garbage collect runs and actually does > the deletes, it is happening in the context of the thread, not the main > thread. > > My way around this at the moment is to keep the widgets around for the > duration of the program rather than deleting them in any way. I would > really like to get this solved though as other people using my code run > into this and don't know what to do. > > Any ideas on how to dispose of widgets / windows in a way that > immediately calls these delete methods? Or is it possible to tell > tkinter that despite the deletes being called from another thread it's > OK because the thread isn't actually changing anything at the same time > as the main thread? > I am not sure what is happening here. It sounds a bit as if the tk gui is not in the main program thread? If yes, maybe this causes the problem; as far as I know it is imperative that the tk mainloop is inside the main program thread. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. We're all sorry for the other guy when he loses his job to a machine. But when it comes to your job -- that's different. And it always will be different. -- McCoy, "The Ultimate Computer", stardate 4729.4 _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss