I have a treectrl structure which is populated from an external search of an open data set hosted by our municipal government. The data pertains to business licenses and is requested using Pandas and Sodapy. The tree is populated as follows:
for index, row in results_df.iterrows(): tradename = row['tradename'] address = row['address'] licTypes = row['licencetypes'] comm = row['comdistnm'] jobSts = row['jobstatusdesc'] jobCrt = row['jobcreated'] lng = row['longitude'] lng = str(lng) lat = row['latitude'] lat = str(lat) # Populate Tree Controls with DataFrame values trdName = self.thrTree.AppendItem(root, tradename) self.thrTree.AppendItem(trdName, address) self.thrTree.AppendItem(trdName, licTypes) self.thrTree.AppendItem(trdName, comm) self.thrTree.AppendItem(trdName, jobSts) self.thrTree.AppendItem(trdName, jobCrt) self.thrTree.AppendItem(trdName, lng) self.thrTree.AppendItem(trdName, lat)
This will result in a final structure of root, then node 1 with business name, and when expanded, contains all the information listed above, so I'm assuming root level, then child node 1, then child.child of node 1? Not even sure how the second second indented nodes are called. (I've heard the term leaf for the third level used before) But I digress; what I am interested in is grabbing the Latitude and Longitude of where the business is located, then allowing the user to map the location if they choose. I bind a wx.EVT_TREE_ITEM_ACTIVATED so that when the user double clicks on a business name to get the details, I want to grab the items displayed. This is how I am currently trying to iterate through the child nodes.
item = self.thrTree.GetSelection() while self.thrTree.GetItemParent(item): piece = self.thrTree.GetItemText(item) tmpHldr.insert(0, piece) item = self.thrTree.GetItemParent(item)
Looking at item, it appears to be collecting all the business names under root, and ignoring the third level items of interest.
What do I need to do to go deeper within the tree to grab the details under the business clicked on, and not just the list of business names under the root item, which is called 'Search Results'?