Monday, April 7, 2014

A curses menu library in Python

Curses Menu Library in Python


Just posted on Google Code a "curses menu library" ; 
https://code.google.com/p/menulib-python/

My little application (also on Google Code) to mimic the digital rain in the movie Matrix  using curses was a little warm-up for something a bit more interesting.

I'm working on the menu of the "call-centre Management" made even earlier - that will offer the menu option of creating a new Game, giving a list of the staff, hiring (and firing) agents, and Inspect them while they're working...

About this Menu library


It works as a standalone program - a demo of sort.
But it is more useful to import it in other program. Just make sure the menulib.py is in the same directory as your source file and then add this line in the import section:

from menulib import run_menu

and in your main program you can then declare a menu as a list :

main_menu = [ "New File", "Edit", "Search", "Exit"]

The last option has to be the one exiting the program

Then in the main function add
option=run_menu(main_menu)
and then add all the conditions to handle the option returned from the menu.

Friday, April 4, 2014

Python new code update and useful links

Some modifications

Since my last post - I've changed a few lines of code, because it wasn't using the "wrapper" function that I understand is a good practice when using the curses library.

Otherwise when debugging sometime the terminal is rendered unusable (typing characters aren't showed, the sequence would only appear after pressing the return key) - the remedy is to type (blindly) stty sane and pressing enter hoping there was no typo ...

 

Hosted on google code

The project is now both on pastebin.com and https://code.google.com/p/matrix-effect/

 

Finally

Here's my bookmarks for Python :

Very useful on how to use the curses library - helped me a lot to understand how to implement : https://www.youtube.com/user/pythoncursestutorial

Very useful tool to understand (by visualization) Python "funky" syntax like :
list1 = list0[:]
x, y = 10, 14
http://www.pythontutor.com/visualize.html#mode=display

Great list of online Python courses on Codecademy
http://www.codecademy.com/groups/python-fro-beginners/discussions/5168241ffd62d12b10004c46

Interactive online Python console lab from Codecademy
http://labs.codecademy.com/#:workspace

For later use (I'm not there yet) :
http://pyglet.org/doc-current/programming_guide/quickstart.html
http://inventwithpython.com/