enthought / enthought/traitsui

A `RangeEditor` editing a `Range` trait will not use the trait's `low` and `high` settings

Open
#2,005 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
306
Forks
99
PR merge metrics
No merged PRs in 30d

Description

Using qt (pyside6 6.2.3) with the latest traitsui release (7.4.3).

A `RangeEditor` that edits a `Range` trait will ignore the trait's `low` and `high` and will default to 0.0 - 1.0 instead:

```python
from traits.api import HasStrictTraits, Range
from traitsui.api import View, Item, RangeEditor

class FixedRange(HasStrictTraits):
a_range = Range(low=0, high=72, value=1)

def default_traits_view(self):
return View(
Item("a_range", style="custom", editor=RangeEditor(mode="slider")),
width=330, height=60,
title="Editor will not inherit low/high"
)

FixedRange().configure_traits()
```

![image](https://user-images.githubusercontent.com/7642150/229066525-a2b8e895-cefc-4b1d-85c8-0491e4cd02fa.png)

(_Expected: slider going from 0 to 72 instead of 0.0 to 1.0_)

The same happens with other modes ("spinner").

**Known workaround**: assign `low` and `high` manually.
**Limitation**: this is unfeasible if the `Range` trait uses extended trait names for `low` and `high`.

---

_Addendum._ I should also point out that if the `RangeEditor` is then used, it will likely generate invalid trait values (in this case, `Range` is validating to `int` because high, low and value are ints; `RangeEditor` however produces floats because it ignored these parameters).

It surprised me that the exception is displayed to the user with a dialog rather than with a "failed validation" color.

![image](https://user-images.githubusercontent.com/7642150/229066918-ff87e5d0-9639-499f-8c06-b3a1ae4b889b.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.