awitree
A simple interface to jstree with AnyWidget that can be used in both Jupyter Notebook and Marimo
Installation
pip install git+https://github.com/srirampc/awitree.git
The environment.yml provides a simple conda environment
to create an environment with awitree installed.
Usage
To create a tree, a python dictionary is provided to the constructor with the expected format specified for jstree given in jstree documentation.
# Expected format of the node (there are no required fields)
{
id : "string" # will be autogenerated if omitted
text : "string" # node text
icon : "string" # string for custom
state : {
opened : bool # is the node open
disabled : bool # is the node disabled
selected : bool # is the node selected
},
children : [] # array of strings or objects
li_attr : {} # attributes for the generated LI node
a_attr : {} # attributes for the generated A node
}
This python dictionary is passed to the javascript as a JSON object, which is then rendered by jstree.
tree_data = {
"id": "0",
"text":"Main Root",
"state": {"open" : True},
"children" : [
{"id": "1", "text" : "Sub Node 1", "children":[]},
{"id": "2", "text" : "Sub Node 2", "children":[]},
{"id": "3", "text" : "Sub Node 3", "children":[]},
]
}
rtree = awit.Tree(data=tree_data)
See notebooks/example.ipynb for jupyter notebook example and notebooks/marimo_example.py for a marimo example.
Development
Create and manage your own virtual environment:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
jupyter lab notebooks/example.ipynb
The widget front-end code bundles it's JavaScript dependencies. After setting up Python, make sure to install these dependencies locally:
npm install
While developing, you can run the following in a separate terminal to automatically rebuild JavaScript as you make changes:
npm run dev
Release files for awitree 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| awitree-0.1.0.tar.gz | 86.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| awitree-0.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 172.6 kB
Release files / awitree-0.1.0.tar.gz
| Download URL | awitree-0.1.0.tar.gz |
|---|---|
| Size | 86.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
459c8f555207683e547dc90104d14646642760f9634236ae050043eda4ddbac2
|
|
BLAKE2b-256 checksum How to use checksums |
4002fb60387946a85de360377b96fb479488cea624fecc7b6286a23af73579e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.14
|
Release files / awitree-0.1.0-py2.py3-none-any.whl
| Download URL | awitree-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 86.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c4d0a517446345ed7fe6610bbf0796d8f443db0b013d82c9b1d3d185542fdbb9
|
|
BLAKE2b-256 checksum How to use checksums |
46100b6f79a7f44fa82abc59b624c1b0988b2775dd9293ffdb342374e2c33dbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.14
|