MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / ChoiceField

Class ChoiceField

python/interaction.py:265–319  ·  view source on GitHub ↗

``ChoiceField`` prompts the user to choose from the list of strings provided in ``choices``. Result is stored \ in self.result as an index in to the choices array. :attr str prompt: prompt to be presented to the user :attr list(str) choices: list of choices to choose from

Source from the content-addressed store, hash-verified

263
264
265class ChoiceField:
266 """
267 ``ChoiceField`` prompts the user to choose from the list of strings provided in ``choices``. Result is stored \
268 in self.result as an index in to the choices array.
269
270 :attr str prompt: prompt to be presented to the user
271 :attr list(str) choices: list of choices to choose from
272 """
273 def __init__(self, prompt: str, choices: List[str], default: Optional[str] = None):
274 self._prompt = prompt
275 self._choices = choices
276 self._default = default
277 self._result = None
278
279 def _fill_core_struct(self, value):
280 value.type = FormInputFieldType.ChoiceFormField
281 value.prompt = self._prompt
282 choice_buf = (ctypes.c_char_p * len(self._choices))()
283 for i in range(0, len(self._choices)):
284 choice_buf[i] = self._choices[i].encode('charmap')
285 value.choices = choice_buf
286 value.count = len(self._choices)
287 value.hasDefault = self._default is not None
288 if self._default is not None:
289 value.indexDefault = self._default
290
291 def _fill_core_result(self, value):
292 value.indexResult = self._result
293
294 def _get_result(self, value):
295 self._result = value.indexResult
296
297 @property
298 def prompt(self):
299 return self._prompt
300
301 @prompt.setter
302 def prompt(self, value):
303 self._prompt = value
304
305 @property
306 def choices(self):
307 return self._choices
308
309 @choices.setter
310 def choices(self, value):
311 self._choices = value
312
313 @property
314 def result(self):
315 return self._result
316
317 @result.setter
318 def result(self, value):
319 self._result = value
320
321
322class OpenFileNameField:

Callers 2

save_svgFunction · 0.90
_get_form_inputMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected