Hey dear readership :)
What.
I recently was in a need of a handy and nice way (not just pragmatic) to chose between different entities in the command line, each of them constituting an option. Surely, you can craft a simple menu with standard I/O functions, but I wanted to explore something different and more beautiful.
Therefore I found curses, a simple wrapper around ncurses, the famous BSD/UNIX library for portable advanced terminal handling.
So, I dived into this library, I'd recommend this tutorial for everyone who wants to deal with this old school stuff...
How.
You can check out the recent script on my github site. Here is a copy, for everyone to lazy to look it up:
import curses
# Author: Nikolai Tschacher
# Date: 02.06.2013
class BoxSelector:
""" Originally designed for accman.py.
Display options build from a list of strings in a (unix) terminal.
The user can browser though the textboxes and select one with enter.
"""
def __init__(self, L):
""" Create a BoxSelector object.
L is a list of strings. Each string is used to build
a textbox.
"""
self.L = L
# Element parameters. Change them here.
self.TEXTBOX_WIDTH = 50
self.TEXTBOX_HEIGHT = 6
self.PAD_WIDTH = 400
self …Continue reading