The Living Thing / Notebooks :

UIs in Python

interacting with an app, a python app, without too much dicking about

Stream processing in python, especially for UIs.

GUIs in python are a mess.

IO loop evented asynchrony

Modern python async-style stuff.

tl;dr Use the event loop from tornado or pyzmq. These non-thread IO things are very easy and comparatively well-documented. And they work with the new python 3 async style. You can use them to farm off heavy computation to other threaded nightmare hell farms or whatever, and they work now.

Here are some ingredients that might make these work better:

Web toolkits talking to python servers

One obvious usecase for all this evented stuff is to use the great mind-share of our time, web engines talking to servers, to do UI stuff.

Thrust renders a chromium window to look at your served code. I’m not 100% clear how it it easier than just running a browser and a server.

brython interprets python using javascript.

There are many examples of rolling your own, using a classic webserver, or electron. Your adventure continues at javascript apps

GUI toolkits using threads


tkinter is well-worn and sturdy dating back to the 90s. It’s a wrapper around the tcl gui toolkit, called tk. If you want to make something simple, it’s not too bad.

It can integrate with tornado.

Beware of the many renames between python 2 and 3.

Cute examples

It looks primitive, but you can get a long way.

  1. dynamic collapsible content:
def toggle(self):
      if bool(
          self.sub_frame.pack(fill="x", expand=1)
  1. snake, including sprites and canvas with collision detection.



  • For sorta-native look and feel you use ttk which introduces styles and themes. Neither of these are obvious.
  • Control variables provide convenient data-syncing accessors for what I will loosely call “scalar types”. Think of them as primitive controllers.
  • There are two layout managers, pack and grid. If you come from an HTML background the former is somewhat like a mildly crippled version of block-layout and the latter somewhat more like HTML tables. You can’t mix them within a single parent widget, but you can freely next Frame widgets with different interior layouts.


cefpython embeds a chrome webview in python; it also supports bidirectional IPC between python and javascript. Its concurrency constructs look… idiosyncratic.


Want a somewhat more modern look, and modern conveniences. Qt5 is, by all accounts, pretty good. The dman language bindings keep changing though, and betwixt qt5 and qt4 lies a chasm which many projects have failed to cross. For QT directly apparently one should use pyotherside? Although I now see people using qtpy as a unifying abstraction layer over all the other unifying abstraction layers. Maybe if I do that the pain will go away.

To ease this pain and make everything even easier, perhaps one should use one of the mildly hip meta-frameworks, such as enaml, which handles asynchronous widget binding and such, and enaml-native, whcih attempts to create mobile-friendly react-native-esque applications.


Hip, multitouch, GPU-friendly, mobile-friendly (and a little bit retro in the design style if not the technologies) kivy, a complete app environment.

Bizarre crossovers of Web GUIs and user interfaces

DIY python web gui by David Baird:

In this howto, I explain the following concepts:

  1. How to launch a GUI toolkit in a separate thread, and how to communicate with this thread.
  2. How to embed a web browser inside the GUI, and how to communicate with this embedded web browser without using sockets. By not using sockets, we don’t have to worry about socket security, and we don’t have to worry about allocating a socket. […] In other words, we will have AJAX-like […] functionality to communicate with Python but without actually having to use AJAX.