Skip to main content

Reusable widgets for marimo notebooks

Project description

mowidgets

Reuse marimo notebooks as widgets inside other marimo notebooks! This allows to build libraries of reusable widgets and distribute them.

This uses native marimo features and the standard Python library; no extra dependencies.

Installation

pip install mowidgets

Tutorial

As an example, we create a simple widget that multiplies two numbers and displays the result.

screenshot of a mowidget

  1. Create a marimo notebook to define the widget.

    marimo edit multiply.py  # widget module name
    

screenshot of a mowidget

  1. Create a marimo notebook for the main app.

    marimo edit app.py
    
  2. From the multiply (widget module name) Python module, import the app variable. It should be an instance of marimo.App. I suggest using a setup cell.

    from multiply import app as multiply_app
    
  3. Use mowidgets.widgetize() on the marimo.App instance to create the widget.

    multiply_widget = mowidgets.widgetize(multiply_app)
    
  4. Call await in front of the widget instance to render it.

    await multiply_widget
    
  5. Using mowidgets.widgetize(..., data_access=True) allows to read values exposed by the widget. You even get autocompletion!

screenshot of a mowidget

See the examples/ directory to see complete files.

Next steps

  • Pass starting values to the MoWidget instance. This would allow to compose widgets together. (Idea well-received by the core dev team)
  • Have MoWidget expose a reliable input and output schema. Optionally add type coercion via Pydantic.
  • Simplify the import experience. Currently, the user must import the marimo.App instance in the main namespace for the widget to properly refresh.

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

mowidgets-0.1.0.tar.gz (259.2 kB view details)

Uploaded Source

Built Distribution

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

mowidgets-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file mowidgets-0.1.0.tar.gz.

File metadata

  • Download URL: mowidgets-0.1.0.tar.gz
  • Upload date:
  • Size: 259.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for mowidgets-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a29379b2fb9e6aed000dba7feb3aedd072f651ec64022e93f31c1f2e7371f2ea
MD5 e3691c7f25565a1b3c717bc9b1c00a7a
BLAKE2b-256 0103b4c6ba433a38de56a256ef6fee1f024f2b36cb064ecb56b5e54e8ed4c016

See more details on using hashes here.

File details

Details for the file mowidgets-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mowidgets-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for mowidgets-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6936c91b69d1915f0801e5467bbe786d70251f50a30c991db12258c8873d8713
MD5 a7ccd97f64d5938ba1ba2acb0bc2134d
BLAKE2b-256 cb8e5c511bc06b6b2ad2add5edc2fc16d75137e7958e2debea0edd7e306e5e0a

See more details on using hashes here.

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