from traits.api import List, HasTraits
class Foo(HasTraits):
x = List
def _x_items_changed(self,new):
print new.added
f = Foo()
f.x = [1,3]
f.x.append(9) #handler reacts!
f.x += [9,10] # handler does not react! Why?
What am I missing here?
Thanks!
It's a bug. TraitListObject overrides extend() and other mutating methods to propagate changes, but __iadd__() was overlooked. The workaround is to use extend() instead of +=.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With