Giter Site home page Giter Site logo

jiwnchoi / anywidget Goto Github PK

View Code? Open in Web Editor NEW

This project forked from manzt/anywidget

0.0 0.0 0.0 11.83 MB

jupyter widgets made easy

Home Page: https://anywidget.dev

License: MIT License

JavaScript 22.82% Python 45.31% TypeScript 14.84% TeX 16.89% Svelte 0.14%

anywidget's Introduction

anywidget logo. A circular icon with two connected arrows pointing clockwise, symbolizing a refresh or restart action
anywidget

custom jupyter widgets made easy

installation . docs . discord . learn

About

anywidget uses modern web standards to simplify authoring and distributing custom Jupyter Widgets.

  • ๐Ÿ› ๏ธ 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

anywidget is available on PyPI:

pip install "anywidget[dev]"

and also on conda-forge:

conda install -c conda-forge anywidget

Usage

import anywidget
import traitlets

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

Read the documentation to learn more.

Packages

Beyond the primary Python package, anywidget provides an ecosystem of tooling to help you build and distribute custom Jupyter Widgets.

Name Description Version (click for changelogs)
anywidget Primary Python package version
npm:@anywidget/types Client type declarations version
npm:@anywidget/vite Vite plugin version
npm:@anywidget/react React framework adapter version
npm:@anywidget/svelte Svelte framework adapter version
npm:create-anywidget CLI to bootstrap a new project version
jsr:@anywidget/deno Backend for Deno Jupyter kernel version

Support

Having trouble? Get help in our Discord or open a Discussion.

Contributing

New contributors welcome! Check out our Contributors Guide for help getting started.

Join us on Discord to meet other maintainers. We'll help you get your first contribution in no time!

License

MIT

anywidget's People

Contributors

manzt avatar dependabot[bot] avatar github-actions[bot] avatar tlambert03 avatar kolibril13 avatar rgbkrk avatar dvdkouril avatar kwentine avatar davidbrochart avatar manonmarchand avatar keller-mark avatar bnavigator avatar gereleth avatar domoritz avatar donmccurdy avatar hbredin avatar jtpio avatar jonmmease avatar kylebarron avatar nvictus avatar peter-gy avatar giswqs avatar rmorshea avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.