This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/intern/python/modules/mcf/utils/userquery.py
Hans Lambermont 12315f4d0e Initial revision
2002-10-12 11:37:38 +00:00

18 lines
464 B
Python

import string
def userquery( prompt, choices, contextdata = '', defaultind=0 ):
if contextdata:
print 'Contextual Information:', contextdata
for x in range( len( choices ) ):
print '(%s)'%x, `choices[x]`
choice = raw_input( prompt+( '(%s):'%defaultind ) )
if not choice:
return choices[ defaultind ]
try:
choice = string.atoi( choice )
return choices[ choice]
except IndexError :
return choices[ defaultind ]
except ValueError:
return choice