pythoncursestuiurwid

Python TUI libs


I'm writing a small sudoku game/solver in Linux using python with TUI (not GUI, that's just lame) just for fun. My question is, which lib is better (by that I mean easier to handle, better support, more straight-forward and understandable), the choices are curses or urwid or if anyone have better suggention, and why? I have some Tkinter and wxPython experiences.

Any help or information will be appreciated.


Solution

  • You might want to check out Unicurses, which wraps the python core curses module in UNIX systems and wraps the free pdcurses library on windows-based machines.

    This library is designed to emulate the syntax and style of the original ncurses library, so if you're interested in learning TUI design using curses-style programming, then check it out.

    Urwid is, from what little documentation I've read, a very interesting library which uses event loops (the reactor pattern) as a basis for application design, much like tkinter or Twisted. Also, urwid has an event loop class specifically designed for use with Twisted, so if your aim is to created TUIs for use over networks, its a good choice. Twisted also uses the reactor pattern, so if you want to learn that style, I'd recommend it.

    Finally, if you do go with an ncurses-style library, check out Dan Gookin's book on ncurses. A very good resource, and the only one I know of which is in print today.

    There are other options such as newt, pygcurses, and so on, but this should get you started. Best of luck, TUI programming today is one of those technological fetishes that can be hard to break into, but it's rewarding.