Bug on BlockProperties with extended functions not recognized fixed
authorlbessard
Mon, 19 Jan 2009 17:07:03 +0100
changeset 306 eecc53781498
parent 305 0ed2b61de43e
child 307 fd1f6ae26d4f
Bug on BlockProperties with extended functions not recognized fixed
Dialogs.py
--- a/Dialogs.py	Mon Jan 19 08:21:41 2009 +0100
+++ b/Dialogs.py	Mon Jan 19 17:07:03 2009 +0100
@@ -206,8 +206,13 @@
     def FindTreeItem(self, root, name, inputs = None):
         if root.IsOk():
             pydata = self.TypeTree.GetPyData(root)
-            if inputs and "inputs" in pydata:
-                same_inputs = pydata["inputs"] == inputs
+            type_inputs = pydata.get("inputs", None)
+            type_extension = pydata.get("extension", None)
+            if inputs is not None and type_inputs is not None:
+                if type_extension is not None:
+                    same_inputs = type_inputs == inputs[:type_extension]
+                else:
+                    same_inputs = type_inputs == inputs
             else:
                 same_inputs = True
             if self.TypeTree.GetItemText(root) == name and same_inputs:
@@ -267,7 +272,12 @@
             self.TypeTree.SetPyData(category_item, {"type" : CATEGORY})
             for blocktype in category["list"]:
                 blocktype_item = self.TypeTree.AppendItem(category_item, blocktype["name"])
-                self.TypeTree.SetPyData(blocktype_item, {"type" : BLOCK, "inputs" : tuple([type for name, type, modifier in blocktype["inputs"]])})
+                block_data = {"type" : BLOCK, 
+                              "inputs" : tuple([type for name, type, modifier in blocktype["inputs"]]),
+                              "extension" : None}
+                if blocktype["extensible"]:
+                    block_data["extension"] = len(blocktype["inputs"])
+                self.TypeTree.SetPyData(blocktype_item, block_data)
         if wx.Platform == '__WXMSW__':
             self.TypeTree.Expand(root)