Skip to main content

cast

Present from a notebook with lightweight decorators.

Project note: This repo is vibe coded: it is an experimental, fast-moving tool built around an idea I wanted to try, so expect rough edges and rapid iteration.

from pathlib import Path

import cast, polars as pl, plotly.express as px

cast.serve(port=8000)            # live page in a background thread

@cast.data                        # function returns a polars LazyFrame
def sales():
    return pl.scan_parquet("sales.parquet")

@cast.figure                      # a factory: takes one table, returns a Plotly figure
def trend(tbl: pl.LazyFrame):
    df = tbl.select(["date", "value"]).collect()
    return px.line(df, x="date", y="value")

@cast.html                        # a factory: returns custom HTML for an iframe block
def callout():
    return "<h2>Custom HTML</h2><button onclick=\"this.textContent='clicked'\">Click</button>"

@cast.image(title="Study design", alt="Diagram of the study workflow")
def study_design():
    return Path("figures/study-design.svg")  # PNG and JPEG work too

sales()                           # register the table (data is injected from the browser)

cast.load("talk.cast.json")       # restore an editable deck after assets register

@cast.figure registers a factory at decoration time — you don't pass a table in the notebook. Open the printed URL and use the controls to add the figure to the inventory, optionally with a chosen table. The same factory can be added many times with different data, and each instance has its own table dropdown; picking a table re-runs your figure function on the server against it. If the figure already exists, the function can also ignore data or take no arguments and return that Plotly object directly. Calling a @cast.data function again updates its data and the page refreshes live.

Registered @cast.data objects can also be added directly as table blocks. Tables have sticky column headers, horizontal and vertical scrolling, optional row numbers and stripes, compact spacing, configurable colors, and a preview limit of up to 1,000 rows. The same scrollable table is preserved in present mode and standalone HTML exports.

Text boxes use slide-native rich text rather than Markdown. The editor toggles editing on the same text element used for presentation, so typography, wrapping, and spacing do not change between design and present modes. Older Markdown text blocks are converted to rich text when opened.

@cast.html registers a custom HTML object at decoration time. Add it from the HTML dropdown to insert the returned HTML into a sandboxed iframe block. This is useful for small widgets, controls, styled notes, or external visualization snippets that are not Plotly figures.

@cast.image registers publication-quality image assets at decoration time. The function can return a PNG/JPEG/SVG file path, raw image bytes, SVG markup, a data URI, or a notebook object with a PNG, JPEG, or SVG rich representation. The live app serves the original bytes without resizing or recompression, so SVG remains vector and raster images retain their full resolution. Registered images are selected beside the + Image button and default to showing the whole source. The inspector provides contain/cover/stretch behavior, a source aspect-ratio action, smooth/crisp/pixel rendering, transparency, alt text, corner radius, and opacity. Frozen HTML exports embed the same original asset so the deck remains portable.

Save and reopen an editable presentation

Use Save in the editor to download presentation.cast.json, and Open to replace the current deck from one of those files. The editable document preserves slide order, text, geometry, styles, rotations, theme, manually uploaded images, and references to decorated assets. It deliberately does not serialize Python functions or live data frames; rerun the notebook cells that define those assets before reopening the deck.

The same workflow is available from Python:

cast.save("talk.cast.json")

# In a later session, after @cast.data/@cast.figure/@cast.html/@cast.image cells:
cast.load("talk.cast.json")

cast.save() is the editable source file. cast.freeze("talk.html") remains the self-contained presentation output intended for viewing and sharing.

See examples/demo.py for a runnable showcase.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cast_func-0.2.0.tar.gz (46.4 kB view details)

Uploaded Source

Built Distribution

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

cast_func-0.2.0-py3-none-any.whl (47.4 kB view details)

Uploaded Python 3

File details

Details for the file cast_func-0.2.0.tar.gz.

File metadata

  • Download URL: cast_func-0.2.0.tar.gz
  • Upload date:
  • Size: 46.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Darwin/24.5.0

File hashes

Hashes for cast_func-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a77b33736f90845fc5230efd7668aa423d56e836ba241d3cf04269e9e5b88369
MD5 09d9f5761864233fa646c053336231ca
BLAKE2b-256 c5b02a5d3e3da5c45932cdd4f4a5175c396e0ae9db7377308dae44cdf0756ff7

See more details on using hashes here.

File details

Details for the file cast_func-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cast_func-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 47.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Darwin/24.5.0

File hashes

Hashes for cast_func-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6bbe9d203a1015862ac8848901b7d08777115ed95ddb01f504f03f58573a20b6
MD5 0b2d26e0eadcb075e9259cb18a5e7e7b
BLAKE2b-256 73f00859f4b242c6db4fc4beab0f3b48ab79e6e24b76515d8bdff859fcfb59c0

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.1

2 files

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page