enthought / enthought/traits

Either trait displayed as many times as there is possible trait type

Open
#375 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

The `either_test` item is displayed twice on this example:

``` python
from traits.api import HasTraits, Either, Float, String, Instance
from traitsui.api import View, UItem, InstanceEditor

class FloatTest(HasTraits):
float_test = Float()

class StringTest(HasTraits):
string_test = String()

class EitherTest(HasTraits):
either_test = Either(
Instance(FloatTest),
Instance(StringTest),
)

traits_view = View(
UItem('either_test', style="custom")
)

EitherTest(either_test=FloatTest()).configure_traits()
```

It sounds like this happens only using `Either` on `Instance` trait. And the `UItem` is displayed as many time as there is possible trait type in the `Either` list.

@corranwebster found that a workaround is to define an editor for the `UItem`:
```python
UItem('either_test', style="custom", editor=InstanceEditor())
```

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.