폴더 구조를 나타 내기 위해 TreeCtrl을 사용하려고합니다. 각 폴더마다 절대 경로와 이름을 알아야합니다. 현재 다음과 같은 작업을하고 있습니다.wx.TreeCtrl item
self.root = self.tree.AddRoot(project.name)
self.tree.SetPyData(self.root, None)
self.root.path = root
---- other code -----
childItem = self.tree.AppendItem(self.root, child.name)
childItem.path = self.root.path + "/" + child.name
하지만 이제 이벤트에서 경로 문자열을 가져와야합니다. 실패 지금까지 나의 접근 방식은 다음과 같습니다 AttributeError가 : 'TreeItemId'개체가 어떤 속성 '경로'가 없기 때문에
self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded, self.tree)
----- other code -------
def OnItemExpanded(self, evt):
selected = evt.GetItem()
print selected.path
지금이 실패합니다. 여기에서 이해할 수있는 것에서 만 이벤트는 "childItem = self.tree.AppendItem (self.root, child.name)"의 실제 항목이 아닌 트리의 Item에 ID를 제공합니다. 그렇다면 어떻게 그 품목에 갈 수 있습니까?
관련, 보그
는
경로는 대답을 주셔서 감사합니다 뭔가 난'의 만드는 – Bogdan