Skip to main content

with-coordination

declarative coordinated multiple views for Jupyter Widgets

pip install with-coordination

usage

import ipywidgets

# create a set of widgets
slider1 = ipywidgets.FloatSlider(description='Slider 1')
slider2 = ipywidgets.FloatSlider(description='Slider 2')
slider3 = ipywidgets.FloatSlider(description='Slider 3')

# prepare an output area with arrangement of widgets
ipywidgets.VBox([slider1, slider2, slider3])
from with_coordination import Coordination

# create a coordination context
with Coordination() as c:

  # define a coordination type
  with c.type("sliderValue") as t:

    # add a scope with a set of widgets
    with t.scope("A", 10) as s:
      # alias maps the widget prop to the coordination type if they are different
      s.view(slider1, alias="value")

    with t.scope("B", 4.0) as s:
      s.view(slider2, alias="value")
      s.view(slider3, alias="value")


  # get the coordination configuration as json
  print(c.to_json()) # b'{"coordinationSpace":{"sliderValue":{"A":10,"B":4.0}},"viewCoordination":{"view_0": ...'

Alternatively, you can use use an existing configuration to create a coordination context.

with open("config.json", "w") as f:
  f.write("""
  {
    "key": 1,
    "coordinationSpace": { "sliderValue": { "A": 0.5, "B": 0.75 } },
    "viewCoordination": {
      "slider1": { "coordinationScopes": { "sliderValue": "A" } },
      "slider2": { "coordinationScopes": { "sliderValue": "B" } },
      "slider3": { "coordinationScopes": { "sliderValue": "B" } }
    }
  }
  """)

with Coordination("config.json") as c:
    c.use_widget(slider1, view_id="slider1", aliases={"value": "sliderValue"})
    c.use_widget(slider2, view_id="slider2", aliases={"value": "sliderValue"})
    c.use_widget(slider3, view_id="slider3", aliases={"value": "sliderValue"})

why

Managing coordinated multiple views is a complex task. This library provides an ergonomic and declarative API to specify how widgets traits should be coordinated.

with-coordination is based on the declarative JSON coordination specification from use-coordination and is designed to work with anywidget.

development

this project is managed using rye.

rye run jupyter lab

rye manages testing, linting, and formatting.

rye test
rye lint
rye format

alternatively you can create a virtual environment and use an development installation. You will need to install jupyterlab.

python -m venv .venv
source .venv/bin/activate
pip install -e .
pip install jupyterlab
jupyter lab

Metadata

Release files for with-coordination 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for with-coordination 0.0.1
File Size Uploaded
with_coordination-0.0.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for with-coordination 0.0.1
File Interpreter ABI Platform
with_coordination-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / with_coordination-0.0.1.tar.gz

Download URL with_coordination-0.0.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
19df2c4c6253a03c46abbb3c929a896af4bba092a43d4f6028503caf6f111520
BLAKE2b-256 checksum
How to use checksums
8446a854d3a196008c2d39fae210253bd0e40c234bcf9df6b12bc39c6eb55649
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / with_coordination-0.0.1-py3-none-any.whl

Download URL with_coordination-0.0.1-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31bfa68d184419c2025f3739ac3be53c1eaa57e98ffd76bc4f9c1d3d64077c54
BLAKE2b-256 checksum
How to use checksums
0404420eb6257697477cc26f14f90deb0a54062cbb39dd11e51f397ba360e32a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page