5 Sep 21:39
[Traits] dirty trait metadata
From: Prabhu Ramachandran <prabhu@...>
Subject: [Traits] dirty trait metadata
Newsgroups: gmane.comp.python.enthought.devel
Date: 2008-09-05 19:43:36 GMT
Subject: [Traits] dirty trait metadata
Newsgroups: gmane.comp.python.enthought.devel
Date: 2008-09-05 19:43:36 GMT
Hi,
Consider the following:
-----------------
from numpy import *
from enthought.traits.api import *
class Data(HasTraits):
x = Array
def _x_changed(self, value):
print value
x = linspace(0, 1)
d = Data(x=x)
-------------------
Now I'd like to always call _x_changed when the x trait is set. Thus,
I'd like this to work:
x *= 2
d.x = x # Should call _x_changed
Is there a simple way of doing this? I know that I could achieve this
if I implemented x as a Property(Array) but is there an easier way?
Thanks.
prabhu
Done in 1682.
Thanks!
cheers,
prabhu
RSS Feed