enthought / enthought/traitsui
ListStrEditor (and TabularEditor) does not refresh if Button object adds new row
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
### EDM Env:
runtime = `cpython 3.6.9+2 osx_x86_64 darwin`
```
appdirs==1.4.3
distribute-remove==1.0.0
icu4c==50.2
libjpeg==7.0
libpng==1.6.36
packaging==16.8
pyface==7.0.0
Pygments==2.2.0
pyparsing==2.2.0
PyQt5==5.14.2
PyQt5-sip==12.7.2
Qt==5.12.6
six==1.11.0
traits==6.0.0
traitsui==7.0.0
```
### Description:
When using a `ListStrEditor` to display items in a list, in combination with a `Button` that appends new items to the list, the UI does not refresh correctly if the button is pressed whilst an item is selected. The UI displays the expected behavior only if an item is not selected.

The new items are appended correctly to the list object and they can be selected, so it seems as if the table is not repainted correctly following the update.
It is worth noting that the same behavior can also be observed when using a `TabularEditor` that displays a list of `HasTraits` classes as table rows, even when assigning the `update` or `refresh` traits. Therefore the inclusion of an `update` event in the `ListStrEditor` as suggested in #511 may not resolve this issue.
It is possible that this could be a Qt issue (maybe related to #791), but I have tried to test using a Wx backend (`wxPython==4.1.0`, just by putting `import wx` in the imports) and I observe the same behavior.
### Code stub:
```python
from traits.api import HasTraits, List, Button
from traitsui.api import View, UItem, Label, ListStrEditor
class MyListView(HasTraits):
add = Button()
rows = List()
def default_traits_view(self):
list_str_editor = ListStrEditor()
return View(
Label('List'),
UItem('add'),
UItem("rows", editor=list_str_editor),
resizable=True,
)
def _add_changed(self):
self.rows.append(0)
if __name__=='__main__':
rows = [1, 2]
my_list = MyListView(rows=rows)
my_list.configure_traits()
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.