ENH: Provides control on item enability and selectability for DataView#1023
ENH: Provides control on item enability and selectability for DataView#1023
Conversation
corranwebster
left a comment
There was a problem hiding this comment.
Thanks for the contribution. I don't think this is the right implementation of this, unfortunately.
We don't want the abstract data model growing additional features, particularly things which are directly related to display and interaction. This really belongs in the display layer, but we didn't get that implemented. At it's core you should be able to have two views of the same underlying data with different enabled/selected behaviour.
So in the current design, where it belongs is in the ValueType. I would not be opposed to having the value type grow attributes for being editable and selectable, with the understanding that that might change in the future. The behaviour and code should likely look an awful lot like the code for handling editability.
Also, needs tests!
|
Secondary question - we already have a mechanism to make cells not editable: that presumably doesn't handle your immediate need? |
|
Thanks for having a look!
Sure, I hesitated to do put this in
Ahah sure! I forgot to make this PR a draft, it is done now.
For my use case, I want a visual feedback and having the item non selectable. The idea is to show to the user that the item is temporarily disabled, following an action she/he did on it that typically takes a few seconds. |
@corranwebster I am good with moving that code to |
Hi there! This microscopic PR is intended to provide ways to control if cells in a table rendered with
DataViewcan be selected or disabled., via new methods added todata_view.AbstractDataModel.The primary need I'd like to answer with this PR is to offer the possibility to disable cells, or make them non-selectable, depending on some conditions in the underlying data. This is useful, for instance, to prevent interactions with some data items while they are used elsewhere. Feel free to close this PR if you have a better idea to tackle this!
Example
In
pyface.examples.data_view.row_table_example, if you subclass the data model to implementis_enabledlike this:and pass it to the data view widget, you should see this: