Hi All,
I am using the following code to populate a tree control. The dictionary currently I am using is ‘dictFolders’ and its structure is defined below.
lstFolders=[]
lstFolders = ["A","B","C","D"]
dictFolders={}
dictFolders = {"A":["Obj1","Obj2","Obj3","Obj4","Obj5","Obj6","Obj7","Obj8","Obj9"],
"B":["Doc1","Doc2","Doc3","Doc4","Doc5","Doc6","Doc7","Doc8","Doc9"],
"C":["Link1","Link2","Link3","Link4","Link5","Link6"],
"D":["Obj1","Obj2","Obj3","Obj4","Obj5","Obj6","Obj7"]}
# Setting the root node text to the Action ID entered
self.treeAction.SetItemText(self.treeAction.GetRootItem(),”Parent Folder Name”)
# Loop to Populate the tree containing Action Objects
print "length of dictFolders=", len(dictFolders)
for intIndex in range (0,len(dictFolders)):
#If tree control does not have any children then append Items
if self.treeAction.ItemHasChildren(nodeFolders[intIndex])==False:
for intiLoopIndex in range (0,len(dictFolders[lstFolders[intIndex]])):
self.treeAction.AppendItem(nodeFolders[intIndex],(dictFolders[lstFolders[intIndex]][intiLoopIndex]))
self.treeAction.ExpandAllChildren(nodeFolders[intIndex])
# Collapsing all children after populating
for intIndex in range(0,len(dictFolders.keys())):
self.treeAction.CollapseAllChildren(nodeFolders[intIndex])
Now I want to implement the same with a new dictionary whose structure is given below:
dictFoldersNew = {"A":{"XYZ": [["Name1", "UID1"], ["Name2", "UID2"]],
"PLM": [["Number1", "UUID1"], ["Number2", "UID2"]],
"RST": [["ID1", "UUID1"], ["ID2", "UID2"]]},
"B": [["IDB1", "UID1"], ["IDB2", "UID2"]],
"C": [["IDC1", "UID1"], ["IDC2", "UID2"]],
"D": [["IDD1", "UID1"], ["IDD2", "UID2"]]}
I want a second level of folders under A and the rest of the structure should remain the same. Under XYZ, PLM and RST I want to display UID1,Number1 and ID1 respectively. And under B,C and D, I want to display (IDB1,IDB2),( IDC1,IDC2). IDD1,IDD2) respectively.
How can I do this?... Presently I am unable to understand the new dictionary format.
Any help is much appreciated.
Regards,
Dinil