#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    62
    Rep Power
    10

    Thumbs up Expand all branches TreeCtrl


    Anyone knows how can I expand all branches for a given Tree?
    I got:
    Code:
    _treeList = [
    	( 'Parent1', ['Child1_1','Child1_2'] ),
    	( 'Parent2', [] ),
    	( 'Parent3', [ 'Child3_1', 'Child3_2',	'Child3_3'] )
    	]
    root = self.tree.AddRoot("root")
    
    # Then I make the Tree with this for loop:
    for item in _treeList:
    	child = self.tree.AppendItem(root, item[0])
    	for childItem in item[1]:
    		self.tree.AppendItem(child, childItem)
    self.tree.Expand(root)
    But only root is expanded and none of the parents. Someone do know how this can be done?
    Thanks
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    155
    Only root is getting expanded because you only have it set to expand root, and that itself only cocurs once. Can you not run a for loop and expand each item in the list separately?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    62
    Rep Power
    10
    Well, i fixed it. I've just printed some usefull data within the loop and began to learn more about how it worked.

    This is the code:
    Code:
    root = self.tree.AddRoot("Bienvenido")
    print "root es",root
    # Creo el menu de arbol
    for item in _treeList:
    	child = self.tree.AppendItem(root, item[0])
    	print "item[0] is parent",item[0]
    	print "item[1] is the list",item[1]
    	print "child is",child
    	for childItem in item[1]:
    		childson = self.tree.AppendItem(child, childItem)
    		print "childson is",childson
    		self.tree.Expand(childson)
    	self.tree.Expand(child)
    self.tree.Expand(root)
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    62
    Rep Power
    10
    Expand childson is not really needed, but could be eventually in a modified _treeList...

IMN logo majestic logo threadwatch logo seochat tools logo