enthought / enthought/pyface

Missing update / repaint from data view with RowTableDataModel

Open
#795 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
115
Forks
54
PR merge metrics
No merged PRs in 30d

Description

Using this example: https://github.com/enthought/pyface/blob/e9b7d968f5fbfb239d70c4c1e095e0672aa0b458/examples/data_view/row_table_example.py

If I add a change handler for one of the traits on `Person`, e.g. like this:
```
class Person(HasStrictTraits):

name = Str()

age = Int()

favorite_color = PyfaceColor()

contacted = Bool()

address = Instance(Address, ())

# Added this
@observe("contacted")
def update_age(self, _):
self.age += 1
```

Then when I flip the `contacted` trait on the view, the age value is not updated on the view until I click the view to force a repaint:

![Nov-09-2020 15-23-32](https://user-images.githubusercontent.com/3673984/98560347-9501ce00-229f-11eb-8b7d-bc0054326f38.gif)

System: OSX 10.15
Python: 3.8

Dependencies
```
Package Version Location
---------- ------------ ----------------------------
pip 19.2.3
pyface 7.2.0.dev163 /Users/kchoi/ETS/pyface
Pygments 2.7.2
PySide2 5.15.1
setuptools 41.2.0
shiboken2 5.15.1
traits 6.1.1
traitsui 7.1.0
```

Changing this line:
https://github.com/enthought/pyface/blob/4bccc3e4bba7b7748025b21e08359f446a2abaa7/pyface/data_view/data_models/row_table_data_model.py#L188

To this:
```
self.values_changed = (
(0, ), (), (len(self.data) - 1, ), (len(self.column_data) - 1, )
)
```
seems to fix the problem.

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.