python urwidtrees deleting a SimpleTree node throws exception

27 Views Asked by At

I'm working on an app that will add or remove nodes in a TreeDisplay during runtime by user input. I have encountered an issue where removing a child node will throw an exception and crash the app. This only happens if the child is focused and "next_sibling_position" is None

for simplicity I will reference the example included in urwidtrees git repo. I found documentation in example6.append.py for adding to the tree but I cannot find any documentation on the proper way to delete a node from the tree.

from the repo -> https://github.com/pazz/urwidtrees/tree/master/docs/examples

referencing "example3.collapse.py"

removing "Grand Grandchild 1" while it is focused causes an exception.

removing "Grand Grandchild 0" while it is focused does not cause an exception

at the treebox object level:

# TreeBox.CollapsibleIndentedTree.SimpleTree.List
tl = self._tree._tree._treelist
child_list = tl[0][1][0][1][0][1]
grand_grandchild0 = child_list[0]
grand_grandchild1 = child_list[1]
# child_list.remove(grand_grandchild0)  # works
# child_list.remove(grand_grandchild1)  # crashes program if grand_grandchild1 is focused but otherwise works
self.refresh()

thank you

0

There are 0 best solutions below