Skip to main content

Add your description here

Project description

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

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

with_coordination-0.0.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

with_coordination-0.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file with_coordination-0.0.0.tar.gz.

File metadata

  • Download URL: with_coordination-0.0.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for with_coordination-0.0.0.tar.gz
Algorithm Hash digest
SHA256 dcce335bfde14530c54f4ea1a218d3aebce44d7f4de4dc5355129a842cee70b4
MD5 4f5f091240715d5c2c518c1b5ac96341
BLAKE2b-256 4f29d499ff68278721555899b1c595376e7873686dad196c7f64687ca5d9edc8

See more details on using hashes here.

File details

Details for the file with_coordination-0.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for with_coordination-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd815f45a597512ccbc8f001d4b416ddbb0cd4c5fbd4442b7e42251b7505f23c
MD5 350cef7117ba9330366fb9ec1cccee52
BLAKE2b-256 62149164751728469b49d7c92d2372bcc830ca1243abbb466cd27925afdaa612

See more details on using hashes here.

Supported by

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