No project description provided
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file awitree-0.1.0.tar.gz.
File metadata
- Download URL: awitree-0.1.0.tar.gz
- Upload date:
- Size: 86.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
459c8f555207683e547dc90104d14646642760f9634236ae050043eda4ddbac2
|
|
| MD5 |
1bd78fcd61165f4cf32d8807c202c5cf
|
|
| BLAKE2b-256 |
4002fb60387946a85de360377b96fb479488cea624fecc7b6286a23af73579e6
|
File details
Details for the file awitree-0.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: awitree-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 86.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4d0a517446345ed7fe6610bbf0796d8f443db0b013d82c9b1d3d185542fdbb9
|
|
| MD5 |
6c1432f916d72b4d5a12fa843ef5345c
|
|
| BLAKE2b-256 |
46100b6f79a7f44fa82abc59b624c1b0988b2775dd9293ffdb342374e2c33dbf
|