Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awitree-0.1.0.tar.gz (86.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

awitree-0.1.0-py2.py3-none-any.whl (86.5 kB view details)

Uploaded Python 2Python 3

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

Hashes for awitree-0.1.0.tar.gz
Algorithm Hash digest
SHA256 459c8f555207683e547dc90104d14646642760f9634236ae050043eda4ddbac2
MD5 1bd78fcd61165f4cf32d8807c202c5cf
BLAKE2b-256 4002fb60387946a85de360377b96fb479488cea624fecc7b6286a23af73579e6

See more details on using hashes here.

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

Hashes for awitree-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c4d0a517446345ed7fe6610bbf0796d8f443db0b013d82c9b1d3d185542fdbb9
MD5 6c1432f916d72b4d5a12fa843ef5345c
BLAKE2b-256 46100b6f79a7f44fa82abc59b624c1b0988b2775dd9293ffdb342374e2c33dbf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page