Python and curses – A small textbox selection example.

Hey dear readership :)



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…


You can check out the recent script on my github site. Here is a copy, for everyone to lazy to look it up:


As you can see, it is very easy to make such a browsable text selection command line interface. Just pass you list of strings to a BoxSelector() class and call the method pick(), which creates all the terminal interface stuff and terminates if a user chose a textbox with hitting enter…

Here is a little picture illustrating the above example: illustration

2 thoughts on “Python and curses – A small textbox selection example.

Leave a Reply

Your email address will not be published. Required fields are marked *

reload captcha

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">