• Stars
    star
    442
  • Rank 98,042 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 2 years ago
  • Updated 18 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

jupyter widgets made easy

anywidget

PyPI License codecov Open In Colab DOI

custom jupyter widgets made easy

  • ๐Ÿ› ๏ธ create widgets without complicated cookiecutter templates
  • ๐Ÿ“š publish to PyPI like any other Python package
  • ๐Ÿค– prototype within .ipynb or .py files
  • ๐Ÿš€ run in Jupyter, JupyterLab, Google Colab, VSCode, and more
  • โšก develop with instant HMR, like modern web frameworks

Learn more in the Jupyter blog.

Installation

Warning: anywidget is new and under active development. It is not yet ready for production as APIs are subject to change.

anywidget is available on PyPI and may be installed with pip:

pip install "anywidget[dev]"

It is also available on conda-forge. If you have Anaconda or Miniconda installed on your computer, you can install anywidget with the following command:

conda install -c conda-forge anywidget

Usage

import anywidget
import traitlets

class CounterWidget(anywidget.AnyWidget):
    # Widget front-end JavaScript code
    _esm = """
    export function render({ model, el }) {
      let getCount = () => model.get("count");
      let button = document.createElement("button");
      button.innerHTML = `count is ${getCount()}`;
      button.addEventListener("click", () => {
        model.set("count", getCount() + 1);
        model.save_changes();
      });
      model.on("change:count", () => {
        button.innerHTML = `count is ${getCount()}`;
      });
      el.appendChild(button);
    }
    """
    # Stateful property that can be accessed by JavaScript & Python
    count = traitlets.Int(0).tag(sync=True)

Front-end code can also live in separate files (recommend):

import pathlib
import anywidget
import traitlets

class CounterWidget(anywidget.AnyWidget):
    _esm = pathlib.Path("index.js")
    _css = pathlib.Path("styles.css")

    count = traitlets.Int(0).tag(sync=True)

Read the documentation to learn more.

Contributing

See CONTRIBUTING.md for information on how to develop anywidget locally.

License

MIT

More Repositories

1

quak

a scalable data profiler
TypeScript
183
star
2

pygv

a minimal, scriptable genome browser for python
Python
47
star
3

zarrita.js

A JavaScript toolkit for working with chunked, compressed, n-dimensional arrays
TypeScript
38
star
4

napari-lazy-openslide

Lazily load multiscale whole-slide images with openslide and dask
Python
29
star
5

numcodecs.js

Buffer compression and transformation codecs for use in Zarr.js and beyond...
TypeScript
27
star
6

scipy-2024-anywidget

Jupyter Notebook
21
star
7

simple-zarr-server

serve Zarr datasets via HTTP
Python
20
star
8

hg

a python api for higlass
Jupyter Notebook
11
star
9

anymyst

TypeScript
7
star
10

deep_lincs

A deep learning toolkit for LINCS L1000 expression data
Python
7
star
11

zarr-lite

minimal (& incomplete) zarr implementation for loading array chunks
JavaScript
6
star
12

napari-dzi-zarr

An experimental plugin for viewing Deep Zoom Images (DZI) with napari + zarr + dask โค๏ธ.
Python
6
star
13

carbonplan-maps

Jupyter Notebook
6
star
14

servir

Python
5
star
15

reference-spec-reader

JavaScript
5
star
16

ipymario

A simple anywidget, built from Mike Bostock's Mario chime snippet.
Python
5
star
17

anndata-repr

Jupyter Notebook
5
star
18

ipytweakpane

JavaScript
4
star
19

cron-tweet

a template repo to schedule tweets via GitHub Actions
3
star
20

zod-ome-ngff

zod schemas for ome-ngff
TypeScript
3
star
21

with-coordination

declarative coordinated multiple views for Jupyter Widgets
Python
3
star
22

arbitree

Draw arbitrary single cell RNA trajectories
R
2
star
23

built-with-anywidget

TypeScript
2
star
24

anywidget-usage

TypeScript
2
star
25

vizarr-preview-server

generate images & twitter card previews for vizarr (WIP)
JavaScript
1
star
26

adventofcode

Rust
1
star
27

omecat

Rust
1
star
28

olympicks

calendar invites for the 2024 paris olympic games
Svelte
1
star
29

stream-index

Rust
1
star
30

soundvision

Visualization tool to explore Spotify library history and create playlists. Created with React, D3, Node, and the Spotify API.
JavaScript
1
star
31

patch-viewer

WIP: A napari plugin to view attention-based heatmaps for whole slide images
Python
1
star
32

coolr

[WIP]: A purely client-side reader for Cooler genomic interaction datasets
TypeScript
1
star
33

deno-clis

TypeScript
1
star
34

canvas-faces

a bookmarklet to learn names and faces on canvas
JavaScript
1
star
35

climate-change-horizonchart

Jupyter Notebook
1
star
36

eigen-tour

TypeScript
1
star
37

esbuild-plugin-virtual

An esbuild plugin which loads virtual modules from memory.
JavaScript
1
star
38

ipyfoo

A bare bones Jupyter widget implementation
Python
1
star