Refresh¶
- class marimo.ui.refresh(options: list[Union[int, float, str]] | None = None, default_interval: int | float | str | None = None, *, label: str = '', on_change: Callable[[int], None] | None = None)¶
A refresh button that will auto-refresh its descendants for a given interval.
Each option value can either be a number (int or float) in seconds or a human-readable string (e.g. “1s”, “10s”, “1m”).
You can also combine multiple time units (e.g. “1m 30s”).
Note: The refresh interval may not be exact, as it depends on the time it takes to render the content and the time it takes to send the content to the client. Also, due to the buffering of UI element changes, if the downstream cells take a long time to render, the refresh interval may be longer than expected.
Example.
refresh_button = mo.ui.refresh( options=["1m", "5m 30s", "10m"], default_interval="10m", ) refresh_button
Attributes.
value
: The time in seconds since the refresh has been activated.
Initialization Args.
options
: The options for the refresh interval, as a list of human-readable strings or numbers (int or float) in seconds. If no options are provided and default_interval is provided, the options will be generated automatically. If no options are provided and default_interval is not provided, the refresh button will not be displayed with a dropdown for auto-refresh.default_interval
: The default value of the refresh interval.label
: optional text label for the elementon_change
: optional callback to run when this element’s value changes
Public methods
Inherited from
UIElement
form
([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
Html
batch
(**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:
name
Inherited from
UIElement
value
The element’s current value.
Inherited from
Html
text
A string of HTML representing this element.