enthought / enthought/traitsui
Enum RadioEditor labels are mapped twice
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
When creating labels for the buttons, the `names` are mapped to `labels` here using supplied `format_func`:
https://github.com/enthought/traitsui/blob/e9f6b0cc03bbad20feb1f7e4f86ce2e174685fbb/traitsui/qt4/enum_editor.py#L389-L393
The names however have already been mapped using the same `format_func` when they were parsed (in `traitsui.helper.enum_values_changed`), which leads to the following situation:
```python
class Foo(HasTraits):
true_or_false = Int()
def default_traits_view(self):
return View(
Item(
"true_or_false",
editor=EnumEditor(
# reusing this maps "FALSE" to "TRUE"
format_func=lambda v: str(bool(v)).upper(),
values=[0, 1],
mode="radio"
),
style='custom'
)
)
foo = Foo()
ui = foo.configure_traits()
```

This is the case with both qt and wx.
The mapping has been around for ~9 years but this bug didn't surface until recently due to https://github.com/enthought/traitsui/issues/267
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.