enthought / enthought/traitsui

Fix handling of extended names and sync traits in DataFrameEditor (possibly TabularEditor)

Open
#553 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Python
Stars
306
Forks
99
PR merge metrics
No merged PRs in 30d

Description

Using the DataFrameEditor's sync traits (`selected`, `dclicked`, etc) will not work when used in conjunction with extended name syntax for the object being edited.

```python
class MyModel(HasTraits):

data = Instance(pd.DataFrame)

def __init__(self, **traits):
HasTraits.__init__(self, **traits)
self.data = pd.DataFrame(data={'col1': [1, 2], 'col2': [3, 4]})

class MyView(HasTraits):

model = Instance(MyModel)
dclicked_record = Event

view = View(Item('object.model.data',
editor=DataFrameEditor(dclicked='dclicked_record')))

def _dclicked_record_fired(self, new):
print('The syncing works!') # LIES!

if __name__ == "__main__":
MyView(model=MyModel()).configure_traits()
```

If we instead create a `data` trait that `DelegatesTo('model')` and adjust the view to `Item('data')`, the event handler lights up. Note that the extended name syntax works insofar as properly displaying the data, just the sync traits machinery seems to be broken.

(This is on Python 3 and using a Qt backend).

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.