Currently the actual range editor used in a "View" do not always conform to the one specified with the mode option, which is unintuitive.
For example if the range is given by low=0 and high=None the actual range editor used is always RangeTextEditor no matter if you specified mode='xslider' or mode='spinner'. That is unexpected. I would expect that explicit set mode would take precedence over automatic settings.
The lines controlling this behavior is given below in _get_simple_editor_class and _get_custom_editor_class methods:
|
def _get_simple_editor_class(self): |
|
"""Returns the editor class to use for a simple style. |
|
|
|
The type of editor depends on the type and extent of the range being |
|
edited: |
|
|
|
* One end of range is unspecified: RangeTextEditor |
|
* **mode** is specified and not 'auto': editor corresponding to |
|
**mode** |
|
* Floating point range with extent > 100: LargeRangeSliderEditor |
|
* Integer range or floating point range with extent <= 100: |
|
SimpleSliderEditor |
|
* All other cases: SimpleSpinEditor |
|
""" |
|
low, high, is_float = self._low_value, self._high_value, self.is_float |
|
|
|
if (low is None) or (high is None): |
|
return toolkit_object("range_editor:RangeTextEditor") |
|
|
|
if (not is_float) and (abs(high - low) > 1000000000): |
|
return toolkit_object("range_editor:RangeTextEditor") |
|
|
|
if self.mode != "auto": |
|
return toolkit_object("range_editor:SimpleEditorMap")[self.mode] |
|
|
|
if is_float and (abs(high - low) > 100): |
|
return toolkit_object("range_editor:LargeRangeSliderEditor") |
|
|
|
if is_float or (abs(high - low) <= 100): |
|
return toolkit_object("range_editor:SimpleSliderEditor") |
|
|
|
return toolkit_object("range_editor:SimpleSpinEditor") |
|
def _get_custom_editor_class(self): |
|
"""Creates a custom style of range editor |
|
|
|
The type of editor depends on the type and extent of the range being |
|
edited: |
|
|
|
* One end of range is unspecified: RangeTextEditor |
|
* **mode** is specified and not 'auto': editor corresponding to |
|
**mode** |
|
* Floating point range: Same as "simple" style |
|
* Integer range with extent > 15: Same as "simple" style |
|
* Integer range with extent <= 15: CustomEnumEditor |
|
|
|
""" |
|
low, high, is_float = self._low_value, self._high_value, self.is_float |
|
if (low is None) or (high is None): |
|
return toolkit_object("range_editor:RangeTextEditor") |
|
|
|
if self.mode != "auto": |
|
return toolkit_object("range_editor:CustomEditorMap")[self.mode] |
|
|
|
if is_float or (abs(high - low) > 15): |
|
return self.simple_editor_class |
|
|
|
return toolkit_object("range_editor:CustomEnumEditor") |
Currently the actual range editor used in a "View" do not always conform to the one specified with the mode option, which is unintuitive.
For example if the range is given by low=0 and high=None the actual range editor used is always RangeTextEditor no matter if you specified mode='xslider' or mode='spinner'. That is unexpected. I would expect that explicit set mode would take precedence over automatic settings.
The lines controlling this behavior is given below in _get_simple_editor_class and _get_custom_editor_class methods:
traitsui/traitsui/editors/range_editor.py
Lines 214 to 245 in 87dceb2
traitsui/traitsui/editors/range_editor.py
Lines 247 to 271 in 87dceb2