Containers¶
TreeBox
is essentially a urwid.ListBox
that displays a given Tree
.
Per default no decoration is used and the widgets of the tree are simply displayed line by line in
depth first order. TreeBox
’s constructor accepts a focus parameter to specify the initially
focussed position. Internally, it uses a TreeListWalker
to linearize the tree to a list.
TreeListWalker
serve as adapter between Tree
and urwid.ListWalker
APIs:
They implement the ListWalker API using the data from a given Tree in depth-first order.
As such, one can directly pass on a TreeListWalker
to an urwid.ListBox
if one doesn’t want
to use tree-based focus movement or key bindings for collapsing subtrees.
API¶
-
class
urwidtrees.widgets.
TreeBox
(tree, focus=None)[source]¶ A widget that displays a given
Tree
. This is essentially aListBox
with the ability to move the focus based on directions in the Tree and to collapse/expand subtrees if possible.TreeBox interprets left/right as well as page up/`page down to move the focus to parent/first child and next/previous sibling respectively. All other keys are passed to the underlying ListBox.
-
collapse_focussed
()[source]¶ Collapse currently focussed position; works only if the underlying tree allows it.
-
-
class
urwidtrees.widgets.
TreeListWalker
(tree, focus=None)[source]¶ ListWalker to walk through a class:Tree.
This translates a
Tree
into aurwid.ListWalker
that is digestible byurwid.ListBox
. It usesTree.[next|prev]_position
to determine the next/previous position in depth first order.