(options)
return options[index]
Accepts a list and causes TextMate to show an inline menu.
    
    If options is a list of strings, will return the selected index.
    
    If options is a list of (key, value) tuples, will display "key" and 
    return "value". Note that we don't use dicts, so that key-value options
    can be ordered. If you want to use a dict, try dict.items().
    
    In either input case, a list item with value `None` causes tm_dialog to
    display a separator for that index.
Accepts a list and causes TextMate to show an inline menu.
    
    If options is a list of strings, will return the selected index.
    
    If options is a list of (key, value) tuples, will display "key" and 
    return "value". Note that we don't use dicts, so that key-value options
    can be ordered. If you want to use a dict, try dict.items().
    
    In either input case, a list item with value `None` causes tm_dialog to
    display a separator for that index.
Accepts a list and causes TextMate to show an inline menu . If options is a list of strings will return the selected index . If options is a list of ( key value ) tuples will display key and return value . Note that we don t use dicts so that key - value options can be ordered . If you want to use a dict try dict . items () . In either input case a list item with value None causes tm_dialog to display a separator for that index .
def menu(options):
    """ Accepts a list and causes TextMate to show an inline menu.
    
    If options is a list of strings, will return the selected index.
    
    If options is a list of (key, value) tuples, will display "key" and 
    return "value". Note that we don't use dicts, so that key-value options
    can be ordered. If you want to use a dict, try dict.items().
    
    In either input case, a list item with value `None` causes tm_dialog to
    display a separator for that index.
    """
    hashed_options = False
    if not options:
        return None
    menu = dict(menuItems=[item(thing) for thing in options])
    if all_are_instance(options, (tuple, NoneType)):
        hashed_options = True
    plist = to_plist(menu)
    proc = subprocess.Popen([dialog, '-u'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
    proc.stdin.write(plist)
    output, _ = proc.communicate()
    result = from_plist(output)
    if not 'selectedIndex' in result:
        return None
    index = int(result['selectedIndex'])
    if hashed_options:
        return options[index][1]
    return options[index]
def menu ( options ) : hashed_options = False if not options : return None menu = dict ( menuItems = [ item ( thing ) for thing in options ] ) if all_are_instance ( options , ( tuple , NoneType ) ) : hashed_options = True plist = to_plist ( menu ) proc = subprocess . Popen ( [ dialog , '-u' ] , stdout = subprocess . PIPE , stdin = subprocess . PIPE ) proc . stdin . write ( plist ) output , _ = proc . communicate ( ) result = from_plist ( output ) if not 'selectedIndex' in result : return None index = int ( result [ 'selectedIndex' ] ) if hashed_options : return options [ index ] [ 1 ] return options [ index ]