

Concurrency in UI Toolkits - desdiv
http://www.guigarage.com/2015/01/concurrency-ui-toolkits-part-1/

======
bayesianhorse
One solution is to use generators in Python. The new Asyncio framework makes
it easier to think about concurrency in GUI applications, and it can be used
to cooperate with several GUI frameworks' event loops, like QT and Kivy, as
well as websockets and other contexts.

It's not immediately obvious how to "yield from start_button()", but the
solution is to have a FIFO command queue like in this article. The UI thread
pushes commands to this queue and then the coroutine can act on the command.

This also simplifies changing the exact meaning of buttons/keys like "back"
depending on the context, and handling multi-step network tasks, like using
external APIs, ssh commands to a server, file downloads and the like. Using a
command queue in Asyncio makes UI actions and IO events interchangeable.

------
desdiv
Part 2 here: [http://www.guigarage.com/2015/02/concurrency-ui-toolkits-
par...](http://www.guigarage.com/2015/02/concurrency-ui-toolkits-part-2/)

------
amelius
> Today every UI toolkit that is not running in a browser needs a UI Thread

This highlights why the idea of running a UI in the browser is actually
seriously broken.

~~~
statictype
Code running in the browser also has a UI thread that it needs to run on. Just
that until recently the UI thread was the _only_ thread you had access to.

