Batch¶
- class marimo.ui.batch(html: Html, elements: dict[str, marimo._plugins.ui._core.ui_element.UIElement[Any, Any]], on_change: Callable[[Dict[str, object]], None] | None = None)¶
Convert an HTML object with templated text into a UI element.
A
batchis a UI element that wraps other UI elements, and is represented by custom HTML or markdown. You can create abatchby calling thebatch()method onHtmlobjects.Get the value of the wrapped UI elements using the
valueattribute of the batch.Example.
In the below example,
user_infois a UI Element whose output is markdown and whose value is a dict with keys'name'and'birthday'(and values equal to the values of their corresponding elements).user_info = mo.md( ''' - What's your name?: {name} - When were you born?: {birthday} ''' ).batch(name=mo.ui.text(), birthday=mo.ui.date())
To get the value of
nameandbirthday, use:user_info.value
You can also instantiate this class directly:
markdown = mo.md( ''' - What's your name?: {name} - When were you born?: {birthday} ''' ) batch = mo.ui.batch( markdown, {"name": mo.ui.text(), "birthday": mo.ui.date()} )
Attributes.
value: adictof the batched elements’ valueselements: adictof the batched elements (clones of the originals)on_change: optional callback to run when this element’s value changes
Initialization Args.
html: a templated
Htmlobjectelements: the UI elements to interpolate into the HTML template
on_change: optional callback to run when this element’s value changes
Public methods
Inherited from
_batch_baseget(key[, default])items()values()Inherited from
UIElementform([label, bordered, loading, ...])Create a submittable form out of this
UIElement.send_message(message, buffers)Send a message to the element rendered on the frontend from the backend.
Inherited from
Htmlbatch(**elements)Convert an HTML object with templated text into a UI element.
center()Center an item.
right()Right-justify.
left()Left-justify.
callout([kind])Create a callout containing this HTML element.
style(style)Wrap an object in a styled container.
Public Data Attributes:
Inherited from
_batch_baseelementsInherited from
UIElementvalueThe element’s current value.
Inherited from
HtmltextA string of HTML representing this element.