Re: [Tkinter-discuss] The Async delete problem....
Aha! Greg, you've given me the clue I needed. I never thought to look into how to trigger a garbage collect. I assumed (incorrectly) that it was something hidden away from users and that I couldn't do anything about it. Researching more, I see that I can indeed trigger a garbage collect myself, etc. Thank you for looking at this and coming to the same conclusion that I have about the garbage collect causing the crashes. Wow, I really appreciate this. I've spent weeks/months on this problem off and on. -mike -Original Message- From: Tkinter-discuss On Behalf Of Greg Ewing Sent: Sunday, December 15, 2019 5:39 PM To: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] The Async delete problem On 16/12/19 11:18 am, Mike Barnett wrote: > There are no tkinter calls made from any thread other than the main thread. It looks like some tkinter objects are becoming part of garbage cycles, and getting collected by whatever thread happens to be running when the cyclic gc kicks in. Seems to me this is fundamentally tk's fault for assuming that __del__ methods will be called from any particular thread. As a workaround, maybe you could manually trigger a gc whenever you dispose of a widget. -- Greg ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftkinter-discuss&data=02%7C01%7C%7Cceb5540d0dbd43ea8f0208d781afad89%7C84df9e7fe9f640afb435%7C1%7C0%7C637120463832895147&sdata=b8%2BnDr1VkUzIBS5ut1e4fg%2FeUhUDx%2BkNeE6f56370%2FQ%3D&reserved=0 ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss
Re: [Tkinter-discuss] The Async delete problem....
I've been trying to figure out how to trigger the garbage collect. Do you have any clues Greg? This is EXACTLY what's happening. -Original Message- From: Tkinter-discuss On Behalf Of Greg Ewing Sent: Sunday, December 15, 2019 5:39 PM To: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] The Async delete problem On 16/12/19 11:18 am, Mike Barnett wrote: > There are no tkinter calls made from any thread other than the main thread. It looks like some tkinter objects are becoming part of garbage cycles, and getting collected by whatever thread happens to be running when the cyclic gc kicks in. Seems to me this is fundamentally tk's fault for assuming that __del__ methods will be called from any particular thread. As a workaround, maybe you could manually trigger a gc whenever you dispose of a widget. -- Greg ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftkinter-discuss&data=02%7C01%7C%7Cceb5540d0dbd43ea8f0208d781afad89%7C84df9e7fe9f640afb435%7C1%7C0%7C637120463832895147&sdata=b8%2BnDr1VkUzIBS5ut1e4fg%2FeUhUDx%2BkNeE6f56370%2FQ%3D&reserved=0 ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss
Re: [Tkinter-discuss] The Async delete problem....
That's how it looks but I can assure you that the thread are not running the mainloop. There are no tkinter calls made from any thread other than the main thread. -Original Message- From: Tkinter-discuss On Behalf Of Michael Lange Sent: Sunday, December 15, 2019 5:16 PM To: tkinter-discuss@python.org Subject: Re: [Tkinter-discuss] The Async delete problem Hi, On Sun, 15 Dec 2019 18:29:18 + Mike Barnett 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: 0x016CA840C9D0> > > 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://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftkinter-discuss&data=02%7C01%7C%7C1b1a8693fa62493a417108d781ac6023%7C84df9e7fe9f640afb435%7C1%7C0%7C637120449647261354&sdata=Rui1yhlJkmvxrA2xz9MtgdJG5zIJbHb8VjwQjqHKD6k%3D&reserved=0 ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss
[Tkinter-discuss] The Async delete problem....
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: 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 Exception ignored in: 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 Exception ignored in: 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 Exception ignored in: Traceback (most recent call last): File "X:\Python\python3.8\lib\tkinter\__init__.py", line 4014, in __del__ self.tk.call('image', 'delete', self.name) RuntimeError: main thread is not in main loop Tcl_AsyncDelete: async handler deleted by the wrong thread 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? Thank you -mike ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss
Re: [Tkinter-discuss] Lines around Tk Widgets on Linux but not Windows
I figured it out! Just took more digging. I could swear I've set highlightthickness=0 before, but evidently not because that fixed it. From: Mike Barnett Sent: Saturday, December 14, 2019 1:27 PM To: Python-Tkinter Subject: Lines around Tk Widgets on Linux but not Windows I've had this problem for a very long time and have not been able to fix it regardless of what I've tried. My tk widgets all have a white border, despite setting the border width to zero. I don't have this problem on the Scale widget and on ttk widgets. The buttons you see along the bottom of the attached screenshot are TK Buttons except for one of them which is a TTK Button. The ttk one doesn't have a border. Any clues as to what I need to configure to remove these? They show up on Linux (including the Pi) and online on Trinket. Thank you for any kind of clues at all for me to investigate! -mike ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss
Re: [Tkinter-discuss] ttk styles - is it possible to have one per widget?
Hmmm... I didn't see am email go out for this. Did anyone get this email? From: Mike Barnett Sent: Wednesday, November 20, 2019 9:37 PM To: Python-Tkinter Subject: ttk styles - is it possible to have one per widget? I have come back to this problem several times and have asked friends for help, but I never seem to crack this nut. What I am trying to do is "style" ttk widgets in a way that each one can have their own unique settings. I've not found code or pseudo-code that does what I'm looking for. Is it possible for ttk widgets to work like tk widgets in that each can have their own unique settings like background color, text color, etc? Any code or pointers to pages with some code that I can lift would be awesome as I can't seem to write my own that works. Happy to share the kinds of things I've tried if it would help. Thank you for your time -mike ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss
[Tkinter-discuss] ttk styles - is it possible to have one per widget?
I have come back to this problem several times and have asked friends for help, but I never seem to crack this nut. What I am trying to do is "style" ttk widgets in a way that each one can have their own unique settings. I've not found code or pseudo-code that does what I'm looking for. Is it possible for ttk widgets to work like tk widgets in that each can have their own unique settings like background color, text color, etc? Any code or pointers to pages with some code that I can lift would be awesome as I can't seem to write my own that works. Happy to share the kinds of things I've tried if it would help. Thank you for your time -mike ___ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss