data driven TraitsUI

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

data driven TraitsUI

Gene Kang
I'm wondering if there are any simple examples on developing a TraitsUI application that can be configured from the contents of a file.  For example, a simple list drop-down selection box that's populated from a list specified in a text file.   Thanks!
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: data driven TraitsUI

Robert Kern
On Sat, Feb 13, 2010 at 15:02, Gene Kang <[hidden email]> wrote:
> I'm wondering if there are any simple examples on developing a TraitsUI application that can be configured from the contents of a file.  For example, a simple list drop-down selection box that's populated from a list specified in a text file.   Thanks!

I don't think we have an example of that, but it shouldn't be too hard
to do. There are a couple of ways to do it. For your case, the easiest
way is to use an Enum(values='some_other_trait') trait where
"some_other_trait" is the name of a List trait containing the
available items. Construct your object with a list pulled from your
configuration file, then call .configure_trait() on the object.

More generally, though, you may need to construct your View
dynamically. This is reasonably easy to do. Just define a
.default_traits_view() method on your class. It should return a View()
instance. You can build up the *args, **kwds for constructing the
View() however you like in that method.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev