Created
July 29, 2014 21:06
-
-
Save ericdill/0a84c22be978e1435cab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_root(self, node): | |
""" | |
find the node whose parent is the invisible root item | |
Parameters | |
---------- | |
node : QtGui.QTreeWidgetItem | |
The node whose top level parent you wish to find | |
Returns | |
------- | |
path_to_node : list | |
list of keys | |
node : | |
""" | |
node =QtGui.QTreeWidgetItem() | |
node.text(0) | |
path_to_node = [] | |
while node.parent() != self.invisibleRootItem(): | |
path_to_node.insert(0, node.text(0)) | |
node = node.parent() | |
# return the node once you find it | |
return node |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment