After many years I'm trying my hands at Tkinter again, and things have
changed... :-)

I'm using Python 2.7 here, but it doesn't look like 3.x changes the issue.
Tcl/Tk version is 8.5, on Mac OS (10.8).

I've got a situation where a background thread is doing I/O and wants to
wake up the Tk event loop. It seems the established wisdom (e.g.
http://code.activestate.com/recipes/82965-threads-tkinter-and-asynchronous-io/)
is to have the Tk event loop wake up every e.g. 100 msec and check a queue
or other state shared with the thread. This works, but makes me worry that
my app will be draining battery power even when no data from the bg thread
is forthcoming.

I've tried other things:

- createfilehandler: This says it cannot work when Tcl/Tk is threaded and
it will be removed in Python 3 anyway.

- The bg thread can use after_idle() or after() to run a command on the Tk
object; this works, but it doesn't seem to wake up the Tk main loop -- the
command usually only runs when I cause a UI event to be generated (e.g.
selecting the window).

What other solutions could I try? I really don't like the "after(100,
<repeat>)" solution.

-- 
--Guido van Rossum (python.org/~guido)
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to