ipytree

0.2.2 · active · verified Thu Apr 16

ipytree is a Python library that provides an interactive Tree Widget for Jupyter environments, built using the Jupyter-widgets protocol and jsTree. It offers an easy-to-use interface to visualize and manipulate hierarchical data structures directly within Jupyter Notebooks and JupyterLab, and can be seamlessly integrated with other `ipywidgets` components.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to create a basic hierarchical tree structure using `ipytree.Tree` and `ipytree.Node` objects, and then display it in a Jupyter environment. Nodes can be added and nested to form complex structures.

from ipytree import Tree, Node

# Create a root node
root_node = Node('Root')

# Add child nodes
child1 = Node('Child 1')
child2 = Node('Child 2')
root_node.add_node(child1)
root_node.add_node(child2)

# Add a nested node
sub_child = Node('Sub Child')
child1.add_node(sub_child)

# Create the tree widget and add the root node
tree = Tree(nodes=[root_node])

# Display the tree
tree

view raw JSON →