Skip to content

Instantly share code, notes, and snippets.

@ericdill
Created July 29, 2014 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericdill/0a84c22be978e1435cab to your computer and use it in GitHub Desktop.
Save ericdill/0a84c22be978e1435cab to your computer and use it in GitHub Desktop.
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