Welcome to mirror list, hosted at ThFree Co, Russian Federation.

userquery.py « utils « mcf « modules « python « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e1dc1bfeda53e1bab5ce7aa38979d50d09e51dfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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