enthought / enthought/traitsui
Consolidate common editor code in the base editor class
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
This is an issue to capture some of the reasoning for #1493 and related code clean-up around the editor classes.
Looking at the code for the qt and the wx editor classes, there is a lot of shared code. Some of this should be moved into the common base class. This includes:
- [ ] almost all the tooltip code (other than the code which sets the tooltip on the actual widget). See #1493
- [ ] error handling:
- [ ] `get_error_control` and `in_error_state` should but shifted to the base class.
- [ ] `error` should be re-implemented in a toolkit-independent way on the base class using Pyface's message dialog.
- [ ] `set_error_state` should be at least an abstract method, but might be able to be implemented by having the toolkit provide methods for getting and setting widget background colours and lifting the common logic up to the base class.
- [ ] listeners for `invalid` and `control` should be on the base class as their code is toolkit independent.
- [ ] listeners for `enabled` and `visible` should be on the base class, but call-out to methods implemented on the toolkit with the actual logic (which is non-trivial toolkit-specific due to issues with layout management).
- [ ] `EditorWithList` and `EditorWithView` are identical between toolkits; there should be toolkit independent base classes/mixins for these, with stub toolkit-classes that inherit from the toolkit editor and the mixin and do nothing else. A later refactor could remove the toolkit classes, and just use the mixins directly in editors which need it.
Additionally, Qt has some code for performing actions which is only used by the table editor, but is toolkit-independent and seems fairly generic. It may make sense to lift this code to the base class if it can be used more generally, otherwise it should probably be pushed down to the table editor where it is actually used.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.