[Tkinter-discuss] TkInter won't update display on OS X if delay is too small

Kevin Walzer kw at codebykevin.com
Sat Jan 12 16:58:27 CET 2013


On 1/12/13 10:46 AM, Leon Maurer wrote:
> Howdy,
>
> I'm running in to a problem where TkInter won't update the interface on
> OS X. I've filed a bug (http://bugs.python.org/issue16941), but it was
> suggested that I also send the message here, in case you have some
> thoughts about what to do -- either a fix or a workaround.
>
> Here's a small piece of code which has the problem:
>
> https://mywebspace.wisc.edu/lnmaurer/web/updatebug/bugtest.py
>
> The program is simple -- basically a big canvas with a some text in the
> middle that counts up.
>
> Here's a short quick-time movie showing the problem with that code:
>
> https://mywebspace.wisc.edu/lnmaurer/web/updatebug/updatebug.mov
>
> The screen-cast has three parts. First, it shows the program working as
> it should. Then, I add a simple background image to the canvas (a black
> rectangle), and the interface refuses to refresh at all; I get a
> spinning beach ball wheel (although the cursor appears as the usual
> black arrow in the screen-cast). Finally  I increase the delay between
> updates, and the interface again refreshes as it should.
>

You're running into a well-known and essentially unsolvable bug with Tk 
on OS X, essentially integration between the event loop of Tk and 
Cocoa's event loop. This is not a Tkinter issue, it's a Tk issue, and 
it's essentially impossible to fix: the event loops of Tk and Cocoa are 
very different and their integration is a fragile, leading at times to 
the kinds of screen freeze/lockups you see. Increasing the delay between 
events a bit, as you've done, is a recommended best practice, as it 
gives the event loop time to spin and process the event queue; so you've 
essentially already found the best solution for your problem.

I'm speaking here at the maintainer of Tk on the Mac; we've discussed 
these issues on the Tcl-Mac mailing list, the MacPython list, and here, 
and a lot of talented developers besides myself have looked at it. No 
one has been able to solve the issue, it's simply an inherent artifact 
that can only be worked around.

Thanks,
Kevin

----

Kevin Walzer
Code by Kevin
http://www.codebykevin.com


More information about the Tkinter-discuss mailing list