본문 바로가기
  • AI (Artificial Intelligence)
Industry 4.0/Python

A curses menu library in Python

by 로샤스 2014. 4. 16.

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.

 

 

 

 

 

 

 

출처 : http://blog.peileppe.com/2014/04/a-curses-menu-library-in-python.html

 

 

 

 

 

 

 

'Industry 4.0 > Python' 카테고리의 다른 글

if…elif…else in Python  (0) 2021.03.31
Python에서 가장 큰 값  (0) 2015.06.19
Python에서 main() 함수 구현  (0) 2015.06.17
Install PyCharm and JDK on Ubuntu 12.04  (1) 2014.04.15
Ubuntu에서 Python 설치하기  (1) 2014.04.15

댓글