On 28/03/2012 3:40 a.m., Thomas Wiecki wrote:
> Hi,
>
> I was wondering whether I could have an Instance be a child of a root
> TreeNode (instead of a list).
>
> E.g.:
>
> 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:
>
> Root
> +- 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
TreeNode(
node_for = [ parent],
children='child1list',
label='treename',
menu=Menu(....),
view=View(....),
add=[child1],
),
TreeNode(
node_for=[child1],
children='child1offspringlist',
label='treename',
menu=Menu(....),
view=View(....),
add=[child1offspring],
),
etc etc.
where treename is a Property or Str in each HasTraits object that
provides the name you want to see for that node in the tree.
Does this help?
Brennan
> Thanks,
> Thomas
> _______________________________________________
> Enthought-Dev mailing list
>
[hidden email]
>
https://mail.enthought.com/mailman/listinfo/enthought-dev>
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev