App¶
marimo.App
¶
A marimo notebook.
A marimo notebook is a dataflow graph, with each node computing a Python function.
embed
async
¶
Embed a notebook into another notebook.
The embed
method lets you embed the output of a notebook
into another notebook and access the values of its variables.
RETURNS | DESCRIPTION |
---|---|
AppEmbedResult
|
An object |
AppEmbedResult
|
output of the notebook) and |
AppEmbedResult
|
variable names defined by the notebook to their values). |
Example
# execute the notebook; app.embed() can't be called in the cell
# that imported it!
result = await app.embed()
Running await app.embed()
executes the notebook and results an object
encapsulating the notebook visual output and its definitions.
Embedded notebook outputs are interactive: when you interact with
UI elements in an embedded notebook's output, any cell referring
to the app
object other than the one that imported it is marked for
execution, and its internal state is automatically updated. This lets
you use notebooks as building blocks or components to create
higher-level notebooks.
Multiple levels of nesting are supported: it's possible to embed a notebook that in turn embeds another notebook, and marimo will do the right thing.
AppMeta¶
marimo.app_meta
¶
Get the metadata of a marimo app.
The AppMeta
class provides access to runtime metadata about a marimo app,
such as its display theme and execution mode.
Examples:
Get the current theme and conditionally set a plotting library's theme:
import altair as alt
# Enable dark theme for Altair when marimo is in dark mode
alt.themes.enable("dark" if mo.app_meta().theme == "dark" else "default")
Show content only in edit mode:
# Only show this content when editing the notebook
mo.md("# Developer Notes") if mo.app_meta().mode == "edit" else None
RETURNS | DESCRIPTION |
---|---|
AppMeta
|
An AppMeta object containing the app's metadata.
TYPE:
|