How to specify dynamic candidate list for Trait UI

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to specify dynamic candidate list for Trait UI

Des.P
I want my Traits UIs to help edit / maintain constrained relationships between objects.

If I have:

class A: pass

class B (HasTraits):
        # initialized with list of As
        def __init__(self, listOfAs):
                self.aList = listOfAs

        # has "it" attribute which must be from that list
        it = Instance(A)

        def _candidatesFor_it():
                return self.aList

a1 = A()
a2 = A()
a3 = A()
a4 = A()

b = B([a1, a2, a4])

b.configure_traits()

Is there a way to tell TraitUI to use _candidatesFor_it to build a selection list for the "one" attribute?

Thanks!
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev