default colors for enum ColorMap type (#1428)

* default colors for enum ColorMap type

* Update ColorMapWidget.py

if to elif

Co-authored-by: ALLENINST\stephanies <stephanies@alleninstitute.org>
This commit is contained in:
Stephanie Seeman 2020-11-11 09:03:50 -08:00 committed by GitHub
parent 4575decf6f
commit b21967d20d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,7 +71,15 @@ class ColorMapParameter(ptree.types.GroupParameter):
defaults = fieldSpec.get('defaults', {})
for k, v in defaults.items():
if k == 'colormap':
item.setValue(v)
if mode == 'range':
item.setValue(v)
elif mode == 'enum':
children = item.param('Values').children()
for i, child in enumerate(children):
try:
child.setValue(v[i])
except IndexError('No default color set for child %s' % child.name()):
continue
else:
item[k] = v