Am 11.08.16 um 06:38 schrieb Terry Reedy:
You might be able to glean something from the succession of files I
uploaded to
https://bugs.python.org/issue27546
Integrate tkinter and asyncio (and async)
I started with just mixing tk and asyncio callbacks. After some
struggle with similar question as you ask above, I ended up with more or
less callback free code using async def and async for. Once I got over
the hump, I rather like it.
Interesting discussion! Tcl itself acquired coroutines some years ago
(in 8.6) and people in this community are very excited with async based
programming.
I'm convinced that it is possible to integrate Tcl's event loop with
asyncio's loop without regular update polling. This might require a
patch to Tkinter at the C level. For example, an easy way is to put
Tcl/Tk in it's own thread. The Tcl event loop can be woken up from a
different thread by the TclThreadQueueEvent() and TclTheradAlert() API
calls. Basically, you would spawn a new thread (from the C level), when
loading Tkinter, which loads Tk and sits in a Tcl event loop ("vwait
forever"). tk.eval() and tk.call() would be redefined to post events
using the aforementioned functions. When a Tcl callback arrives, it
would send an event to asyncio in the main thread - no idea how this
works, though. In the end, it would also allow to use Tkinter from
different Python threads, because all calls would be rooted to the one
instance only.
Christian
--
https://mail.python.org/mailman/listinfo/python-list