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

Function get_form_input

python/interaction.py:1356–1419  ·  view source on GitHub ↗

``get_from_input`` Prompts the user for a set of inputs specified in ``fields`` with given title. \ The fields parameter is a list which can contain the following types: ===================== =================================================== FieldType Description ===============

(fields, title)

Source from the content-addressed store, hash-verified

1354
1355
1356def get_form_input(fields, title):
1357 """
1358 ``get_from_input`` Prompts the user for a set of inputs specified in ``fields`` with given title. \
1359 The fields parameter is a list which can contain the following types:
1360
1361 ===================== ===================================================
1362 FieldType Description
1363 ===================== ===================================================
1364 str an alias for LabelField
1365 None an alias for SeparatorField
1366 LabelField Text output
1367 SeparatorField Vertical spacing
1368 TextLineField Prompt for a string value
1369 MultilineTextField Prompt for multi-line string value
1370 IntegerField Prompt for an integer
1371 AddressField Prompt for an address
1372 ChoiceField Prompt for a choice from provided options
1373 OpenFileNameField Prompt for file to open
1374 SaveFileNameField Prompt for file to save to
1375 DirectoryNameField Prompt for directory name
1376 ===================== ===================================================
1377
1378 This API is flexible and works both in the UI via a pop-up dialog and on the command-line.
1379
1380 .. note:: More complicated APIs should consider using the included pyside2 functionality in the `binaryninjaui` module. Returns true or false depending on whether the user submitted responses or cancelled the dialog.
1381
1382 :param fields: A list containing these classes, strings or None
1383 :type fields: list(str) or list(None) or list(LabelField) or list(SeparatorField) or list(TextLineField) or list(MultilineTextField) or list(IntegerField) or list(AddressField) or list(ChoiceField) or list(OpenFileNameField) or list(SaveFileNameField) or list(DirectoryNameField)
1384 :param str title: The title of the pop-up dialog
1385 :rtype: bool
1386 :Example:
1387
1388 >>> int_f = IntegerField("Specify Integer")
1389 >>> tex_f = TextLineField("Specify name")
1390 >>> choice_f = ChoiceField("Options", ["Yes", "No", "Maybe"])
1391 >>> get_form_input(["Get Data", None, int_f, tex_f, choice_f], "The options")
1392 Get Data
1393 <empty>
1394 Specify Integer 1337
1395 Specify name Peter
1396 The options
1397 1) Yes
1398 2) No
1399 3) Maybe
1400 Options 1
1401 >>> True
1402 >>> print(tex_f.result, int_f.result, choice_f.result)
1403 Peter 1337 0
1404 """
1405 value = (core.BNFormInputField * len(fields))()
1406 for i in range(0, len(fields)):
1407 if isinstance(fields[i], str):
1408 LabelField(fields[i])._fill_core_struct(value[i])
1409 elif fields[i] is None:
1410 SeparatorField()._fill_core_struct(value[i])
1411 else:
1412 fields[i]._fill_core_struct(value[i])
1413 if not core.BNGetFormInput(value, len(fields), title):

Callers 1

save_svgFunction · 0.90

Calls 4

LabelFieldClass · 0.85
SeparatorFieldClass · 0.85
_fill_core_structMethod · 0.45
_get_resultMethod · 0.45

Tested by

no test coverage detected