1

I am trying to use traitsui.api.ValueEditor to create a tree view for a dictionary:

class my_editor(HasTraits):
      x = Any   
      traits_view = View(Item('x', editor = ValueEditor()))

a = my_editor(x = my_dict)
a.configure_traits()

And the output looks like:

enter image description here

And I would like to hide the items '_listener_traits', '_sync_trait_' and '_traits_listener_', which start as underscore character _. In this way the tree viewer will only display d, designator, mat_name, material, modeltree and name.

After looking up the source code of ValueEditor, I guess editing the TreeEditor, RootNode or value_tree_nodes might customize which traits to be viewed? Is this the right way and which should I edit specifically to customize the ValueEditor?

Evelyn Liu
  • 21
  • 4
  • I've looked this over pretty seriously now and I too can't figure it out. With all of the abstractions between the _ValueTree, _ValueEditor, ValueEditor, TreeEditor etc..., I can't see how to every access the `get_children_nodes()` that one would have to overwrite to acoomplish this. I made us a dirty hack that overloads the value at runtime (monkeypatching), but means we will only be able to use this once, so any time this editor is called, it will always look this way. It's ok, for now we'll just screen out private traits, and any traits that aren't array, int or float. – Adam Hughes Jan 27 '15 at 22:46

0 Answers0