Browse Source

Added better comments

Mark Mine 22 years ago
parent
commit
b2c27a3348
1 changed files with 10 additions and 0 deletions
  1. 10 0
      direct/src/tkwidgets/Tree.py

+ 10 - 0
direct/src/tkwidgets/Tree.py

@@ -162,6 +162,7 @@ class TreeNode:
         self.canvas.yview_moveto(fraction)
         self.canvas.yview_moveto(fraction)
 
 
     def reveal(self):
     def reveal(self):
+        # Make sure all parent nodes are marked as expanded
         parent = self.parent
         parent = self.parent
         while parent:
         while parent:
             if parent.state == 'collapsed':
             if parent.state == 'collapsed':
@@ -169,7 +170,9 @@ class TreeNode:
                 parent = parent.parent
                 parent = parent.parent
             else:
             else:
                 break
                 break
+        # Redraw tree accordingly
         self.update()
         self.update()
+        # Bring this item into view
         self.view()
         self.view()
 
 
     def lastvisiblechild(self):
     def lastvisiblechild(self):
@@ -329,20 +332,27 @@ class TreeNode:
         self.canvas.focus_set()
         self.canvas.focus_set()
 
 
     def find(self, searchKey):
     def find(self, searchKey):
+        # Search for a node who's key matches the given key
+        # Is it this node
         if searchKey == self.item.GetKey():
         if searchKey == self.item.GetKey():
             return self
             return self
+        # Nope, check the children
         sublist = self.item._GetSubList()
         sublist = self.item._GetSubList()
         for item in sublist:
         for item in sublist:
             key = item.GetKey()
             key = item.GetKey()
+            # Use existing child or create new TreeNode if none exists
             if self.children.has_key(key):
             if self.children.has_key(key):
                 child = self.children[key]
                 child = self.children[key]
             else:
             else:
                 child = TreeNode(self.canvas, self, item, self.menuList)
                 child = TreeNode(self.canvas, self, item, self.menuList)
+                # Update local list of children and keys
                 self.children[key] = child
                 self.children[key] = child
                 self.kidKeys.append(key)
                 self.kidKeys.append(key)
+            # See if node is child (or one of child's descendants)
             retVal = child.find(searchKey)
             retVal = child.find(searchKey)
             if retVal:
             if retVal:
                 return retVal
                 return retVal
+        # Not here
         return None
         return None
 
 
 class TreeItem:
 class TreeItem: