pythonuser-interfacetwistedtuiurwid

What Options Are There for a Python TUI Backend?


I need to build a python TUI for a project that I am working on. I do not need advice suggestion about the actual TUI libraries out there (like ncurses/npyscreen/Urwid/etc) as my team has already determined that they are too heavyweight for our needs. The TUI takes relatively simple text input and doesn't require all of the nice formatting and widgets. It also will only be accepting input from a single user at any time.

Since we are rolling our own display, that leaves the real question, which is are there options for libs out there that can help implement the event-handling/IO loop that I can reuse? I started the Internet search for GUI/TUI backends and quickly found myself in the Twisted/Tornado/Gevent world, which I am also not sure is the proper avenue to run down. Are these libraries, or possibly Urwid able to let me easy slip in my own display code (to render screens and take simple raw_input() style data)?

This will only be run in a Python 2.7, Linux environment, but if it works on a Mac, that will be a big plus.


Solution

  • Twisted has a framework called "Insults" which is sort of its version of Curses.

    This framework is still quite rough around the edges, but it will probably stay that way unless someone takes the plunge and starts using it / filing bugs, etc. You can see how Imaginary sets up an async text UI (input line and separate output area so output doesn't interrupt your typing) here.