enthought / enthought/traitsui
Proportional-width columns in TabularEditor do not resize when table is resized.
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
According to the docs, if the column widths are set to a fraction between `0` and `1` then the column widths are computed as the fraction of the total width of the tabular editor.. This works fine for the initial layout but the columns do not readjust when the editor is resized..
The problem seems to be that column resize events are explicitly ignored after the initial layout. Here is the relevant code in `traitsui/qt4/tabular_editor.py`:
```
def resizeEvent(self, event):
...
if (not self._initial_size and parent and
(self.isVisible() or isinstance(parent, QtGui.QMainWindow))):
self._initial_size = True
self.resizeColumnsToContents()
```
Essentially, the flag `_initialize_size` is set to `True` after the first layout and so `resizeColumnstoContents` is never called after the first layout..
Looking further into the history of the code snippet, there seems to have been an attempt (#53) to fix this but was reverted as it broke the expected behavior when manually resizing the columns..
IIUC the current behavior of disabling resizing the columns after the initial layout is aimed towards preserving the column widths in case the user manually resized the columns.. Is this right ?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.