I have a dictionary called Menu_Main:

Menu_Main =   { 1: ['People', Call_Fam],
                2: ['Groups', Call_Group],
                3: ['Events', nullfunc],
                4: ['Attendance', nullfunc],
                5: ['Visitation', nullfunc],
                6: ['Finances', nullfunc],
            7: ['Administration', nullfunc],
            10: ['Help', nullfunc],              # I would like to make the 
"10" an "h"
            12: ['Quit', 'return']}               # and the "12" a "q".

I assume the keys can be of mixed types.  However, I'm not sure how to adjust 
my code below that actually drives the menu system.  I changed "input" to 
"raw_input", but I get "H is not defined" when I run the script.  Essentially, 
I'd like the user to enter a number for most items, but use letters for "Help", 
"Quit", and "Back to Main".

def RunMenu(MenuList):
    '''This is the function that drives the menu system.

    We place the "clear screen" command twice to provide a fresh screen for
    each menu level.  We then call the menus above to display them.  There is a
    special value for MenuList[sel][1] of 'return' which is the exit condition
    for the loop. look at the entry for 9 of Menu_Main, or item 8 of Menu_Fam.
    '''
    while True:
        for opts in MenuList.keys():            # print menu list
            print opts, ': ', MenuList[opts][0] #
        sel = input('Enter Selection:')  # get input
        if sel in MenuList.keys():  #verify user input is a valid key
            if MenuList[sel][1] == 'return': return MenuList[sel][0]
            else: MenuList[sel][1]()

Thanks,
Don
-- 
DC Parris
Matheteuo Christian Fellowship
[EMAIL PROTECTED]
http://matheteuo.org/
Free software is like God's love - you can share it with anyone anywhere 
anytime!
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to