enthought / enthought/traitsui

Make EditorFactory class traits settable to make new editor creation easier

Open
#1,521 0 comments 0 reactions 0 assignees View on GitHub
component: core difficulty: intermediate type: enhancement
Dominant language
Python
Stars
306
Forks
99
PR merge metrics
No merged PRs in 30d

Description

In the case where you want to subclass an Editor or otherwise provide an alternative that changes the behaviour of the default editors, you currently need to also subclass the corresponding EditorFactory to replace the editor types with the new Editor(s). The easiest way of doing this where you don't need to worry about cross-platform compatibility is by overriding the values of these traits:
https://github.com/enthought/traitsui/blob/23f17d1a5b725d5388abd5cbcd98d8a614913a03/traitsui/editor_factory.py#L67-L77

However, these properties are not settable, so you do need to subclass, instead of doing something like:
```
Item('foo', editor=TextEditor(simple_editor_class=MyBetterEditor))
```
Indeed, it may be that the best way to do this is to make the traits regular `Type` traits, and the current getter a _default_.

Now in many cases you will likely want a new factory subclass in any case because there are likely to be new factory parameters that you want to convey, but for simple cases, being able to do this would seem advantageous.

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.