So, let me try to make things clear:
You want a multiple selection dropdown, and what you need to get out of it is the list of LABELS that were selected ? Not the values ? Are the values used in any way ?
I suggest populating your dropdown like this
# Whatever processing takes place before the snippet you showed us and that results in `outputdata`
# If it's the results of processing, you might as well use a pyDataSet so that it's easier to manipulate.
return [
{
'value': wcenter,
'label': wcenter
} for wcenter in outputdata
]
This is a ROUGH example. You might need to cast to string as you did before, though that could be done earlier in the building of outputdata
.
You could also rework the label a bit, maybe something like {'label': wcenter.replace('_', ' ')}
, things like that.
Now you can use the label
for display only, and use value
for your things.
Bind something to dropdown.props.values
and you’ll get a list of those wcenter
, that you can iterate through like this:
for value in dropdown.prop.values:
do_something(value)
And you’ll get every wcenter
that was selected.
If you really need to have a number associated to your wcenters:
return [
{
'label': wcenter,
'value': {
'index': i,
'name': wcenter
}
} for i, wcenter in enumerate(outputdata)
]
Now when entries are selected in the dropdown, you’ll get a list that looks like this:
[
{
'index': x,
'name': "center foo"
},
{
'index': y,
'name': "center bar"
}
]
That you can iterate through:
for index, name in values.items():
do_something(index, name)