Пример #1
0
def get_choice_input(prompt, title, choices):
	"""
	``get_choice_input`` prompts the user to select the one of the provided choices.

	Note: This API function differently on the command line vs. the UI. In the UI a popup is used. On the commandline
	      a simple text prompt is used. The ui uses a combo box.

	:param str prompt: String to prompt with.
	:param str title: Title of the window when executed in the UI.
	:param list choices: A list of strings for the user to choose from.
	:rtype: integer array index of the selected option
	:Example:
		>>> get_choice_input("PROMPT>", "choices", ["Yes", "No", "Maybe"])
		choices
		1) Yes
		2) No
		3) Maybe
		PROMPT> 1
		0L
	"""
	choice_buf = (ctypes.c_char_p * len(choices))()
	for i in xrange(0, len(choices)):
		choice_buf[i] = str(choices[i])
	value = ctypes.c_ulonglong()
	if not core.BNGetChoiceInput(value, prompt, title, choice_buf, len(choices)):
		return None
	return value.value
Пример #2
0
def get_choice_input(prompt, title, choices):
    choice_buf = (ctypes.c_char_p * len(choices))()
    for i in xrange(0, len(choices)):
        choice_buf[i] = str(choices[i])
    value = ctypes.c_ulonglong()
    if not core.BNGetChoiceInput(value, prompt, title, choice_buf,
                                 len(choices)):
        return None
    return value.value