enthought / enthought/traitsui
{visible/enabled}_when for Label on wx does not work on application start
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
see comment:
https://github.com/enthought/traitsui/pull/1544#discussion_r617672507
The problem encountered was that if we set the labels wx window to invisible at the start, then toggling its visibility never did anything (it seems like the UI never gives space for it to exist).
You can observe this by adding `self._label_when()` as mentioned in the above comment.
Currently, even if the `visible_when` statement evaluates to false initially, we show the label...
Then as soon as anything changes in the UIs context everything gets synced up and the label is only visible when the `visible_when` expression is true
Code to play with to observe behavior:
```
from traits.api import HasTraits, Int, Str
from traitsui.api import View, Item, Label, HGroup
class A(HasTraits):
x = Int()
view = View(
Label("Visible", visible_when="x != 0"),
Label("Enabled", enabled_when="x != 0"),
Item('x'),
resizable=True
)
if __name__ == '__main__':
A().configure_traits()
```
mess with the default value for `x` to either be 0 or non 0.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.