Skip to main content

anywidget for embedding metaframe URLs in Jupyter and marimo notebooks

Project description

metaframe-widget

An anywidget for embedding metaframe and metapage URLs in Jupyter and marimo notebooks.

Install

pip install metaframe-widget

With environment extras:

pip install "metaframe-widget[jupyter]"   # includes jupyterlab
pip install "metaframe-widget[marimo]"    # includes marimo

Quick start

Jupyter

from metaframe_widget import MetaframeWidget

w = MetaframeWidget(url="https://framejs.io/#?js=...", height="300px")
w

marimo

import marimo as mo
from metaframe_widget import MetaframeWidget

w = MetaframeWidget(url="https://framejs.io/#?js=...", height="300px")
mo.ui.anywidget(w)

A widget is always created from a URL. To embed your own code, build and save it at framejs.io — the editor mints a short URL you can paste into url=. The URL is the portable, saveable form of a metaframe; the code itself lives behind it rather than being inlined in your notebook.

URL forms

Any of these work as url=:

# Raw / full URL — the code is inlined in the hash (can get very long)
MetaframeWidget(url="https://framejs.io/#?js=...")

# Expiring snapshot — content-addressed, kept ~30 days, then garbage-collected
# (editor: "Create expiring snapshot")
MetaframeWidget(url="https://framejs.io/j/<sha256>")

# Durable, editable frame — permanent, tied to your account (editor: "Save")
# framejs.io/j/<uuid> and framejs.app/j/<uuid> resolve to the same frame
MetaframeWidget(url="https://framejs.io/j/<uuid>")

Prefer the durable /j/<uuid> form in notebooks you keep. See Short URLs for the full comparison.

API reference

Parameter Type Default Description
url str "" Full metaframe URL (including hash params)
inputs dict {} Dict of inputs to push to the metaframe
outputs dict {} Dict of outputs received from the metaframe (read-only)
width str "100%" CSS width for the widget container
height str "400px" CSS height for the widget container
allow str "" iframe allow attribute (e.g. "camera; microphone")

Methods

  • set_inputs(d) — merge a dict into current inputs
  • set_input(key, value) — set a single input key
  • on_outputs_change(callback) — register a callback for output changes
  • on_saved_url_change(callback) — register a callback for when the user creates an expiring snapshot (/j/<sha256>) inside the widget
  • pipe_to(target, output_key, input_key=None) — connect an output to another widget's input

Piping widgets

source = MetaframeWidget(url="...")
sink = MetaframeWidget(url="...")
source.pipe_to(sink, output_key="result", input_key="data")

Links

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

metaframe_widget-0.3.12.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

metaframe_widget-0.3.12-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file metaframe_widget-0.3.12.tar.gz.

File metadata

  • Download URL: metaframe_widget-0.3.12.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for metaframe_widget-0.3.12.tar.gz
Algorithm Hash digest
SHA256 46c44853ab3244ceadc2d5af09d10c6a989e7d606630fe300be36a0ac426e858
MD5 64f962367a5c8545079641edbaa57d48
BLAKE2b-256 1d5987e11bdd4b3191432a32b55b19f3b8c9bae7d573bc720c8d30d9e20718bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaframe_widget-0.3.12.tar.gz:

Publisher: publish-python.yml on metapages/framejs.io

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file metaframe_widget-0.3.12-py3-none-any.whl.

File metadata

File hashes

Hashes for metaframe_widget-0.3.12-py3-none-any.whl
Algorithm Hash digest
SHA256 70b62b468940799c971c595fbe9d3505b772ca5b62385310b40c508a9670566e
MD5 1b899e013bcd74e162be27395c016dda
BLAKE2b-256 5b7a135f211deb1730cbc407a0b8e8dc42f6ab0848c2dd6f70ce57bb806d7bb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaframe_widget-0.3.12-py3-none-any.whl:

Publisher: publish-python.yml on metapages/framejs.io

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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