The SelectionDialog module

On this page :

Also see :

PR 31552 New parametric module SelectionDialog has been added. See help(SelectionDialog) for more details. (v2015)

PR 44894 In the Python API, users can browse a subset of the shape file. See help(SelectionDialog.RunMaterialFileSelectionDialog) for more information. The dialog .choose_file.ChooseMtrl can support similar functionality via attributes for a list of shapes and browser title. (v2018)


The SelectionDialog module can be used to add four different types of selection dialogs. The following example demonstrates the four types.

import SelectionDialog as SD
if __name__ == '__main__':
ok, sel = SD.RunCustomSelectionDialogForOneItem(
'Select one item'
, sorted([2, 1, 0])
, 2
)
print(ok, sel)
if ok:
ok, sel = SD.RunCustomSelectionDialogForOneItemWithDescription(
'Select one item description'
, sorted({0:'c', 1:'b', 2:'a'}.items(), key=lambda o: o[1])
, 0
)
print(ok, sel)
if ok:
ok, sel = SD.RunCustomSelectionDialogForManyItems(
'Select many items'
, sorted([2, 1, 0])
, [1, 2]
)
print(ok, sel)
if ok:
ok, sel = SD.RunCustomSelectionDialogForManyItemsWithDescriptions(
'Select many item descriptions'
, sorted({0:'c', 1:'b', 2:'a'}.items(), key=lambda o: o[1])
, [0, 1]
)
print(ok, sel)

Documentation can be accessed using python's built in help function and the SDS2 Python Prompt .

SDS2 Python Prompt

>>> import SelectionDialog                           # import the module
>>>
>>> help(SelectionDialog)                              # access help on the module
Help on module SelectionDialog:

NAME
SelectionDialog

FILE
(built-in)

FUNCTIONS
RunCustomSelectionDialogForManyItems(...)
RunCustomSelectionDialogForManyItems( (str)dialog_title, (list)items [, (list)preselection=[]]) -> tuple :
Launch a selection dialog displaying the values in items.
Return a pair indicating if the user clicked OK and
the selected items.
Example: ok, sel = RunCustomSelectionDialogForManyItems(
'Select many items'
, sorted([2, 1, 0])
, [1, 2])


C++ signature :
boost::python::tuple RunCustomSelectionDialogForManyItems(std::string,boost::python::list [,boost::python::list=[]])

RunCustomSelectionDialogForManyItemsWithDescriptions(...)
RunCustomSelectionDialogForManyItemsWithDescriptions( (str)dialog_title, (list)key_description_tuples [, (list)preselection=[]]) -> tuple :
Launch a selection dialog displaying the items
in [d for k, d in key_description_tuples].
Return a pair indicating if the user clicked OK and
the selected key/description tuples.
Example: ok, sel = SD.RunCustomSelectionDialogForManyItemsWithDescriptions(
'Select many item descriptions'
, sorted({0:'c', 1:'b', 2:'a'}.items(), key=lambda o: o[1])
, [0, 1])


C++ signature :
boost::python::tuple RunCustomSelectionDialogForManyItemsWithDescriptions(std::string,boost::python::list [,boost::python::list=[]])

RunCustomSelectionDialogForManyItemsWithDescriptions( (str)dialog_title, (dict)description_dictionary [, (list)preselection=[]]) -> tuple :
Launch a selection dialog displaying the values in description_dictionary.
Return a pair indicating if the user clicked OK and
the selected key/description tuples.
Example: ok, sel = SD.RunCustomSelectionDialogForManyItemsWithDescriptions(
'Select many item descriptions'
, {0:'c', 1:'b', 2:'a'}
, [0, 1])


C++ signature :
boost::python::tuple RunCustomSelectionDialogForManyItemsWithDescriptions(std::string,boost::python::dict [,boost::python::list=[]])

RunCustomSelectionDialogForOneItem(...)
RunCustomSelectionDialogForOneItem( (str)dialog_title, (list)items [, (object)preselection=None]) -> tuple :
Launch a selection dialog displaying the values in items.
Return a pair indicating if the user clicked OK and
the selected description if one was selected.
Example: ok, sel = RunCustomSelectionDialogForOneItem(
'Select one item', sorted([2,1,0]), 2)

C++ signature :
boost::python::tuple RunCustomSelectionDialogForOneItem(std::string,boost::python::list [,boost::python::api::object=None])

RunCustomSelectionDialogForOneItemWithDescription(...)
RunCustomSelectionDialogForOneItemWithDescription( (str)dialog_title, (list)key_description_tuples [, (object)preselection=None]) -> tuple :
Launch a selection dialog displaying the items
in [d for k, d in key_description_tuples].
Return a pair indicating if the user clicked OK and
the selected key/description tuple if one was selected.
Example: ok, sel = RunCustomSelectionDialogForOneItemWithDescription(
'Select one item description'
, sorted({0:'c', 1:'b', 2:'a'}.items(), key=lambda o: o[1])
, 0)


C++ signature :
boost::python::tuple RunCustomSelectionDialogForOneItemWithDescription(std::string,boost::python::list [,boost::python::api::object=None])

RunCustomSelectionDialogForOneItemWithDescription( (str)dialog_title, (dict)description_dictionary [, (object)preselection=None]) -> tuple :
Launch a selection dialog displaying the values in description_dictionary.
Return a pair indicating if the user clicked OK and
the selected key/description tuple if one was selected.
Example: ok, sel = RunCustomSelectionDialogForOneItemWithDescription(
'Select many item descriptions'
, {0:'c', 1:'b', 2:'a'}
, [0, 1])


C++ signature :
boost::python::tuple RunCustomSelectionDialogForOneItemWithDescription(std::string,boost::python::dict [,boost::python::api::object=None])