|
16 | 16 | from .trait_types import InstanceDict, TypedTuple
|
17 | 17 | from .widget import register, widget_serialization
|
18 | 18 | 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, |
20 | 20 | Tuple, Union, observe, validate)
|
21 | 21 |
|
22 | 22 | _doc_snippets = {}
|
@@ -161,10 +161,8 @@ def __init__(self, *args, **kwargs):
|
161 | 161 | # We have to make the basic options bookkeeping consistent
|
162 | 162 | # so we don't have errors the first time validators run
|
163 | 163 | 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) |
168 | 166 |
|
169 | 167 | # Select the first item by default, if we can
|
170 | 168 | if 'index' not in kwargs and 'value' not in kwargs and 'label' not in kwargs:
|
@@ -303,10 +301,8 @@ def __init__(self, *args, **kwargs):
|
303 | 301 | # We have to make the basic options bookkeeping consistent
|
304 | 302 | # so we don't have errors the first time validators run
|
305 | 303 | 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) |
310 | 306 |
|
311 | 307 | super().__init__(*args, **kwargs)
|
312 | 308 | self._initializing_traits_ = False
|
|
0 commit comments