Status¶
Use progress bars or spinners to visualize loading status in your notebooks and apps. Useful when iterating over collections or loading data from files, databases, or APIs.
Progress bar¶
You can display a progress bar while iterating over a collection, similar
to tqdm
.
marimo.status.progress_bar
¶
progress_bar(
collection: Optional[Collection[S | int]] = None,
*,
title: Optional[str] = None,
subtitle: Optional[str] = None,
completion_title: Optional[str] = None,
completion_subtitle: Optional[str] = None,
total: Optional[int] = None,
show_rate: bool = True,
show_eta: bool = True,
remove_on_exit: bool = False,
disabled: bool = False
)
Iterate over a collection and show a progress bar.
Examples:
You can optionally provide a title and subtitle to show during iteration, and a title/subtitle to show upon completion:
The update
method accepts the optional keyword
arguments increment
(defaults to 1
), title
,
and subtitle
.
For performance reasons, the progress bar is only updated in the UI every 150ms.
PARAMETER | DESCRIPTION |
---|---|
collection
|
Optional collection to iterate over.
TYPE:
|
title
|
Optional title.
TYPE:
|
subtitle
|
Optional subtitle.
TYPE:
|
completion_title
|
Optional title to show during completion.
TYPE:
|
completion_subtitle
|
Optional subtitle to show during completion.
TYPE:
|
total
|
Optional total number of items to iterate over.
TYPE:
|
show_rate
|
If True, show the rate of progress (items per second).
TYPE:
|
show_eta
|
If True, show the estimated time of completion.
TYPE:
|
remove_on_exit
|
If True, remove the progress bar from output on exit.
TYPE:
|
disabled
|
If True, disable the progress bar.
TYPE:
|
progress
instance-attribute
¶
progress = ProgressBar(
title=title,
subtitle=subtitle,
total=total,
show_rate=show_rate,
show_eta=show_eta,
)
Spinner¶
marimo.status.spinner
¶
spinner(
title: Optional[str] = None,
subtitle: Optional[str] = None,
remove_on_exit: bool = True,
)
Show a loading spinner.
Use mo.status.spinner()
as a context manager to show a loading spinner.
You can optionally pass a title and subtitle.
Examples:
with mo.status.spinner(subtitle="Loading data ...") as _spinner:
data = expensive_function()
_spinner.update(subtitle="Crunching numbers ...")
...
mo.ui.table(data)
You can also show the spinner without a context manager:
PARAMETER | DESCRIPTION |
---|---|
title
|
Optional title.
TYPE:
|
subtitle
|
Optional subtitle.
TYPE:
|
remove_on_exit
|
If True, the spinner is removed from output on exit. Defaults to True.
TYPE:
|