enthought / enthought/traitsui
`HSplit`/`VSplit` panes don't collapse on `visible_when` change in Qt
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
This happens when you have something like:
```
VSplit(Item(..., visible_when='...'), ...)
```
At least some of the time, when the item is hidden, the space it takes up remains.
The `QSplitter` will collapse hidden panes by default, so in principle this should just work. However because the layout code wraps the editor and label in an anonymous widget here:
https://github.com/enthought/traitsui/blob/28a0b89888f87c97cacbc11e1d44b3fac912467a/traitsui/qt4/ui_panel.py#L615-L625
the anonymous widget is not linked to the `visible_when`. There is code in the `Editor` class that takes care of this situation for `Tabbed` groups:
https://github.com/enthought/traitsui/blob/c10d40d10a20e9cb7feb75b700d5ab41435c8d8d/traitsui/qt4/editor.py#L127-L185
but nothing there seems to handle splitters.
The immediate fix is probably to put something in place to handle splitters in the editor code. A better fix is a thorough refactor of the code.
A workaround is to wrap the item in a `VGroup` and have the `visible_when` on that.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.