> I was wondering whether I could have an Instance be a child of a root
> TreeNode (instead of a list).
> class Root(HasTraits):
> child1 = Instance(Child1)
> child2 = Instance(Child2)
> Child itself has a List and other stuff that displays fine in a tree.
> Normally I would create a TreeNode with children='child1' but it
> expects a list. I want to create the following tree from this:
> +- child1
> +- child2
> How could I do this? Please let me know if my question isn't clear.
You could put child1 into a child1list=List(Instance(child1))and
similarly for child2. They would just be lists of only one item.
Then you could use
I've come upon the same issue. I don't want to modify a model to put an Instance in a List-of-one just for the TreeEditor, especially since I've gone through a lot of trouble to keep the model and view code very separate. For a very brief moment, I looked at creating a TreeNodeInstance class (or something) that allowed for such cases but realized I don't have the time to invest in even finding out if a hack like that would work.
Any chance Enthought has considered adding an option for this case?