Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fluentpython/asyncio-tkinter

Example of running asyncio on top of the Tcl/Tk event loop via Tkinter
https://github.com/fluentpython/asyncio-tkinter

Last synced: 3 days ago
JSON representation

Example of running asyncio on top of the Tcl/Tk event loop via Tkinter

Awesome Lists containing this project

README

        

==========================
Using asyncio with Tkinter
==========================

The ``tkapp.py`` and ``tkapp2.py`` examples in this folder demonstrate:

- using an alternative ``asyncio.BaseEventLoop`` subclass on top of the Tkinter event loop;
- leveraging futures and ``yield from`` to escape *callback hell*;
- applying the ``asyncio`` abstractions to GUI programming instead of network programming.

History
=======

The code is adapted from Dino Viehland's (@DinoV) talk `Using futures for async GUI programming in Python 3.3 `_ presented at PyCon US 2013. Dino's example used Tulip because the first release of ``asyncio`` was not available then; some APIs changed later and the ``tkapp.py`` was not working with Python 3.4 and ``asyncio`` from the standard library.

Luciano Ramalho (@ramalho) updated this code to run with Python 3.4 with help and encouragement from Guido van Rossum (@gvanrossum). See relevant thread in the `python-tulip `_ group.

Ramalho also wrote the ``tkapp2.py`` which makes it easier to run the three demonstrations from Viehland's talk: sequential processing, asynchronous with callbacks and asynchronous with coroutines.

Alan Cristhian (@AlanCristhian) fixed the hang-on-exit bug by turning the ``asyncio`` event loop thread into a daemon; see ``guievents.py``, method ``GuiEventLoop._start_io_event_loop``.