python urwidtrees删除SimpleTree节点引发异常

问题描述

我正在开发一个应用程序,该应用程序将在运行时通过用户输入在 Treedisplay 中添加删除节点。我遇到了删除子节点会引发异常并使应用程序崩溃的问题。这只发生在孩子专注并且“next_sibling_position”是 None

为简单起见,我将引用 urwidtrees git repo 中包含的示例。我在 example6.append.py 中找到了用于添加到树中的文档,但找不到任何关于从树中删除节点的正确方法的文档。

来自 repo -> https://github.com/pazz/urwidtrees/tree/master/docs/examples

引用“example3.collapse.py”

在聚焦时移除“Grand Grandchild 1”会导致异常。

在聚焦时移除“Grand Grandchild 0”不会导致异常

在树箱对象级别:

# 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()

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)