I wrote a custom trait (basically it handles units). Here is the
def validate(self, object, name, value):
# Convert the value to the SI unit
value, self.unit = unitconvert(value, self.siunit)
# Validate the quantity
value = super(MyTrait, self).validate(object, name, value)
self.error(object, name, value)
The class is called with the additional keyword 'siunit', eg.
MyTraits(siunit='m'). So far everything works like expected and
Now I want to overwrite create_editor() to make the following editor:
|input| |value| |self.siunit|
|input| is the input field.
|value| is the return value of validate (the quantity converted into SI
units). The widget should be read only.
|self.siunit| displays the SI unit associated with the trait
(self.siunit) and is read only.
I came up with something like this:
editors = [super(MyTrait, self).create_editor(),
Which looks ugly and does not display the SI unit.
I trawled the Net and the documentation but could not find anything
appropriate to learn from it. Can anybody point me in the right