Python TUI libs

I am writing a little sudoku game / solver on Linux using python with TUI (and not a GUI that is just lame) just for fun. My question is, is lib better (I mean, it's easier to handle, better to maintain, more straightforward and straightforward), choosing curses or urwid , or if someone has a better guess and why? I have experience with Tkinter and wxPython.

Any help or information would be appreciated.

+8
python curses tui urwid
source share
3 answers

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

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

Urwid is a small documentation that I read, a very interesting library that uses event loops ( reactor template ) as the basis for developing an application like tkinter or Twisted. In addition, urwid has an event loop class specifically designed for use with Twisted, so if your goal is to create TUIs for use over networks, this is a good choice. Twisted also uses a reactor template, so if you want to know this style, I would recommend it.

Finally, if you are coming with an ncurses -style library, check out Dan Gukin ’s book on ncurses . A very good resource and the only one that I know of that is in print today. A.

There are other options like newt , pygcurses , etc., but this should get you started. Best of all, TUI programming today is one of those technology fetishes that are hard to break into, but it is useful.

+9
source share

While the above is a perfectly reasonable solution for Linux, the OP has requested other suggestions and justification for them.

Who wants to use a low-level API like curses in a modern OO language like Python? Not to mention that you are stuck inside Windows (which is not the OP, but this is a problem for many people) ... There must be a better way.

To try to solve this problem, I put together a simple cross-platform class (yup - Windows is on, without departing from PDcurses) to do everything that most people want from their terminal / console. If you work on Linux, this is a more humane way to program curses. If you work on Windows, the same class works as without external binary dependencies. The Screen class can be found at https://github.com/peterbrittain/asciimatics .

In addition, I created a loading of high-level objects for creating animations and TUIs. For example, this is a sample entry using TUI widgets:

Text Interface Widgets

If you need an extra feature, let me know and I will see what I can do.

+4
source share

If your game is running inside the console, just select curses .

If your game will run as a GUI application, simply select PySide .

+1
source share

All Articles