Skip to main content

It's React, but in Python

Reason this release was yanked:

bad build

Project description

reactpy-jupyter

A client for ReactPy implemented using Jupyter widgets

Try It Now!

Check out some live examples by clicking the badge below:

Binder

Getting Started

To install use pip:

pip install reactpy_jupyter

Then, before anything else, do one of the following:

  1. At the top of your notebook run

    import reactpy_jupyter
    
  2. Register reactpy_jupyter as a permanant IPython extension in your config file:

    c.InteractiveShellApp.extensions = [
        'reactpy_jupyter'
    ]
    

Usage

Once you're done getting started, you can author and display ReactPy layouts natively in your Jupyter Notebook:

import reactpy

@reactpy.component
def ClickCount():
    count, set_count = reactpy.hooks.use_state(0)
    return reactpy.html.button(
        {"onClick": lambda event: set_count(count + 1)},
        [f"Click count: {count}"],
    )

ClickCount()

You can also turn an reactpy element constructor into one that returns an ipywidget with the reactpy_juptyer.widgetize function. This is useful if you wish to use ReactPy in combination with other Jupyter Widgets as in the following example:

ClickCountWidget = reactpy_jupyter.widgetize(ClickCount)
ipywidgets.Box(
    [
        ClickCountWidget(),
        ClickCountWidget(),
    ]
)

Alternatively just wrap an reactpy element instance in an reactpy_jupyter.LayoutWidget:

ipywidgets.Box(
    [
        reactpy_jupyter.LayoutWidget(ClickCount()),
        reactpy_jupyter.LayoutWidget(ClickCount()),
    ]
)

For a more detailed introduction check out this live demo here:

Binder

Development Installation

For a development installation (requires Node.js and Yarn version 1),

$ git clone https://github.com/reactive-python/reactpy-jupyter.git
$ cd reactpy-jupyter
$ pip install -e .

To automatically re-build and refresh Jupyter when making changes start a Vite dev server:

$ npx vite

Then, before importing reactpy_jupyter set the following environment variable:

import os
os.environ["REACTPY_JUPYTER_DEV"] = "1"
import reactpy_jupyter

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

reactpy_jupyter-0.9.4.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

reactpy_jupyter-0.9.4-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file reactpy_jupyter-0.9.4.tar.gz.

File metadata

  • Download URL: reactpy_jupyter-0.9.4.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for reactpy_jupyter-0.9.4.tar.gz
Algorithm Hash digest
SHA256 3ee0b19ff4b3324857f8d4f5b7d8b75bc17eca0abe3396e45e4cd9236a01eeab
MD5 7f4a165ca2243201b7403f47725039f5
BLAKE2b-256 347c1c204f4c71117a2c30b004897df427f2952e4794dc3d6665fba28911d54c

See more details on using hashes here.

File details

Details for the file reactpy_jupyter-0.9.4-py3-none-any.whl.

File metadata

File hashes

Hashes for reactpy_jupyter-0.9.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ebdd170b19cd33524b0a56799a7b387fa9ce5405127d21961d5b7d69e32a97a9
MD5 2063f61a0fcb8a8798bca21a5fe3608c
BLAKE2b-256 5de0483276d8c2811f304c7ea56c03a2111b74a5df9ea3f174ddefe7aa58e80f

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