Is done by using (subclasses of) DecoratedTree. Objects of this type wrap around a given Tree and themselves behave like a (possibly altered) tree. Per default, DecoratedTree just passes every method on to its underlying tree. Decoration is done not by overwriting __getitem__, but by offering two additional methods
get_decorated(pos) returns the (decorated) content of the original tree at the given position. decorate(pos, widget,..) decorates the given widget assuming its placed at a given position. The former is trivially based on the latter, Containers that display Tree‘s use get_decorated instead of __getitem__() when working on DecoratedTree‘s.
The reason for this slightly odd design choice is that first it makes it easy to read the original content of a decorated tree: You simply use dtree[pos]. Secondly, this makes it possible to recursively add line decoration when nesting (decorated) Trees.
The module decoration offers a few readily usable DecoratedTree subclasses that implement decoration by indentation, arrow shapes and subtree collapsing: CollapsibleTree, IndentedTree, CollapsibleIndentedTree, ArrowTree and CollapsibleArrowTree. Each can be further customized by constructor parameters.
Decorates the tree by indenting nodes according to their depth and using the gaps to draw arrows indicate the tree structure.
Mixin for Tree that allows to collapse subtrees and use an indicator icon in line decorations. This Mixin adds the ability to construct collapse-icon for a position, indicating its collapse status to CollapseMixin.
Mixin for Tree that allows to collapse subtrees.
This works by overwriting [first|last]_child_position, forcing them to return None if the given position is considered collapsed. We use a (given) callable is_collapsed that accepts positions and returns a boolean to determine which node is considered collapsed.
Arrow-decoration that allows collapsing subtrees
Indent collapsible tree nodes according to their depth in the tree and display icons indicating collapse-status in the gaps.
Undecorated Tree that allows to collapse subtrees
Tree that wraps around another Tree and allows to read original content as well as decorated versions thereof.
decorate widget according to a position pos in the original tree. setting is_first to False indicates that we are decorating a line that is part of the (multi-line) content at this position, but not the first part. This allows to omit incoming arrow heads for example.