@@ -2074,37 +2074,34 @@ def set_handle_props(self, **handle_props):
2074
2074
self .update ()
2075
2075
self ._handle_props .update (handle_props )
2076
2076
2077
- def _validate_state (self , value ):
2077
+ def _validate_state (self , state ):
2078
2078
supported_state = [
2079
2079
key for key , value in self ._state_modifier_keys .items ()
2080
2080
if key != 'clear' and value != 'not-applicable'
2081
2081
]
2082
- if value not in supported_state :
2083
- keys = ', ' .join (supported_state )
2084
- raise ValueError ('Setting default state must be one of the '
2085
- f'following: { keys } .' )
2082
+ _api .check_in_list (supported_state , state = state )
2086
2083
2087
- def add_state (self , value ):
2084
+ def add_state (self , state ):
2088
2085
"""
2089
2086
Add a state to define the widget's behavior. See the
2090
2087
`state_modifier_keys` parameters for details.
2091
2088
2092
2089
Parameters
2093
2090
----------
2094
- value : str
2091
+ state : str
2095
2092
Must be a supported state of the selector. See the
2096
2093
`state_modifier_keys` parameters for details.
2097
2094
2098
2095
Raises
2099
2096
------
2100
2097
ValueError
2101
- When the value is not supported by the selector.
2098
+ When the state is not supported by the selector.
2102
2099
2103
2100
"""
2104
- self ._validate_state (value )
2105
- self ._state .add (value )
2101
+ self ._validate_state (state )
2102
+ self ._state .add (state )
2106
2103
2107
- def remove_state (self , value ):
2104
+ def remove_state (self , state ):
2108
2105
"""
2109
2106
Remove a state to define the widget's behavior. See the
2110
2107
`state_modifier_keys` parameters for details.
@@ -2118,11 +2115,11 @@ def remove_state(self, value):
2118
2115
Raises
2119
2116
------
2120
2117
ValueError
2121
- When the value is not supported by the selector.
2118
+ When the state is not supported by the selector.
2122
2119
2123
2120
"""
2124
- self ._validate_state (value )
2125
- self ._state .remove (value )
2121
+ self ._validate_state (state )
2122
+ self ._state .remove (state )
2126
2123
2127
2124
2128
2125
class SpanSelector (_SelectorWidget ):
@@ -2193,7 +2190,7 @@ def on_select(min: float, max: float) -> Any
2193
2190
2194
2191
state_modifier_keys : dict, optional
2195
2192
Keyboard modifiers which affect the widget's behavior. Values
2196
- amend the defaults.
2193
+ amend the defaults, which are:
2197
2194
2198
2195
- "clear": Clear the current shape, default: "escape".
2199
2196
@@ -2800,7 +2797,7 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
2800
2797
2801
2798
state_modifier_keys : dict, optional
2802
2799
Keyboard modifiers which affect the widget's behavior. Values
2803
- amend the defaults.
2800
+ amend the defaults, which are:
2804
2801
2805
2802
- "move": Move the existing shape, default: no modifier.
2806
2803
- "clear": Clear the current shape, default: "escape".
@@ -2855,6 +2852,8 @@ class RectangleSelector(_SelectorWidget):
2855
2852
props=props)
2856
2853
>>> fig.show()
2857
2854
2855
+ >>> selector.add_state('square')
2856
+
2858
2857
See also: :doc:`/gallery/widgets/rectangle_selector`
2859
2858
"""
2860
2859
0 commit comments