Show More
@@ -65,6 +65,7 b' class _Selection(DOMWidget):' | |||||
65 | # the setting of self.values right now, before anything else runs |
|
65 | # the setting of self.values right now, before anything else runs | |
66 | self.values = kwargs.pop('values') |
|
66 | self.values = kwargs.pop('values') | |
67 | DOMWidget.__init__(self, *args, **kwargs) |
|
67 | DOMWidget.__init__(self, *args, **kwargs) | |
|
68 | self._value_in_values() | |||
68 |
|
69 | |||
69 | def _values_changed(self, name, old, new): |
|
70 | def _values_changed(self, name, old, new): | |
70 | """Handles when the values dict has been changed. |
|
71 | """Handles when the values dict has been changed. | |
@@ -76,10 +77,13 b' class _Selection(DOMWidget):' | |||||
76 | self.value_names = list(new.keys()) |
|
77 | self.value_names = list(new.keys()) | |
77 | finally: |
|
78 | finally: | |
78 | self._in_values_changed = False |
|
79 | self._in_values_changed = False | |
|
80 | self._value_in_values() | |||
79 |
|
81 | |||
|
82 | def _value_in_values(self): | |||
80 | # ensure that the chosen value is one of the choices |
|
83 | # ensure that the chosen value is one of the choices | |
81 |
if self. |
|
84 | if self.values: | |
82 |
self.value |
|
85 | if self.value not in self.values.values(): | |
|
86 | self.value = next(iter(self.values.values())) | |||
83 |
|
87 | |||
84 | def _value_names_changed(self, name, old, new): |
|
88 | def _value_names_changed(self, name, old, new): | |
85 | if not self._in_values_changed: |
|
89 | if not self._in_values_changed: |
General Comments 0
You need to be logged in to leave comments.
Login now