Skip to content

Commit 52f05cb

Browse files
committed
validate options the normal way
1 parent adfd39c commit 52f05cb

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

ipywidgets/widgets/widget_selection.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .trait_types import InstanceDict, TypedTuple
1717
from .widget import register, widget_serialization
1818
from .docutils import doc_subst
19-
from traitlets import (Unicode, Bool, Int, Any, Dict, TraitError, CaselessStrEnum,
19+
from traitlets import (Unicode, Bool, Bunch, Int, Any, Dict, TraitError, CaselessStrEnum,
2020
Tuple, Union, observe, validate)
2121

2222
_doc_snippets = {}
@@ -161,10 +161,8 @@ def __init__(self, *args, **kwargs):
161161
# We have to make the basic options bookkeeping consistent
162162
# so we don't have errors the first time validators run
163163
self._initializing_traits_ = True
164-
options = _make_options(kwargs.get('options', ()))
165-
self._options_full = options
166-
self.set_trait('_options_labels', tuple(i[0] for i in options))
167-
self._options_values = tuple(i[1] for i in options)
164+
kwargs['options'] = self._validate_options(Bunch(value = kwargs.get('options', ())))
165+
self._propagate_options(None)
168166

169167
# Select the first item by default, if we can
170168
if 'index' not in kwargs and 'value' not in kwargs and 'label' not in kwargs:
@@ -303,10 +301,8 @@ def __init__(self, *args, **kwargs):
303301
# We have to make the basic options bookkeeping consistent
304302
# so we don't have errors the first time validators run
305303
self._initializing_traits_ = True
306-
options = _make_options(kwargs.get('options', ()))
307-
self._options_full = options
308-
self.set_trait('_options_labels', tuple(i[0] for i in options))
309-
self._options_values = tuple(i[1] for i in options)
304+
kwargs['options'] = self._validate_options(Bunch(value = kwargs.get('options', ())))
305+
self._propagate_options(None)
310306

311307
super().__init__(*args, **kwargs)
312308
self._initializing_traits_ = False

0 commit comments

Comments
 (0)