[Tkinter-discuss] Waking up the Tk event loop from a thread

Guido van Rossum guido at python.org
Thu Nov 7 01:39:16 CET 2013


Hi Kevin,

Thanks for the clarification.

Fortunately using event_generate() with a virtual event works like a charm
(unlike after() or after_idle()) so I am happy with the way things are now.
It has been quite frustrating though to get here. :-(

--Guido



On Wed, Nov 6, 2013 at 2:52 PM, Kevin Walzer <kw at codebykevin.com> wrote:

> Hello Guido,
>
>
> On 11/6/13, 5:02 PM, Guido van Rossum wrote:
>
>> Sadly, on Mac with Python 3 and Tcl/Tk 8.5 this exhibits exactly the
>> problem I am complaining about -- the updates are erratic and often need
>> to be helped along by moving the mouse or changing the focus.
>>
>
> You may be seeing an issue that's specific to recent versions of Tk on the
> Mac.
>
> In 2009, Apple sponsored a port of Tk from the Carbon API to the Cocoa API
> because they had deprecated Carbon. The Cocoa port has many advantages, not
> the least of which is better integration with various system API's, but it
> has drawbacks as well. Specifically, the event loop integration between Tk
> and Cocoa is complicated and fragile,  much more so than between Tk and
> Carbon (where the event loops were very similar and easy to integrate).
>
> This results in the kind of behavior you are seeing--sometimes there are
> issues with event loop updates, window redraw, etc., and sometimes event
> dispatching causes crashes.
>
> My predecessor as maintainer of Tk on the Mac, Daniel Steffen, is the
> author of the Cocoa port, but is now working for Apple and can't work on Tk
> anymore. The result is that many of the event loop bugs must remain
> unfixed--the code there is devilishly complex and, frankly, Daniel is the
> only one who really understands it. I'm not even persuaded that the
> impedance mismatch between the two event loops can be bridged, as Daniel
> already did quite a bit of bug fixing and refinement of the event loop
> stuff after the initial release of the Cocoa port.
>
> In most cases I'm left recommending various workarounds for the behavior,
> such as judicious use of update(),  update_idlestasks(), after(), and so
> on. Exercising the event loop by moving the mouse also helps in some
> instances.
>
> Hope that sheds some light on what you are seeing.
>
> --Kevin
>
> --
> Kevin Walzer
> Code by Kevin/Mobile Code by Kevin
> http://www.codebykevin.com
> http://www.wtmobilesoftware.com
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> https://mail.python.org/mailman/listinfo/tkinter-discuss
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20131106/f41b154d/attachment.html>


More information about the Tkinter-discuss mailing list