@@ -117,7 +117,7 @@ def _validate_options(self, proposal):
117
117
118
118
@observe ('options' )
119
119
def _propagate_options (self , change ):
120
- "Set the values and labels, and unselect any option if we aren't initializing"
120
+ "Set the values and labels, and select the first option if we aren't initializing"
121
121
options = self ._options_full
122
122
self .set_trait ('_options_labels' , tuple (i [0 ] for i in options ))
123
123
self ._options_values = tuple (i [1 ] for i in options )
@@ -391,6 +391,15 @@ def _validate_options(self, proposal):
391
391
raise TraitError ("Option list must be nonempty" )
392
392
return proposal .value
393
393
394
+ @observe ('options' )
395
+ def _propagate_options (self , change ):
396
+ "Select the first option"
397
+ options = self ._options_full
398
+ self .set_trait ('_options_labels' , tuple (i [0 ] for i in options ))
399
+ self ._options_values = tuple (i [1 ] for i in options )
400
+ if self ._initializing_traits_ is not True :
401
+ self .index = (0 , 0 )
402
+
394
403
@register
395
404
class SelectionSlider (_SelectionNonempty ):
396
405
"""Slider to select a single item from a list or dictionary."""
@@ -415,13 +424,6 @@ class SelectionRangeSlider(_MultipleSelectionNonempty):
415
424
label = Tuple (help = "Min and max selected labels" )
416
425
index = Tuple ((0 ,0 ), help = "Min and max selected indices" ).tag (sync = True )
417
426
418
- @observe ('options' )
419
- def _propagate_options (self , change ):
420
- "Unselect any option"
421
- if self ._initializing_traits_ is not True :
422
- self .index = (0 , 0 )
423
- self .set_trait ('_options_labels' , tuple (i [0 ] for i in change .new ))
424
- self ._options_values = tuple (i [1 ] for i in change .new )
425
427
426
428
@validate ('index' )
427
429
def _validate_index (self , proposal ):
0 commit comments