streamlit API Reference
Full documentation for streamlit (1.57.0)
streamlit.App
Python Library Documentation: class App in module streamlit.web.server.starlette.starlette_app
class App(builtins.object)
| App(script_path: 'str | Path', *, secrets: 'Mapping[str, SecretsValue] | None' = None, lifespan: 'Callable[[App], AbstractAsyncContextManager[dict[str, Any] | None]] | None' = None, routes: 'Sequence[BaseRoute] | None' = None, middleware: 'Sequence[Middleware] | None' = None, exception_handlers: 'Mapping[Any, ExceptionHandler] | None' = None, debug: 'bool' = False) -> 'None'
|
| ASGI-compatible Streamlit application.
|
| .. warning::
| This feature is experimental and may change or be removed in future
| versions without warning. Use at your own risk.
|
| This class provides a way to configure and run Streamlit applications
| with custom routes, middleware, lifespan hooks, and exception handlers.
|
| Parameters
| ----------
| script_path : str | Path
| Path to the main Streamlit script. Can be absolute or relative. Relative
| paths are resolved based on context: when started via ``streamlit run``,
| they resolve relative to the main script; when started directly via uvicorn
| or another ASGI server, they resolve relative to the current working directory.
| secrets : Mapping[str, SecretsValue] | None
| A dictionary of secrets to make available via ``st.secrets``. Supported
| value types are: ``str``, ``int``, ``float``, ``bool``, and nested ``dict``.
| When provided, these secrets are shallow-merged with file-based secrets
| (programmatic secrets override file-based secrets at the top level).
| Unsupported types raise ``TypeError`` at construction.
| lifespan : Callable[[App], AbstractAsyncContextManager[dict[str, Any] | None]] | None
| Async context manager for startup/shutdown logic. The context manager
| receives the App instance and can yield a dictionary of state that will
| be accessible via ``app.state``.
| routes : Sequence[BaseRoute] | None
| Additional routes to mount alongside Streamlit. User routes are checked
| against reserved Streamlit routes and will raise ValueError if they conflict.
| middleware : Sequence[Middleware] | None
| Middleware stack to apply to all requests. User middleware runs before
| Streamlit's internal middleware.
| exception_handlers : Mapping[Any, ExceptionHandler] | None
| Custom exception handlers for user routes.
| debug : bool
| Enable debug mode for the underlying Starlette application.
|
| Examples
| --------
| Basic usage:
|
| >>> from streamlit.web.server.starlette import App
| >>> app = App("main.py")
|
| With lifespan hooks:
|
| >>> from contextlib import asynccontextmanager
| >>> from streamlit.web.server.starlette import App
| >>>
| >>> @asynccontextmanager
| ... async def lifespan(app):
| ... print("Starting up...")
| ... yield {"model": "loaded"}
| ... print("Shutting down...")
| >>>
| >>> app = App("main.py", lifespan=lifespan)
|
| With custom routes:
|
| >>> from starlette.routing import Route
| >>> from starlette.responses import JSONResponse
| >>> from streamlit.web.server.starlette import App
| >>>
| >>> async def health(request):
| ... return JSONResponse({"status": "ok"})
| >>>
| >>> app = App("main.py", routes=[Route("/health", health)])
|
| With programmatic secrets:
|
| >>> import os
| >>> from streamlit.web.server.starlette import App
| >>>
| >>> app = App(
| ... "main.py",
| ... secrets={
| ... "database": {
| ... "host": os.environ["DB_HOST"],
| ... "password": os.environ["DB_PASSWORD"],
| ... }
| ... },
| ... )
|
| Methods defined here:
|
| async __call__(self, scope: 'Scope', receive: 'Receive', send: 'Send') -> 'None'
| ASGI interface.
|
| When mounted on another ASGI framework without using the lifespan() method,
| the runtime will be auto-started on the first HTTP/WebSocket request.
|
| __init__(self, script_path: 'str | Path', *, secrets: 'Mapping[str, SecretsValue] | None' = None, lifespan: 'Callable[[App], AbstractAsyncContextManager[dict[str, Any] | None]] | None' = None, routes: 'Sequence[BaseRoute] | None' = None, middleware: 'Sequence[Middleware] | None' = None, exception_handlers: 'Mapping[Any, ExceptionHandler] | None' = None, debug: 'bool' = False) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| lifespan(self) -> 'Callable[[Any], AbstractAsyncContextManager[None]]'
| Get a lifespan context manager for mounting on external ASGI frameworks.
|
| Use this when mounting st.App as a sub-application on another framework
| like FastAPI. The Streamlit runtime lifecycle will be managed by the
| parent framework's lifespan instead of st.App's internal lifespan.
|
| Returns
| -------
| Callable[[Any], AbstractAsyncContextManager[None]]
| A lifespan context manager compatible with Starlette/FastAPI.
|
| Examples
| --------
| Mount st.App on FastAPI:
|
| >>> from fastapi import FastAPI
| >>> from streamlit.starlette import App
| >>>
| >>> streamlit_app = App("dashboard.py")
| >>> fastapi_app = FastAPI(lifespan=streamlit_app.lifespan())
| >>> fastapi_app.mount("/dashboard", streamlit_app)
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| script_path
| The entry point script path.
|
| state
| Application state, populated by lifespan context manager.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
streamlit.Page
Python Library Documentation: function Page in module streamlit.navigation.page
Page(page: 'str | Path | Callable[[], None]', *, title: 'str | None' = None, icon: 'str | None' = None, url_path: 'str | None' = None, default: 'bool' = False, visibility: "Literal['visible', 'hidden']" = 'visible') -> 'StreamlitPage'
Configure a page for ``st.navigation`` in a multipage app.
Call ``st.Page`` to initialize a ``StreamlitPage`` object, and pass it to
``st.navigation`` to declare a page in your app.
When a user navigates to a page, ``st.navigation`` returns the selected
``StreamlitPage`` object. Call ``.run()`` on the returned ``StreamlitPage``
object to execute the page. You can only run the page returned by
``st.navigation``, and you can only run it once per app rerun.
A page can be defined by a Python file, ``Callable``, or external URL.
Parameters
----------
page : str, Path, or callable
The source for the internal or external page. This can be one of the
following values:
- ``callable``: Streamlit executes the callable when it runs the page.
The ``callable`` can't accept arguments.
- Path to a Python file: Streamlit executes the Python script when it
runs the page. The path can be a string or ``pathlib.Path``
object. It can be absolute or relative to the entrypoint file.
- URL: Streamlit opens the URL in a new tab when a user selects it
in the navigation menu or a page link. In this case, the app doesn't
rerun. The URL must contain an HTTP or HTTPS scheme, like
``"https://docs.streamlit.io"``. If the page is defined by a URL,
then the ``title`` parameter is required.
title : str or None
The title of the page. If this is ``None`` (default), the page title
(in the browser tab) and label (in the navigation menu) will be
inferred from the filename or callable name in ``page``. For more
information, see `Overview of multipage apps
<https://docs.streamlit.io/st.page.automatic-page-labels>`_.
The title supports GitHub-flavored Markdown of the following types:
Bold, Italics, Strikethrough, Inline Code, and Images. Images display
like icons, with a max height equal to the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional, supported
Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
icon : str or None
An optional emoji or icon to display next to the page title and label.
If ``icon`` is ``None`` (default), no icon is displayed next to the
page label in the navigation menu, and a Streamlit icon is displayed
next to the title (in the browser tab). If ``icon`` is a string, the
following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon. In this case, the
spinner only displays next to the page label in the navigation menu.
The spinner isn't used as the page favicon next to the title in the
browser tab. The favicon is the default Streamlit icon unless
otherwise specified with the ``page_icon`` parameter of
``st.set_page_config``.
url_path : str or None
The page's URL pathname, which is the path relative to the app's root
URL. If this is ``None`` (default), the URL pathname will be inferred
from the filename or callable name in ``page``. For more information,
see `Overview of multipage apps
<https://docs.streamlit.io/st.page.automatic-page-urls>`_.
The default page will have a pathname of ``""``, indicating the root
URL of the app. If you set ``default=True``, ``url_path`` is ignored.
``url_path`` can't include forward slashes; paths can't include
subdirectories.
default : bool
Whether this page is the default page to be shown when the app is
loaded. If ``default`` is ``False`` (default), the page will have a
nonempty URL pathname. However, if no default page is passed to
``st.navigation`` and this is the first page, this page will become the
default page. If ``default`` is ``True``, then the page will have
an empty pathname and ``url_path`` will be ignored.
visibility : "visible" or "hidden"
Whether the page is shown in the navigation menu. If this is
``"visible"`` (default), the page appears in the navigation menu. If
this is ``"hidden"``, the page is excluded from the navigation menu.
Hidden pages defined by Python files or callables remain accessible
by ``st.page_link`` and ``st.switch_page``. External URLs can always
be accessed using ``st.page_link`` regardless of their inclusion or
visibility in the navigation menu.
.. note::
Navigating to an internal page by URL starts a new session. For
any internal page to be accessible by URL, it must be passed to
``st.navigation`` during the new session's initial script
run. The page can be visible or hidden.
Returns
-------
StreamlitPage
The page object associated to the given script.
Example
-------
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
def page2():
st.title("Second page")
pg = st.navigation([
st.Page("page1.py", title="First page", icon="🔥"),
st.Page(page2, title="Second page", icon=":material/favorite:"),
st.Page(
"https://docs.streamlit.io",
title="Streamlit Docs",
icon=":material/open_in_new:"
),
])
pg.run()
streamlit.altair_chart
Python Library Documentation: method altair_chart in module streamlit.delta_generator
altair_chart(altair_chart: 'AltairChart', *, width: 'Width | None' = None, height: 'Height' = 'content', use_container_width: 'bool | None' = None, theme: "Literal['streamlit'] | None" = 'streamlit', key: 'Key | None' = None, on_select: "Literal['rerun', 'ignore'] | WidgetCallback" = 'ignore', selection_mode: 'str | Iterable[str] | None' = None) -> 'DeltaGenerator | VegaLiteState' method of streamlit.delta_generator.DeltaGenerator instance
Display a chart using the Vega-Altair library.
`Vega-Altair <https://altair-viz.github.io/>`_ is a declarative
statistical visualization library for Python, based on Vega and
Vega-Lite.
Parameters
----------
altair_chart : altair.Chart
The Altair chart object to display. See
https://altair-viz.github.io/gallery/ for examples of graph
descriptions.
width : "stretch", "content", int, or None
The width of the chart element. This can be one of the following:
- ``"stretch"``: The width of the element matches the width of the
parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
- ``None`` (default): Streamlit uses ``"stretch"`` for most charts,
and uses ``"content"`` for the following multi-view charts:
- Facet charts: the spec contains ``"facet"`` or encodings for
``"row"``, ``"column"``, or ``"facet"``.
- Horizontal concatenation charts: the spec contains
``"hconcat"``.
- Repeat charts: the spec contains ``"repeat"``.
- Nested composition charts: the spec contains ``"vconcat"``
with nested ``"hconcat"``, ``"vconcat"``, ``"concat"``, or
``"layer"`` operators (e.g., scatter plots with marginal
histograms).
height : "content", "stretch", or int
The height of the chart element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
use_container_width : bool or None
Whether to override the chart's native width with the width of
the parent container. This can be one of the following:
- ``None`` (default): Streamlit will use the parent container's
width for all charts except those with known incompatibility
(``altair.Facet``, ``altair.HConcatChart``, and
``altair.RepeatChart``).
- ``True``: Streamlit sets the width of the chart to match the
width of the parent container.
- ``False``: Streamlit sets the width of the chart to fit its
contents according to the plotting library, up to the width of
the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
theme : "streamlit" or None
The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
Streamlit uses its own design default. If ``theme`` is ``None``,
Streamlit falls back to the default behavior of the library.
The ``"streamlit"`` theme can be partially customized through the
configuration options ``theme.chartCategoricalColors`` and
``theme.chartSequentialColors``. Font configuration options are
also applied.
key : str, int, or None
An optional string to use for giving this element a stable
identity. If this is ``None`` (default), the element's identity
will be determined based on the values of the other parameters.
Additionally, if selections are activated and ``key`` is provided,
Streamlit will register the key in Session State to store the
selection state. The selection state is read-only. For more
details, see `Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
on_select : "ignore", "rerun", or callable
How the figure should respond to user selection events. This
controls whether or not the figure behaves like an input widget.
``on_select`` can be one of the following:
- ``"ignore"`` (default): Streamlit will not react to any selection
events in the chart. The figure will not behave like an input
widget.
- ``"rerun"``: Streamlit will rerun the app when the user selects
data in the chart. In this case, ``st.altair_chart`` will return
the selection data as a dictionary.
- A ``callable``: Streamlit will rerun the app and execute the
``callable`` as a callback function before the rest of the app.
In this case, ``st.altair_chart`` will return the selection data
as a dictionary.
To use selection events, the object passed to ``altair_chart`` must
include selection parameters. To learn about defining interactions
in Altair and how to declare selection-type parameters, see
`Interactive Charts <https://altair-viz.github.io/user_guide/interactions.html>`_
in Altair's documentation.
For consistent selection output, especially in multi-view charts
(layer, hconcat, vconcat, facet, repeat), specify ``fields`` or
``encodings`` in your selection, like
``alt.selection_point(fields=["Origin"])`` or
``alt.selection_point(encodings=["x", "y"])``. Without explicit
fields, Vega may add an internal row identifier field (``vgsid``)
to your data, and selections can then return this identifier
instead of your original data values.
selection_mode : str or Iterable of str
The selection parameters Streamlit should use. If
``selection_mode`` is ``None`` (default), Streamlit will use all
selection parameters defined in the chart's Altair spec.
When Streamlit uses a selection parameter, selections from that
parameter will trigger a rerun and be included in the selection
state. When Streamlit does not use a selection parameter,
selections from that parameter will not trigger a rerun and not be
included in the selection state.
Selection parameters are identified by their ``name`` property.
Returns
-------
element or dict
If ``on_select`` is ``"ignore"`` (default), this command returns an
internal placeholder for the chart element that can be used with
the ``.add_rows()`` method. Otherwise, this command returns a
dictionary-like object that supports both key and attribute
notation. The attributes are described by the ``VegaLiteState``
dictionary schema.
Examples
--------
>>> import altair as alt
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(rng(0).standard_normal((60, 3)), columns=["a", "b", "c"])
>>>
>>> chart = (
... alt.Chart(df)
... .mark_circle()
... .encode(x="a", y="b", size="c", color="c", tooltip=["a", "b", "c"])
... )
>>>
>>> st.altair_chart(chart)
.. output::
https://doc-vega-lite-chart.streamlit.app/
height: 450px
streamlit.area_chart
Python Library Documentation: method area_chart in module streamlit.delta_generator
area_chart(data: 'Data' = None, *, x: 'str | None' = None, y: 'str | Sequence[str] | None' = None, x_label: 'str | None' = None, y_label: 'str | None' = None, color: 'str | Color | list[Color] | None' = None, stack: 'bool | ChartStackType | None' = None, width: 'Width' = 'stretch', height: 'Height' = 'content', use_container_width: 'bool | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display an area chart.
This is syntax-sugar around ``st.altair_chart``. The main difference
is this command uses the data's own column and indices to figure out
the chart's Altair spec. As a result this is easier to use for many
"just plot this" scenarios, while being less customizable.
Parameters
----------
data : Anything supported by st.dataframe
Data to be plotted.
x : str or None
Column name or key associated to the x-axis data. If ``x`` is
``None`` (default), Streamlit uses the data index for the x-axis
values.
y : str, Sequence of str, or None
Column name(s) or key(s) associated to the y-axis data. If this is
``None`` (default), Streamlit draws the data of all remaining
columns as data series. If this is a ``Sequence`` of strings,
Streamlit draws several series on the same chart by melting your
wide-format table into a long-format table behind the scenes.
x_label : str or None
The label for the x-axis. If this is ``None`` (default), Streamlit
will use the column name specified in ``x`` if available, or else
no label will be displayed.
y_label : str or None
The label for the y-axis. If this is ``None`` (default), Streamlit
will use the column name(s) specified in ``y`` if available, or
else no label will be displayed.
color : str, tuple, Sequence of str, Sequence of tuple, or None
The color to use for different series in this chart.
For an area chart with just 1 series, this can be:
- None, to use the default color.
- A hex string like "#ffaa00" or "#ffaa0088".
- An RGB or RGBA tuple with the red, green, blue, and alpha
components specified as ints from 0 to 255 or floats from 0.0 to
1.0.
- A built-in color name: "red", "orange", "yellow", "green",
"blue", "violet", "gray"/"grey", or "primary". These map to
theme colors that you can customize using ``theme.<color>Color``
configuration options.
For an area chart with multiple series, where the dataframe is in
long format (that is, y is None or just one column), this can be:
- None, to use the default colors.
- The name of a column in the dataset. Data points will be grouped
into series of the same color based on the value of this column.
In addition, if the values in this column match one of the color
formats above (hex string or color tuple), then that color will
be used.
For example: if the dataset has 1000 rows, but this column only
contains the values "adult", "child", and "baby", then those 1000
datapoints will be grouped into three series whose colors will be
automatically selected from the default palette.
But, if for the same 1000-row dataset, this column contained
the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
datapoints would still be grouped into 3 series, but their
colors would be "#ffaa00", "#f0f", "#0000ff" this time around.
For an area chart with multiple series, where the dataframe is in
wide format (that is, y is a Sequence of columns), this can be:
- None, to use the default colors.
- A list of string colors or color tuples to be used for each of
the series in the chart. This list should have the same length
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
for three lines). You can also use built-in color names in the
list (e.g. ``color=["red", "blue", "green"]``).
You can set the default colors in the ``theme.chartCategoryColors``
configuration option.
stack : bool, "normalize", "center", or None
Whether to stack the areas. If this is ``None`` (default),
Streamlit uses Vega's default. Other values can be as follows:
- ``True``: The areas form a non-overlapping, additive stack within
the chart.
- ``False``: The areas overlap each other without stacking.
- ``"normalize"``: The areas are stacked and the total height is
normalized to 100% of the height of the chart.
- ``"center"``: The areas are stacked and shifted to center their
baseline, which creates a steamgraph.
width : "stretch", "content", or int
The width of the chart element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
height : "stretch", "content", or int
The height of the chart element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
use_container_width : bool or None
Whether to override the chart's native width with the width of
the parent container. This can be one of the following:
- ``None`` (default): Streamlit will use the chart's default behavior.
- ``True``: Streamlit sets the width of the chart to match the
width of the parent container.
- ``False``: Streamlit sets the width of the chart to fit its
contents according to the plotting library, up to the width of
the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
Examples
--------
**Example 1: Basic area chart from a dataframe**
If you don't use any of the optional parameters, Streamlit plots each
column as a separate area, uses the index as the x values, and labels
each series with the column name:
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
>>>
>>> st.area_chart(df)
.. output::
https://doc-area-chart.streamlit.app/
height: 440px
**Example 2: Area chart from specific dataframe columns**
You can choose different columns to use for the x and y values. If your
dataframe is in long format (all y-values in one column), you can set
the area colors from another column.
If the column contains color strings, the colors will be applied
directly and the series will be unlabeled. If the column contains other
values, those values will label each area, and the area colors will be
selected from the default color palette. You can configure this color
palette in the ``theme.chartCategoryColors`` configuration option.
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... {
... "col1": list(range(20)) * 3,
... "col2": rng(0).standard_normal(60),
... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20,
... }
... )
>>>
>>> st.area_chart(df, x="col1", y="col2", color="col3")
.. output::
https://doc-area-chart1.streamlit.app/
height: 440px
**Example 3: Area chart from wide-format dataframe**
If your dataframe is in wide format (y-values are in multiple columns),
you can pass a list of columns to the ``y`` parameter. Each column
name becomes a series label. To override the default colors, pass a
list of colors to the ``color`` parameter, one for each series. If your
areas are overlapping, use colors with some transparency (alpha
channel) for the best results.
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... {
... "col1": list(range(20)),
... "col2": rng(0).standard_normal(20),
... "col3": rng(1).standard_normal(20),
... }
... )
>>>
>>> st.area_chart(
... df,
... x="col1",
... y=["col2", "col3"],
... color=["#FF000080", "#0000FF80"],
... )
.. output::
https://doc-area-chart2.streamlit.app/
height: 440px
**Example 4: Area chart with different stacking**
You can adjust the stacking behavior by setting ``stack``. You can
create a streamgraph by setting ``stack="center"``:
>>> import streamlit as st
>>> from vega_datasets import data
>>>
>>> df = data.unemployment_across_industries()
>>>
>>> st.area_chart(df, x="date", y="count", color="series", stack="center")
.. output::
https://doc-area-chart-steamgraph.streamlit.app/
height: 440px
streamlit.audio
Python Library Documentation: method audio in module streamlit.delta_generator
audio(data: 'MediaData', format: 'str' = 'audio/wav', start_time: 'MediaTime' = 0, *, sample_rate: 'int | None' = None, end_time: 'MediaTime | None' = None, loop: 'bool' = False, autoplay: 'bool' = False, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display an audio player.
Parameters
----------
data : str, Path, bytes, BytesIO, numpy.ndarray, or file
The audio to play. This can be one of the following:
- A URL (string) for a hosted audio file. Also supports
``/app/static/<asset>`` URLs for files served via
`static file serving <https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_.
- A path to a local audio file. The path can be a ``str``
or ``Path`` object. Paths can be absolute or relative to the
working directory (where you execute ``streamlit run``).
- Raw audio data. Raw data formats must include all necessary file
headers to match the file format specified via ``format``.
If ``data`` is a NumPy array, it must either be a 1D array of the
waveform or a 2D array of shape (C, S) where C is the number of
channels and S is the number of samples. See the default channel
order at
http://msdn.microsoft.com/en-us/library/windows/hardware/dn653308(v=vs.85).aspx
format : str
The MIME type for the audio file. This defaults to ``"audio/wav"``.
For more information about MIME types, see
https://www.iana.org/assignments/media-types/media-types.xhtml.
start_time : int, float, timedelta, str, or None
The time from which the element should start playing. This can be
one of the following:
- ``None`` (default): The element plays from the beginning.
- An ``int`` or ``float`` specifying the time in seconds. ``float``
values are rounded down to whole seconds.
- A string specifying the time in a format supported by `Pandas'
Timedelta constructor <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_,
e.g. ``"2 minute"``, ``"20s"``, or ``"1m14s"``.
- A ``timedelta`` object from `Python's built-in datetime library
<https://docs.python.org/3/library/datetime.html#timedelta-objects>`_,
e.g. ``timedelta(seconds=70)``.
sample_rate : int or None
The sample rate of the audio data in samples per second. This is
only required if ``data`` is a NumPy array.
end_time : int, float, timedelta, str, or None
The time at which the element should stop playing. This can be
one of the following:
- ``None`` (default): The element plays through to the end.
- An ``int`` or ``float`` specifying the time in seconds. ``float``
values are rounded down to whole seconds.
- A string specifying the time in a format supported by `Pandas'
Timedelta constructor <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_,
e.g. ``"2 minute"``, ``"20s"``, or ``"1m14s"``.
- A ``timedelta`` object from `Python's built-in datetime library
<https://docs.python.org/3/library/datetime.html#timedelta-objects>`_,
e.g. ``timedelta(seconds=70)``.
loop : bool
Whether the audio should loop playback.
autoplay : bool
Whether the audio file should start playing automatically. This is
``False`` by default. Browsers will not autoplay audio files if the
user has not interacted with the page by clicking somewhere.
width : "stretch" or int
The width of the audio player element. This can be one of the
following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Examples
--------
To display an audio player for a local file, specify the file's string
path and format.
>>> import streamlit as st
>>>
>>> st.audio("cat-purr.mp3", format="audio/mpeg", loop=True)
.. output::
https://doc-audio-purr.streamlit.app/
height: 250px
You can also pass ``bytes`` or ``numpy.ndarray`` objects to ``st.audio``.
>>> import streamlit as st
>>> import numpy as np
>>>
>>> audio_file = open("myaudio.ogg", "rb")
>>> audio_bytes = audio_file.read()
>>>
>>> st.audio(audio_bytes, format="audio/ogg")
>>>
>>> sample_rate = 44100 # 44100 samples per second
>>> seconds = 2 # Note duration of 2 seconds
>>> frequency_la = 440 # Our played note will be 440 Hz
>>> # Generate array with seconds*sample_rate steps, ranging between 0 and seconds
>>> t = np.linspace(0, seconds, seconds * sample_rate, False)
>>> # Generate a 440 Hz sine wave
>>> note_la = np.sin(frequency_la * t * 2 * np.pi)
>>>
>>> st.audio(note_la, sample_rate=sample_rate)
.. output::
https://doc-audio.streamlit.app/
height: 865px
streamlit.audio_input
Python Library Documentation: method audio_input in module streamlit.delta_generator
audio_input(label: 'str', *, sample_rate: 'int | None' = 16000, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch') -> 'UploadedFile | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a widget that returns an audio recording from the user's microphone.
Parameters
----------
label : str
A short label explaining to the user what this widget is used for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
sample_rate : int or None
The target sample rate for the audio recording in Hz. This
defaults to ``16000``, which is optimal for speech recognition.
The following values are supported: ``8000`` (telephone quality),
``11025``, ``16000`` (speech-recognition quality), ``22050``,
``24000``, ``32000``, ``44100``, ``48000`` (high-quality), or
``None``. If this is ``None``, the widget uses the browser's
default sample rate (typically 44100 or 48000 Hz).
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you access the widget's value via
``st.session_state[key]`` (read-only). For more details, see
`Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this audio input's value
changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the audio input if set to
``True``. Default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "stretch" or int
The width of the audio input widget. This can be one of the following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
Returns
-------
None or UploadedFile
The ``UploadedFile`` class is a subclass of ``BytesIO``, and
therefore is "file-like". This means you can pass an instance of it
anywhere a file is expected. The MIME type for the audio data is
``audio/wav``.
.. Note::
The resulting ``UploadedFile`` is subject to the size
limitation configured in ``server.maxUploadSize``. If you
expect large sound files, update the configuration option
appropriately.
Examples
--------
*Example 1:* Record a voice message and play it back.*
The default sample rate of 16000 Hz is optimal for speech recognition.
>>> import streamlit as st
>>>
>>> audio_value = st.audio_input("Record a voice message")
>>>
>>> if audio_value:
... st.audio(audio_value)
.. output::
https://doc-audio-input.streamlit.app/
height: 260px
*Example 2:* Record high-fidelity audio and play it back.*
Higher sample rates can create higher-quality, larger audio files. This
might require a nicer microphone to fully appreciate the difference.
>>> import streamlit as st
>>>
>>> audio_value = st.audio_input("Record high quality audio", sample_rate=48000)
>>>
>>> if audio_value:
... st.audio(audio_value)
.. output::
https://doc-audio-input-high-rate.streamlit.app/
height: 260px
streamlit.auth_util
Python Library Documentation: module streamlit.auth_util in streamlit
NAME
streamlit.auth_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CLASSES
builtins.object
AuthCache
class AuthCache(builtins.object)
| AuthCache() -> 'None'
|
| Simple cache implementation for storing info required for Authlib.
|
| Methods defined here:
|
| __init__(self) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| delete(self, key: 'str') -> 'None'
|
| get(self, key: 'str') -> 'Any'
|
| get_dict(self) -> 'dict[str, Any]'
|
| set(self, key: 'str', value: 'Any', expires_in: 'int | None' = None) -> 'None'
| # for set method, we are follow the same signature used in Authlib
| # the expires_in is not used in our case
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
FUNCTIONS
build_logout_url(end_session_endpoint: 'str', client_id: 'str', post_logout_redirect_uri: 'str', id_token: 'str | None' = None) -> 'str'
Build an OIDC logout URL with the required parameters.
Parameters
----------
end_session_endpoint
The OIDC provider's end_session_endpoint URL.
client_id
The OAuth client ID.
post_logout_redirect_uri
The URI to redirect to after logout.
id_token
Optional ID token to include as id_token_hint for the logout request.
Returns
-------
str
The complete logout URL with query parameters.
clear_cookie_and_chunks(get_single_cookie_fn: 'Callable[[str], bytes | None]', clear_single_cookie_fn: 'Callable[[str], None]', cookie_name: 'str') -> 'None'
Clear a cookie and any associated chunk cookies.
The main cookie always exists. If there are chunks, also clear
cookie_name_1, cookie_name_2, etc., and the count cookie.
Args:
get_single_cookie_fn: Function to get a single cookie (cookie_name) -> bytes | None
clear_single_cookie_fn: Function to clear a single cookie (cookie_name)
cookie_name: Name of the cookie
decode_provider_token(provider_token: 'str') -> 'ProviderTokenPayload'
Decode the JWT token and validate the claims.
encode_provider_token(provider: 'str') -> 'str'
Returns a signed JWT token with the provider and expiration time.
generate_default_provider_section(auth_section: 'AttrDict') -> 'dict[str, Any]'
Generate a default provider section for the 'auth' section of secrets.toml.
get_cookie_with_chunks(get_single_cookie_fn: 'Callable[[str], bytes | None]', cookie_name: 'str') -> 'bytes | None'
Get a cookie, reconstructing from chunks if it was split.
If a count cookie exists, the main cookie contains the first chunk,
and additional chunks are in cookie_name_1, cookie_name_2, etc.
If no count cookie exists, the main cookie contains the entire value.
Args:
get_single_cookie_fn: Function to get a single cookie (cookie_name) -> bytes | None
cookie_name: Name of the cookie
Returns
-------
Cookie value as bytes, or None if not found
get_expose_tokens_config() -> 'list[str]'
Get the expose_tokens configuration from secrets.toml.
Returns a list of token types to expose. Accepts both string and list formats:
- expose_tokens = "id" -> ["id"]
- expose_tokens = ["id", "access"] -> ["id", "access"]
get_origin_from_redirect_uri() -> 'str | None'
Extract the origin (scheme + host) from the configured redirect_uri.
Returns
-------
str | None
The origin in format "scheme://host:port", or None if not configured.
get_redirect_uri(auth_section: 'AttrDict') -> 'str | None'
Get the redirect_uri from auth_section - filling in port number if needed.
get_secrets_auth_section() -> 'AttrDict'
Get the 'auth' section of the secrets.toml.
get_signing_secret() -> 'str'
Get the cookie signing secret from the configuration or secrets.toml.
get_validated_redirect_uri() -> 'str | None'
Get the redirect_uri from secrets, validating it ends with /oauth2callback.
This is used for logout flows where we need a validated redirect URI
that matches the OAuth callback path.
Returns
-------
str | None
The validated redirect URI, or None if not configured or invalid.
is_authlib_installed() -> 'bool'
Check if Authlib is installed.
set_cookie_with_chunks(set_single_cookie_fn: 'Callable[[str, str], None]', create_signed_value_fn: 'Callable[[str, str], bytes]', cookie_name: 'str', value: 'dict[str, Any]') -> 'None'
Set a cookie, splitting into multiple cookies if necessary.
Args:
set_single_cookie_fn: Function to set a single cookie (cookie_name, value)
create_signed_value_fn: Function to create a signed cookie value (cookie_name, value)
cookie_name: Name of the cookie
value: Dictionary value to serialize and store
validate_auth_credentials(provider: 'str') -> 'None'
Validate the general auth credentials and auth credentials for the given
provider.
DATA
COOKIE_ATTRIBUTES = '; Path=/; HttpOnly'
COOKIE_ATTR_SIZE = 18
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
MAX_COOKIE_BYTES = 4096
SIGNING_OVERHEAD_SAFETY_BUFFER = 50
SINGLE_BYTE_BASE64_SIZE = 4
TYPE_CHECKING = False
__annotations__ = {'COOKIE_ATTRIBUTES': 'Final', 'COOKIE_ATTR_SIZE': '...
secrets_singleton = Secrets
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\auth_util.py
streamlit.badge
Python Library Documentation: method badge in module streamlit.delta_generator
badge(label: 'str', *, icon: 'str | None' = None, color: "Literal['red', 'orange', 'yellow', 'blue', 'green', 'violet', 'gray', 'grey', 'primary']" = 'blue', width: 'Width' = 'content', help: 'str | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a colored badge with an icon and label.
This is a thin wrapper around the color-badge Markdown directive.
The following are equivalent:
- ``st.markdown(":blue-badge[Home]")``
- ``st.badge("Home", color="blue")``
.. note::
You can insert badges everywhere Streamlit supports Markdown by
using the color-badge Markdown directive. See ``st.markdown`` for
more information.
Parameters
----------
label : str
The label to display in the badge. The label can optionally contain
GitHub-flavored Markdown of the following types: Bold, Italics,
Strikethroughs, Inline Code.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives. Because this command escapes square
brackets (``[ ]``) in this parameter, any directive requiring
square brackets is not supported.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
icon : str or None
An optional emoji or icon to display next to the badge label. If
``icon`` is ``None`` (default), no icon is displayed. If ``icon``
is a string, the following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
color : str
The color to use for the badge. This defaults to ``"blue"``.
This can be one of the following supported colors: red, orange,
yellow, blue, green, violet, gray/grey, or primary. If you use
``"primary"``, Streamlit will use the default primary accent color
unless you set the ``theme.primaryColor`` configuration option.
width : "content", "stretch", or int
The width of the badge element. This can be one of the following:
- ``"content"`` (default): The width of the element matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the element matches the width of the
parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
help : str or None
A tooltip to display when hovering over the badge. If this is
``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
Examples
--------
Create standalone badges with ``st.badge`` (with or without icons). If
you want to have multiple, side-by-side badges, you can use the
Markdown directive in ``st.markdown``.
>>> import streamlit as st
>>>
>>> st.badge("New")
>>> st.badge("Success", icon=":material/check:", color="green")
>>>
>>> st.markdown(
>>> ":violet-badge[:material/star: Favorite] :orange-badge[⚠️ Needs review] :gray-badge[Deprecated]"
>>> )
.. output::
https://doc-badge.streamlit.app/
height: 220px
streamlit.balloons
Python Library Documentation: method balloons in module streamlit.delta_generator
balloons() -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Draw celebratory balloons.
Examples
--------
>>> import streamlit as st
>>>
>>> st.balloons()
...then watch your app and get ready for a celebration!
streamlit.bar_chart
Python Library Documentation: method bar_chart in module streamlit.delta_generator
bar_chart(data: 'Data' = None, *, x: 'str | None' = None, y: 'str | Sequence[str] | None' = None, x_label: 'str | None' = None, y_label: 'str | None' = None, color: 'str | Color | list[Color] | None' = None, horizontal: 'bool' = False, sort: 'bool | str' = True, stack: 'bool | ChartStackType | None' = None, width: 'Width' = 'stretch', height: 'Height' = 'content', use_container_width: 'bool | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a bar chart.
This is syntax-sugar around ``st.altair_chart``. The main difference
is this command uses the data's own column and indices to figure out
the chart's Altair spec. As a result this is easier to use for many
"just plot this" scenarios, while being less customizable.
Parameters
----------
data : Anything supported by st.dataframe
Data to be plotted.
x : str or None
Column name or key associated to the x-axis data. If ``x`` is
``None`` (default), Streamlit uses the data index for the x-axis
values.
y : str, Sequence of str, or None
Column name(s) or key(s) associated to the y-axis data. If this is
``None`` (default), Streamlit draws the data of all remaining
columns as data series. If this is a ``Sequence`` of strings,
Streamlit draws several series on the same chart by melting your
wide-format table into a long-format table behind the scenes.
x_label : str or None
The label for the x-axis. If this is ``None`` (default), Streamlit
will use the column name specified in ``x`` if available, or else
no label will be displayed.
y_label : str or None
The label for the y-axis. If this is ``None`` (default), Streamlit
will use the column name(s) specified in ``y`` if available, or
else no label will be displayed.
color : str, tuple, Sequence of str, Sequence of tuple, or None
The color to use for different series in this chart.
For a bar chart with just one series, this can be:
- None, to use the default color.
- A hex string like "#ffaa00" or "#ffaa0088".
- An RGB or RGBA tuple with the red, green, blue, and alpha
components specified as ints from 0 to 255 or floats from 0.0 to
1.0.
- A built-in color name: "red", "orange", "yellow", "green",
"blue", "violet", "gray"/"grey", or "primary". These map to
theme colors that you can customize using ``theme.<color>Color``
configuration options.
For a bar chart with multiple series, where the dataframe is in
long format (that is, y is None or just one column), this can be:
- None, to use the default colors.
- The name of a column in the dataset. Data points will be grouped
into series of the same color based on the value of this column.
In addition, if the values in this column match one of the color
formats above (hex string or color tuple), then that color will
be used.
For example: if the dataset has 1000 rows, but this column only
contains the values "adult", "child", and "baby", then those 1000
datapoints will be grouped into three series whose colors will be
automatically selected from the default palette.
But, if for the same 1000-row dataset, this column contained
the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
datapoints would still be grouped into 3 series, but their
colors would be "#ffaa00", "#f0f", "#0000ff" this time around.
For a bar chart with multiple series, where the dataframe is in
wide format (that is, y is a Sequence of columns), this can be:
- None, to use the default colors.
- A list of string colors or color tuples to be used for each of
the series in the chart. This list should have the same length
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
for three lines). You can also use built-in color names in the
list (e.g. ``color=["red", "blue", "green"]``).
You can set the default colors in the ``theme.chartCategoryColors``
configuration option.
horizontal : bool
Whether to make the bars horizontal. If this is ``False``
(default), the bars display vertically. If this is ``True``,
Streamlit swaps the x-axis and y-axis and the bars display
horizontally.
sort : bool or str
How to sort the bars. This can be one of the following:
- ``True`` (default): The bars are sorted automatically along the
independent/categorical axis with Altair's default sorting. This
also correctly sorts ordered categorical columns
(``pd.Categorical``).
- ``False``: The bars are shown in data order without sorting.
- The name of a column (e.g. ``"col1"``): The bars are sorted by
that column in ascending order.
- The name of a column with a minus-sign prefix (e.g. ``"-col1"``):
The bars are sorted by that column in descending order.
stack : bool, "normalize", "center", "layered", or None
Whether to stack the bars. If this is ``None`` (default),
Streamlit uses Vega's default. Other values can be as follows:
- ``True``: The bars form a non-overlapping, additive stack within
the chart.
- ``False``: The bars display side by side.
- ``"layered"``: The bars overlap each other without stacking.
- ``"normalize"``: The bars are stacked and the total height is
normalized to 100% of the height of the chart.
- ``"center"``: The bars are stacked and shifted to center the
total height around an axis.
width : "stretch", "content", or int
The width of the chart element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
height : "stretch", "content", or int
The height of the chart element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
use_container_width : bool or None
Whether to override the chart's native width with the width of
the parent container. This can be one of the following:
- ``None`` (default): Streamlit will use the chart's default behavior.
- ``True``: Streamlit sets the width of the chart to match the
width of the parent container.
- ``False``: Streamlit sets the width of the chart to fit its
contents according to the plotting library, up to the width of
the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
Examples
--------
**Example 1: Basic bar chart from a dataframe**
If you don't use any of the optional parameters, Streamlit plots each
column as a series of bars, uses the index as the x values, and labels
each series with the column name:
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
>>>
>>> st.bar_chart(df)
.. output::
https://doc-bar-chart.streamlit.app/
height: 440px
**Example 2: Bar chart from specific dataframe columns**
You can choose different columns to use for the x and y values. If your
dataframe is in long format (all y-values in one column), you can set
the bar colors from another column.
If the column contains color strings, the colors will be applied
directly and the series will be unlabeled. If the column contains other
values, those values will label each series, and the bar colors will be
selected from the default color palette. You can configure this color
palette in the ``theme.chartCategoryColors`` configuration option.
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... {
... "col1": list(range(20)) * 3,
... "col2": rng(0).standard_normal(60),
... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20,
... }
... )
>>>
>>> st.bar_chart(df, x="col1", y="col2", color="col3")
.. output::
https://doc-bar-chart1.streamlit.app/
height: 440px
**Example 3: Bar chart from wide-format dataframe**
If your dataframe is in wide format (y-values are in multiple columns),
you can pass a list of columns to the ``y`` parameter. Each column
name becomes a series label. To override the default colors, pass a
list of colors to the ``color`` parameter, one for each series:
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... {
... "col1": list(range(20)),
... "col2": rng(0).standard_normal(20),
... "col3": rng(1).standard_normal(20),
... }
... )
>>>
>>> st.bar_chart(
... df,
... x="col1",
... y=["col2", "col3"],
... color=["#FF0000", "#0000FF"],
... )
.. output::
https://doc-bar-chart2.streamlit.app/
height: 440px
**Example 4: Horizontal bar chart**
You can use the ``horizontal`` parameter to display horizontal bars
instead of vertical bars. This is useful when you have long labels on
the x-axis, or when you want to display a large number of categories.
This example requires ``vega_datasets`` to be installed.
>>> import streamlit as st
>>> from vega_datasets import data
>>>
>>> source = data.barley()
>>>
>>> st.bar_chart(source, x="variety", y="yield", color="site", horizontal=True)
.. output::
https://doc-bar-chart-horizontal.streamlit.app/
height: 440px
**Example 5: Unstacked bar chart**
You can configure the stacking behavior of the bars by setting the
``stack`` parameter. Set it to ``False`` to display bars side by side.
This example requires ``vega_datasets`` to be installed.
>>> import streamlit as st
>>> from vega_datasets import data
>>>
>>> source = data.barley()
>>>
>>> st.bar_chart(source, x="year", y="yield", color="site", stack=False)
.. output::
https://doc-bar-chart-unstacked.streamlit.app/
height: 440px
streamlit.bokeh_chart
Python Library Documentation: method bokeh_chart in module streamlit.delta_generator
bokeh_chart(figure: 'object', use_container_width: 'bool' = True) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display an interactive Bokeh chart.
Bokeh is a charting library for Python. You can find
more about Bokeh at https://bokeh.pydata.org.
.. Important::
This command has been deprecated and removed. Please use our custom
component, |streamlit-bokeh|_, instead. Calling st.bokeh_chart will
do nothing.
.. |streamlit-bokeh| replace:: ``streamlit-bokeh``
.. _streamlit-bokeh: https://github.com/streamlit/streamlit-bokeh
Parameters
----------
figure : bokeh.plotting.figure.Figure
A Bokeh figure to plot.
use_container_width : bool
Whether to override the figure's native width with the width of
the parent container. If ``use_container_width`` is ``True`` (default),
Streamlit sets the width of the figure to match the width of the parent
container. If ``use_container_width`` is ``False``, Streamlit sets the
width of the chart to fit its contents according to the plotting library,
up to the width of the parent container.
streamlit.bottom
Python Library Documentation: BottomContainerProxy in module streamlit.elements.bottom wrapper(*args: 'Any', **kwargs: 'Any') -> 'NoReturn'
streamlit.button
Python Library Documentation: method button in module streamlit.delta_generator
button(label: 'str', key: 'Key | None' = None, help: 'str | None' = None, on_click: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', icon: 'str | None' = None, icon_position: 'IconPosition' = 'left', disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', shortcut: 'str | None' = None) -> 'bool' method of streamlit.delta_generator.DeltaGenerator instance
Display a button widget.
Parameters
----------
label : str
A short label explaining to the user what this button is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you access the widget's value via
``st.session_state[key]`` (read-only). For more details, see
`Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed when the button is hovered over. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_click : callable
An optional callback invoked when this button is clicked.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
type : "primary", "secondary", or "tertiary"
An optional string that specifies the button type. This can be one
of the following:
- ``"primary"``: The button's background is the app's primary color
for additional emphasis.
- ``"secondary"`` (default): The button's background coordinates
with the app's background color for normal emphasis.
- ``"tertiary"``: The button is plain text without a border or
background for subtlety.
icon : str or None
An optional emoji or icon to display next to the button label. If ``icon``
is ``None`` (default), no icon is displayed. If ``icon`` is a
string, the following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols \
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
icon_position : "left" or "right"
The position of the icon relative to the button label. This
defaults to ``"left"``.
disabled : bool
An optional boolean that disables the button if set to ``True``.
The default is ``False``.
use_container_width : bool
Whether to expand the button's width to fill its parent container.
If ``use_container_width`` is ``False`` (default), Streamlit sizes
the button to fit its contents. If ``use_container_width`` is
``True``, the width of the button matches its parent container.
In both cases, if the contents of the button are wider than the
parent container, the contents will line wrap.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``. For ``use_container_width=False``, use
``width="content"``.
width : "content", "stretch", or int
The width of the button. This can be one of the following:
- ``"content"`` (default): The width of the button matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the button matches the width of the
parent container.
- An integer specifying the width in pixels: The button has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the button matches the width
of the parent container.
shortcut : str or None
An optional keyboard shortcut that triggers the button. This can be
one of the following strings:
- A single alphanumeric key like ``"K"`` or ``"4"``.
- A function key like ``"F11"``.
- A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
- Any of the above combined with modifiers. For example, you can use
``"Ctrl+K"`` or ``"Cmd+Shift+O"``.
.. important::
The keys ``"C"`` and ``"R"`` are reserved and can't be used,
even with modifiers. Punctuation keys like ``"."`` and ``","``
aren't currently supported.
The following special keys are supported: Backspace, Delete, Down,
End, Enter, Esc, Home, Left, PageDown, PageUp, Right, Space, Tab,
and Up.
The following modifiers are supported: Alt, Ctrl, Cmd, Meta, Mod,
Option, Shift.
- Ctrl, Cmd, Meta, and Mod are interchangeable and will display to
the user to match their platform.
- Option and Alt are interchangeable and will display to the user
to match their platform.
Returns
-------
bool
True if the button was clicked on the last run of the app,
False otherwise.
Examples
--------
**Example 1: Customize your button type**
>>> import streamlit as st
>>>
>>> st.button("Reset", type="primary")
>>> if st.button("Say hello"):
... st.write("Why hello there")
... else:
... st.write("Goodbye")
>>>
>>> if st.button("Aloha", type="tertiary"):
... st.write("Ciao")
.. output::
https://doc-buton.streamlit.app/
height: 300px
**Example 2: Add icons to your button**
Although you can add icons to your buttons through Markdown, the
``icon`` parameter is a convenient and consistent alternative.
>>> import streamlit as st
>>>
>>> left, middle, right = st.columns(3)
>>> if left.button("Plain button", width="stretch"):
... left.markdown("You clicked the plain button.")
>>> if middle.button("Emoji button", icon="😃", width="stretch"):
... middle.markdown("You clicked the emoji button.")
>>> if right.button("Material button", icon=":material/mood:", width="stretch"):
... right.markdown("You clicked the Material button.")
.. output::
https://doc-button-icons.streamlit.app/
height: 220px
**Example 3: Use keyboard shortcuts**
The following example shows how to use keyboard shortcuts to trigger a
button. If you use any of the platform-dependent modifiers (Ctrl, Cmd,
or Mod), they are interpreted interchangeably and always displayed to
the user to match their platform.
>>> import streamlit as st
>>>
>>> with st.container(horizontal=True, horizontal_alignment="distribute"):
>>> "`A`" if st.button("A", shortcut="A") else "` `"
>>> "`S`" if st.button("S", shortcut="Ctrl+S") else "` `"
>>> "`D`" if st.button("D", shortcut="Cmd+Shift+D") else "` `"
>>> "`F`" if st.button("F", shortcut="Mod+Alt+Shift+F") else "` `"
.. output::
https://doc-button-shortcuts.streamlit.app/
height: 220px
streamlit.cache
Python Library Documentation: function cache in module streamlit.runtime.caching.legacy_cache_api
cache(func: 'F | None' = None, persist: 'bool' = False, allow_output_mutation: 'bool' = False, show_spinner: 'bool' = True, suppress_st_warning: 'bool' = False, hash_funcs: 'HashFuncsDict | None' = None, max_entries: 'int | None' = None, ttl: 'float | None' = None) -> 'F'
Legacy caching decorator (deprecated).
Legacy caching with ``st.cache`` has been removed from Streamlit. This is
now an alias for ``st.cache_data`` and ``st.cache_resource``.
Parameters
----------
func : callable
The function to cache. Streamlit hashes the function's source code.
persist : bool
Whether to persist the cache on disk.
allow_output_mutation : bool
Whether to use ``st.cache_data`` or ``st.cache_resource``. If this is
``False`` (default), the arguments are passed to ``st.cache_data``. If
this is ``True``, the arguments are passed to ``st.cache_resource``.
show_spinner : bool
Enable the spinner. Default is ``True`` to show a spinner when there is
a "cache miss" and the cached data is being created.
suppress_st_warning : bool
This is not used.
hash_funcs : dict or None
Mapping of types or fully qualified names to hash functions. This is used to
override the behavior of the hasher inside Streamlit's caching mechanism: when
the hasher encounters an object, it will first check to see if its type matches
a key in this dict and, if so, will use the provided function to generate a hash
for it. See below for an example of how this can be used.
max_entries : int or None
The maximum number of entries to keep in the cache, or ``None``
for an unbounded cache. (When a new entry is added to a full cache,
the oldest cached entry will be removed.) The default is ``None``.
ttl : float or None
The maximum number of seconds to keep an entry in the cache, or
None if cache entries should not expire. The default is None.
Examples
--------
>>> import streamlit as st
>>>
>>> @st.cache
... def fetch_and_clean_data(url):
... # Fetch data from URL here, and then clean it up.
... return data
>>>
>>> d1 = fetch_and_clean_data(DATA_URL_1)
>>> # Actually executes the function, since this is the first time it was
>>> # encountered.
>>>
>>> d2 = fetch_and_clean_data(DATA_URL_1)
>>> # Does not execute the function. Instead, returns its previously computed
>>> # value. This means that now the data in d1 is the same as in d2.
>>>
>>> d3 = fetch_and_clean_data(DATA_URL_2)
>>> # This is a different URL, so the function executes.
To set the ``persist`` parameter, use this command as follows:
>>> @st.cache(persist=True)
... def fetch_and_clean_data(url):
... # Fetch data from URL here, and then clean it up.
... return data
To disable hashing return values, set the ``allow_output_mutation`` parameter to
``True``:
>>> @st.cache(allow_output_mutation=True)
... def fetch_and_clean_data(url):
... # Fetch data from URL here, and then clean it up.
... return data
To override the default hashing behavior, pass a custom hash function.
You can do that by mapping a type (e.g. ``MongoClient``) to a hash function (``id``)
like this:
>>> @st.cache(hash_funcs={MongoClient: id})
... def connect_to_database(url):
... return MongoClient(url)
Alternatively, you can map the type's fully-qualified name
(e.g. ``"pymongo.mongo_client.MongoClient"``) to the hash function instead:
>>> @st.cache(hash_funcs={"pymongo.mongo_client.MongoClient": id})
... def connect_to_database(url):
... return MongoClient(url)
streamlit.cache_data
Python Library Documentation: CacheDataAPI in module streamlit.runtime.caching.cache_data_api object class CacheDataAPI(builtins.object) | CacheDataAPI(decorator_metric_name: 'str') -> 'None' | | Implements the public st.cache_data API: the @st.cache_data decorator, and | st.cache_data.clear(). | | Methods defined here: | | __call__(self, func: 'Callable[P, R] | None' = None, *, ttl: 'float | timedelta | str | None' = None, max_entries: 'int | None' = None, show_spinner: 'bool | str' = True, show_time: 'bool' = False, persist: 'CachePersistType | bool' = None, hash_funcs: 'HashFuncsDict | None' = None, scope: 'CacheScope' = 'global') -> 'CachedFunc[P, R] | Callable[[Callable[P, R]], CachedFunc[P, R]]' | Call self as a function. | | __init__(self, decorator_metric_name: 'str') -> 'None' | Create a CacheDataAPI instance. | | Parameters | ---------- | decorator_metric_name | The metric name to record for decorator usage. | | clear(self) -> 'None' | Clear all in-memory and on-disk data caches. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
streamlit.cache_resource
Python Library Documentation: CacheResourceAPI in module streamlit.runtime.caching.cache_resource_api object class CacheResourceAPI(builtins.object) | CacheResourceAPI(decorator_metric_name: 'str') -> 'None' | | Implements the public st.cache_resource API: the @st.cache_resource decorator, | and st.cache_resource.clear(). | | Methods defined here: | | __call__(self, func: 'Callable[P, R] | None' = None, *, ttl: 'float | timedelta | str | None' = None, max_entries: 'int | None' = None, show_spinner: 'bool | str' = True, show_time: 'bool' = False, validate: 'ValidateFunc | None' = None, hash_funcs: 'HashFuncsDict | None' = None, on_release: 'OnRelease | None' = None, scope: 'CacheScope' = 'global') -> 'CachedFunc[P, R] | Callable[[Callable[P, R]], CachedFunc[P, R]]' | Call self as a function. | | __init__(self, decorator_metric_name: 'str') -> 'None' | Create a CacheResourceAPI instance. | | Parameters | ---------- | decorator_metric_name | The metric name to record for decorator usage. | | clear(self) -> 'None' | Clear all cache_resource caches. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
streamlit.camera_input
Python Library Documentation: method camera_input in module streamlit.delta_generator
camera_input(label: 'str', key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch') -> 'UploadedFile | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a widget that returns pictures from the user's webcam.
Parameters
----------
label : str
A short label explaining to the user what this widget is used for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you access the widget's value via
``st.session_state[key]`` (read-only). For more details, see
`Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this camera_input's value
changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the camera input if set to
``True``. Default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "stretch" or int
The width of the camera input widget. This can be one of the
following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
Returns
-------
None or UploadedFile
The UploadedFile class is a subclass of BytesIO, and therefore is
"file-like". This means you can pass an instance of it anywhere a
file is expected.
Examples
--------
>>> import streamlit as st
>>>
>>> enable = st.checkbox("Enable camera")
>>> picture = st.camera_input("Take a picture", disabled=not enable)
>>>
>>> if picture:
... st.image(picture)
.. output::
https://doc-camera-input.streamlit.app/
height: 600px
streamlit.caption
Python Library Documentation: method caption in module streamlit.delta_generator
caption(body: 'SupportsStr', unsafe_allow_html: 'bool' = False, *, help: 'str | None' = None, width: 'Width' = 'stretch', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display text in small font.
This should be used for captions, asides, footnotes, sidenotes, and
other explanatory text.
Parameters
----------
body : str
The text to display as GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
unsafe_allow_html : bool
Whether to render HTML within ``body``. If this is ``False``
(default), any HTML tags found in ``body`` will be escaped and
therefore treated as raw text. If this is ``True``, any HTML
expressions within ``body`` will be rendered.
Adding custom HTML to your app impacts safety, styling, and
maintainability.
.. note::
If you only want to insert HTML or CSS without Markdown text,
we recommend using ``st.html`` instead.
help : str or None
A tooltip that gets displayed next to the caption. If this is
``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
width : "stretch", "content", or int
The width of the caption element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
text_alignment : "left", "center", "right", or "justify"
The horizontal alignment of the text within the element. This can
be one of the following:
- ``"left"`` (default): Text is aligned to the left edge.
- ``"center"``: Text is centered.
- ``"right"``: Text is aligned to the right edge.
- ``"justify"``: Text is justified (stretched to fill the available
width with the last line left-aligned).
.. note::
For text alignment to have a visible effect, the element's
width must be wider than its content. If you use
``width="content"`` with short text, the alignment may not be
noticeable.
Examples
--------
>>> import streamlit as st
>>>
>>> st.caption("This is a string that explains something above.")
>>> st.caption("A caption with _italics_ :blue[colors] and emojis :sunglasses:")
streamlit.chat_input
Python Library Documentation: method chat_input in module streamlit.delta_generator
chat_input(placeholder: 'str' = 'Your message', *, key: 'Key | None' = None, max_chars: 'int | None' = None, max_upload_size: 'int | None' = None, accept_file: "bool | Literal['multiple', 'directory']" = False, file_type: 'str | Sequence[str] | None' = None, accept_audio: 'bool' = False, audio_sample_rate: 'int | None' = 16000, disabled: 'bool' = False, on_submit: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, width: 'WidthWithoutContent' = 'stretch', height: 'Height' = 'content') -> 'str | ChatInputValue | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a chat input widget.
Parameters
----------
placeholder : str
A placeholder text shown when the chat input is empty. This
defaults to ``"Your message"``. For accessibility reasons, you
should not use an empty string.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``accept_file``, ``file_type``, ``max_chars``,
or ``max_upload_size`` resets the widget even when a key
is provided.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
max_chars : int or None
The maximum number of characters that can be entered. If this is
``None`` (default), there will be no maximum.
max_upload_size : int or None
The maximum allowed size of each uploaded file in megabytes.
If this is ``None`` (default), the maximum file size is set by the
``server.maxUploadSize`` configuration option in your
``config.toml`` file. If this is an integer, it must be positive
and will override the ``server.maxUploadSize`` configuration option.
accept_file : bool, "multiple", or "directory"
Whether the chat input should accept files. This can be one of the
following values:
- ``False`` (default): No files are accepted and the user can only
submit a message.
- ``True``: The user can add a single file to their submission.
- ``"multiple"``: The user can add multiple files to their
submission.
- ``"directory"``: The user can add multiple files to their
submission by selecting a directory. If ``file_type`` is set,
only files matching those type(s) will be uploaded.
By default, uploaded files are limited to 200 MB each. You can
configure this using the ``server.maxUploadSize`` config option.
For more information on how to set config options, see
|config.toml|_.
.. |config.toml| replace:: ``config.toml``
.. _config.toml: https://docs.streamlit.io/develop/api-reference/configuration/config.toml
file_type : str, Sequence[str], or None
The allowed file types for uploaded files. This can be one of the
following values:
- ``None`` (default): All file extensions are allowed.
- A file extension: Only one file extension is allowed. For example,
to only accept CSV files, use ``"csv"`` or ``".csv"``.
- A MIME type: Only one MIME type is allowed. For example,
to accept JPEG images, use ``"image/jpeg"``.
- A MIME wildcard: All types within a MIME media type are allowed.
For example, to accept all images, use ``"image/*"``.
- A MIME media type: This is a shortcut that is equivalent to a
MIME wildcard. If you use ``"image"``, ``"audio"``, ``"video"``, or
``"text"``, Streamlit will internally append ``/*`` to create
a MIME wildcard.
- A sequence of strings: Use a combination of the previously listed
strings to accept multiple file types.
For more information about MIME types, see
https://www.iana.org/assignments/media-types/media-types.xhtml.
.. note::
This is a best-effort check, but doesn't provide a
security guarantee against users uploading files of other types
or type extensions. The correct handling of uploaded files is
part of the app developer's responsibility.
accept_audio : bool
Whether to show an audio recording button in the chat input. This
defaults to ``False``. If this is ``True``, users can record and
submit audio messages. Recorded audio is available as an
``UploadedFile`` object with MIME type ``audio/wav``.
audio_sample_rate : int or None
The target sample rate for audio recording in Hz when
``accept_audio`` is ``True``. This defaults to ``16000``, which is
optimal for speech recognition.
The following values are supported: ``8000`` (telephone quality),
``11025``, ``16000`` (speech-recognition quality), ``22050``,
``24000``, ``32000``, ``44100``, ``48000`` (high-quality), or
``None``. If this is ``None``, the widget uses the browser's
default sample rate (typically 44100 or 48000 Hz).
disabled : bool
Whether the chat input should be disabled. This defaults to
``False``.
on_submit : callable
An optional callback invoked when the chat input's value is submitted.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
width : "stretch" or int
The width of the chat input widget. This can be one of the
following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
height : "content", "stretch", or int
The minimum height of the chat input widget. This can be one of
the following:
- ``"content"`` (default): The widget uses the default single-line
height and automatically expands based on the text content.
- ``"stretch"``: The height of the widget stretches to fill the
available height of the parent container. The parent container
must have a defined height for this to work properly.
- An integer specifying the minimum height in pixels: The widget
has a fixed minimum height but still auto-expands based on text
content. The minimum recommended height is 68 pixels, which fits
a single line of text.
Returns
-------
None, str, or dict-like
The user's submission. This is one of the following types:
- ``None``: If the user didn't submit a message, file, or audio
recording in the last rerun, the widget returns ``None``.
- A string: When the widget isn't configured to accept files or
audio recordings, and the user submitted a message in the last
rerun, the widget returns the user's message as a string.
- A dict-like object: When the widget is configured to accept files
or audio recordings, and the user submitted any content in the
last rerun, the widget returns a dict-like object.
The object always includes the ``text`` attribute, and
optionally includes ``files`` and/or ``audio`` attributes depending
on the ``accept_file`` and ``accept_audio`` parameters.
When the widget is configured to accept files or audio recordings,
and the user submitted content in the last rerun, you can access
the user's submission with key or attribute notation from the
dict-like object. This is shown in Example 3 below.
- The ``text`` attribute holds a string that is the user's message.
This is an empty string if the user only submitted one or more
files or audio recordings.
- The ``files`` attribute is only present when ``accept_file``
isn't ``False``. When present, it holds a list of
``UploadedFile`` objects. The list is empty if the user only
submitted a message or audio recording. Unlike
``st.file_uploader``, this attribute always returns a list, even
when the widget is configured to accept only one file at a time.
- The ``audio`` attribute is only present when ``accept_audio`` is
``True``. When present, it holds an ``UploadedFile`` object if
audio was recorded or ``None`` if no audio was recorded.
The ``UploadedFile`` class is a subclass of ``BytesIO`` and
therefore is "file-like". This means you can pass an instance of it
anywhere a file is expected.
Examples
--------
**Example 1: Pin the chat input widget to the bottom of your app**
When ``st.chat_input`` is used in the main body of an app, it will be
pinned to the bottom of the page.
>>> import streamlit as st
>>>
>>> prompt = st.chat_input("Say something")
>>> if prompt:
... st.write(f"User has sent the following prompt: {prompt}")
.. output::
https://doc-chat-input.streamlit.app/
height: 350px
**Example 2: Use the chat input widget inline**
The chat input can also be used inline by nesting it inside any layout
container (container, columns, tabs, sidebar, etc) or fragment. Create
chat interfaces embedded next to other content, or have multiple
chatbots!
>>> import streamlit as st
>>>
>>> with st.sidebar:
>>> messages = st.container(height=200)
>>> if prompt := st.chat_input("Say something"):
>>> messages.chat_message("user").write(prompt)
>>> messages.chat_message("assistant").write(f"Echo: {prompt}")
.. output::
https://doc-chat-input-inline.streamlit.app/
height: 350px
**Example 3: Let users upload files**
When you configure your chat input widget to allow file attachments, it
will return a dict-like object when the user sends a submission. You
can access the user's message through the ``text`` attribute of this
dictionary. You can access a list of the user's submitted file(s)
through the ``files`` attribute. Similar to ``st.session_state``, you
can use key or attribute notation.
>>> import streamlit as st
>>>
>>> prompt = st.chat_input(
>>> "Say something and/or attach an image",
>>> accept_file=True,
>>> file_type=["jpg", "jpeg", "png"],
>>> )
>>> if prompt and prompt.text:
>>> st.markdown(prompt.text)
>>> if prompt and prompt["files"]:
>>> st.image(prompt["files"][0])
.. output::
https://doc-chat-input-file-uploader.streamlit.app/
height: 350px
**Example 4: Programmatically set the text via session state**
You can use ``st.session_state`` to set the text of the chat input widget.
Because ``st.chat_input`` is a trigger widget, the value in Session State
is cleared after the widget is populated. This prevents the widget from
returning the value until the user submits it.
>>> import streamlit as st
>>>
>>> if st.button("Set Value"):
>>> st.session_state.chat_input = "Hello, world!"
>>> st.chat_input(key="chat_input")
>>> st.write("Chat input value:", st.session_state.chat_input)
.. output::
https://doc-chat-input-session-state.streamlit.app/
height: 350px
**Example 5: Enable audio recording**
You can enable audio recording by setting ``accept_audio=True``.
The ``accept_audio`` parameter works independently of ``accept_file``,
allowing you to enable audio recording with or without file uploads.
>>> import streamlit as st
>>>
>>> prompt = st.chat_input(
>>> "Say or record something",
>>> accept_audio=True,
>>> )
>>> if prompt and prompt.text:
>>> st.write("Text:", prompt.text)
>>> if prompt and prompt.audio:
>>> st.audio(prompt.audio)
>>> st.write("Audio file:", prompt.audio.name)
.. output::
https://doc-chat-input-audio.streamlit.app/
height: 350px
streamlit.chat_message
Python Library Documentation: method chat_message in module streamlit.delta_generator
chat_message(name: "Literal['user', 'assistant', 'ai', 'human'] | str", *, avatar: "Literal['user', 'assistant'] | str | AtomicImage | None" = None, width: 'Width' = 'stretch') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Insert a chat message container.
To add elements to the returned container, you can use ``with`` notation
(preferred) or just call methods directly on the returned object. See the
examples below.
.. note::
To follow best design practices and maintain a good appearance on
all screen sizes, don't nest chat message containers.
Parameters
----------
name : "user", "assistant", "ai", "human", or str
The name of the message author. Can be "human"/"user" or
"ai"/"assistant" to enable preset styling and avatars.
Currently, the name is not shown in the UI but is only set as an
accessibility label. For accessibility reasons, you should not use
an empty string.
avatar : Anything supported by st.image (except list), str, or None
The avatar shown next to the message.
If ``avatar`` is ``None`` (default), the icon will be determined
from ``name`` as follows:
- If ``name`` is ``"user"`` or ``"human"``, the message will have a
default user icon.
- If ``name`` is ``"ai"`` or ``"assistant"``, the message will have
a default bot icon.
- For all other values of ``name``, the message will show the first
letter of the name.
In addition to the types supported by |st.image|_ (except list),
the following strings are valid:
- A single-character emoji. For example, you can set ``avatar="🧑💻"``
or ``avatar="🦖"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
.. |st.image| replace:: ``st.image``
.. _st.image: https://docs.streamlit.io/develop/api-reference/media/st.image
width : "stretch", "content", or int
The width of the chat message container. This can be one of the following:
- ``"stretch"`` (default): The width of the container matches the
width of the parent container.
- ``"content"``: The width of the container matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The container has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the container matches the width
of the parent container.
Returns
-------
Container
A single container that can hold multiple elements.
Examples
--------
You can use ``with`` notation to insert any element into an expander
>>> import streamlit as st
>>> import numpy as np
>>>
>>> with st.chat_message("user"):
... st.write("Hello 👋")
... st.line_chart(np.random.randn(30, 3))
.. output::
https://doc-chat-message-user.streamlit.app/
height: 450px
Or you can just call methods directly in the returned objects:
>>> import streamlit as st
>>> import numpy as np
>>>
>>> message = st.chat_message("assistant")
>>> message.write("Hello human")
>>> message.bar_chart(np.random.randn(30, 3))
.. output::
https://doc-chat-message-user1.streamlit.app/
height: 450px
streamlit.checkbox
Python Library Documentation: method checkbox in module streamlit.delta_generator
checkbox(label: 'str', value: 'bool' = False, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'bool' method of streamlit.delta_generator.DeltaGenerator instance
Display a checkbox widget.
Parameters
----------
label : str
A short label explaining to the user what this checkbox is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
value : bool
Preselect the checkbox when it first renders. This will be
cast to bool internally.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this checkbox's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the checkbox if set to ``True``.
The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "content", "stretch", or int
The width of the checkbox widget. This can be one of the following:
- ``"content"`` (default): The width of the widget matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the widget matches the width of the
parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Returns
-------
bool
Whether or not the checkbox is checked.
Examples
--------
>>> import streamlit as st
>>>
>>> agree = st.checkbox("I agree")
>>>
>>> if agree:
... st.write("Great!")
.. output::
https://doc-checkbox.streamlit.app/
height: 220px
streamlit.cli_util
Python Library Documentation: module streamlit.cli_util in streamlit
NAME
streamlit.cli_util - Utilities related to the CLI.
FUNCTIONS
open_browser(url: 'str') -> 'None'
Open a web browser pointing to a given URL.
We use this function instead of Python's `webbrowser` module because this
way we can capture stdout/stderr to avoid polluting the terminal with the
browser's messages. For example, Chrome always prints things like "Created
new window in existing browser session", and those get on the user's way.
url : str
The URL. Must include the protocol.
print_to_cli(message: 'str', **kwargs: 'Any') -> 'None'
Print a message to the terminal using click if available, else print
using the built-in print function.
You can provide any keyword arguments that click.secho supports.
style_for_cli(message: 'str', **kwargs: 'Any') -> 'str'
Style a message using click if available, else return the message
unchanged.
You can provide any keyword arguments that click.style supports.
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\cli_util.py
streamlit.code
Python Library Documentation: method code in module streamlit.delta_generator
code(body: 'SupportsStr', language: 'str | None' = 'python', *, line_numbers: 'bool' = False, wrap_lines: 'bool' = False, height: 'Height | None' = 'content', width: 'Width' = 'stretch') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a code block with optional syntax highlighting.
Parameters
----------
body : str
The string to display as code or monospace text.
language : str or None
The language that the code is written in, for syntax highlighting.
This defaults to ``"python"``. If this is ``None``, the code will
be plain, monospace text.
For a list of available ``language`` values, see
`react-syntax-highlighter
<https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/AVAILABLE_LANGUAGES_PRISM.MD>`_
on GitHub.
line_numbers : bool
An optional boolean indicating whether to show line numbers to the
left of the code block. This defaults to ``False``.
wrap_lines : bool
An optional boolean indicating whether to wrap lines. This defaults
to ``False``.
height : "content", "stretch", or int
The height of the code block element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
.. note::
Use scrolling containers sparingly. If you use scrolling
containers, avoid heights that exceed 500 pixels. Otherwise,
the scroll surface of the container might cover the majority of
the screen on mobile devices, which makes it hard to scroll the
rest of the app.
width : "stretch", "content", or int
The width of the code block element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Examples
--------
>>> import streamlit as st
>>>
>>> code = '''def hello():
... print("Hello, Streamlit!")'''
>>> st.code(code, language="python")
.. output::
https://doc-code.streamlit.app/
height: 220px
>>> import streamlit as st
>>> code = '''Is it a crown or boat?
... ii
... iiiiii
... WWw .iiiiiiii. ...:
... WWWWWWw .iiiiiiiiiiii. ........
... WWWWWWWWWWw iiiiiiiiiiiiiiii ...........
... WWWWWWWWWWWWWWwiiiiiiiiiiiiiiiii............
... WWWWWWWWWWWWWWWWWWwiiiiiiiiiiiiii.........
... WWWWWWWWWWWWWWWWWWWWWWwiiiiiiiiii.......
... WWWWWWWWWWWWWWWWWWWWWWWWWWwiiiiiii....
... WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWwiiii.
... -MMMWWWWWWWWWWWWWWWWWWWWWWMMM-
... '''
>>> st.code(code, language=None)
.. output::
https://doc-code-ascii.streamlit.app/
height: 380px
streamlit.color_picker
Python Library Documentation: method color_picker in module streamlit.delta_generator
color_picker(label: 'str', value: 'str | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'str' method of streamlit.delta_generator.DeltaGenerator instance
Display a color picker widget.
Parameters
----------
label : str
A short label explaining to the user what this input is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
value : str
The hex value of this widget when it first renders. If None,
defaults to black.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this color_picker's value
changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the color picker if set to
``True``. The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "content", "stretch", or int
The width of the color picker widget. This can be one of the
following:
- ``"content"`` (default): The width of the widget matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the widget matches the width of the
parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Returns
-------
str
The selected color as a hex string.
Examples
--------
>>> import streamlit as st
>>>
>>> color = st.color_picker("Pick A Color", "#00f900")
>>> st.write("The current color is", color)
.. output::
https://doc-color-picker.streamlit.app/
height: 335px
streamlit.column_config
Python Library Documentation: module streamlit.column_config in streamlit
NAME
streamlit.column_config
DESCRIPTION
Column types that can be configured via the ``column_config`` parameter of
``st.dataframe`` and ``st.data_editor``.
FUNCTIONS
AreaChartColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, pinned: 'bool | None' = None, y_min: 'int | float | None' = None, y_max: 'int | float | None' = None, color: 'ChartColor | None' = None) -> 'ColumnConfig'
Configure an area chart column in ``st.dataframe`` or ``st.data_editor``.
Cells need to contain a list of numbers. Chart columns are not editable
at the moment. This command needs to be used in the ``column_config`` parameter
of ``st.dataframe`` or ``st.data_editor``.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
y_min : int, float, or None
The minimum value on the y-axis for all cells in the column. If this is
``None`` (default), every cell will use the minimum of its data.
y_max : int, float, or None
The maximum value on the y-axis for all cells in the column. If this is
``None`` (default), every cell will use the maximum of its data.
color : "auto", "auto-inverse", str, or None
The color to use for the chart. This can be one of the following:
- ``None`` (default): The primary color is used.
- ``"auto"``: If the data is increasing, the chart is green; if the
data is decreasing, the chart is red.
- ``"auto-inverse"``: If the data is increasing, the chart is red; if
the data is decreasing, the chart is green.
- A single color value that is applied to all charts in the column.
In addition to the basic color palette (red, orange, yellow, green,
blue, violet, gray/grey, and primary), this supports hex codes like
``"#483d8b"``.
The basic color palette can be configured in the theme settings.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"sales": [
[0, 4, 26, 80, 100, 40],
[80, 20, 80, 35, 40, 100],
[10, 20, 80, 80, 70, 0],
[10, 100, 20, 100, 30, 100],
],
}
)
st.data_editor(
data_df,
column_config={
"sales": st.column_config.AreaChartColumn(
"Sales (last 6 months)",
width="medium",
help="The sales volume in the last 6 months",
y_min=0,
y_max=100,
),
},
hide_index=True,
)
.. output::
https://doc-areachart-column.streamlit.app/
height: 300px
AudioColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None) -> 'ColumnConfig'
Configure an audio column in ``st.dataframe`` or ``st.data_editor``.
Audio columns display an icon. When a user double clicks the icon in a cell,
Streamlit displays playback controls. To play an audio file, a cell must have
one of the following values:
- A URL to fetch the audio from. If you use `static file serving
<https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_, the
URL can be relative to your app's URL. Otherwise, the URL must be fully qualified with
a scheme, like ``"https://example.com/my_audio.mp3"``.
Paths to local audio files aren't supported.
- A data URL containing a Base64-encoded audio like ``"data:audio/mp3;base64,//uQ..."``.
Audio columns aren't editable at this time. This command must be used in the
``column_config`` parameter of ``st.dataframe`` or ``st.data_editor``.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), audio icons are center-aligned.
Examples
--------
You can use publicly accessible URLs or Base64-encoded audio data. To show
the playback controls, double click a cell in the audio column.
.. code-block:: python
:filename: streamlit_app.py
import base64
import pandas as pd
import streamlit as st
@st.cache_data
def load_audio_as_base64():
with open("cat-purr.mp3", "rb") as audio_file:
audio_bytes = audio_file.read()
return base64.b64encode(audio_bytes).decode("utf-8")
data_df = pd.DataFrame(
{
"source": [
"Small and fluffy house panther",
"Wikimedia, Performed by Muriel Nguyen Xuan and Stéphane Magnenat",
],
"audio": [
f"data:audio/mp3;base64,{load_audio_as_base64()}",
"https://upload.wikimedia.org/wikipedia/commons/c/c4/Muriel-Nguyen-Xuan-Chopin-valse-opus64-1.ogg",
],
}
)
st.dataframe(
data_df,
column_config={
"audio": st.column_config.AudioColumn("Preview Audio"),
},
)
.. output::
https://doc-audio-column.streamlit.app/
height: 400px
BarChartColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, pinned: 'bool | None' = None, y_min: 'int | float | None' = None, y_max: 'int | float | None' = None, color: 'ChartColor | None' = None) -> 'ColumnConfig'
Configure a bar chart column in ``st.dataframe`` or ``st.data_editor``.
Cells need to contain a list of numbers. Chart columns are not editable
at the moment. This command needs to be used in the ``column_config`` parameter
of ``st.dataframe`` or ``st.data_editor``.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
pinned: bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
y_min : int, float, or None
The minimum value on the y-axis for all cells in the column. If this is
``None`` (default), every cell will use the minimum of its data.
y_max : int, float, or None
The maximum value on the y-axis for all cells in the column. If this is
``None`` (default), every cell will use the maximum of its data.
color : "auto", "auto-inverse", str, or None
The color to use for the chart. This can be one of the following:
- ``None`` (default): The primary color is used.
- ``"auto"``: If the data is increasing, the chart is green; if the
data is decreasing, the chart is red.
- ``"auto-inverse"``: If the data is increasing, the chart is red; if
the data is decreasing, the chart is green.
- A single color value that is applied to all charts in the column.
In addition to the basic color palette (red, orange, yellow, green,
blue, violet, gray/grey, and primary), this supports hex codes like
``"#483d8b"``.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"sales": [
[0, 4, 26, 80, 100, 40],
[80, 20, 80, 35, 40, 100],
[10, 20, 80, 80, 70, 0],
[10, 100, 20, 100, 30, 100],
],
}
)
st.data_editor(
data_df,
column_config={
"sales": st.column_config.BarChartColumn(
"Sales (last 6 months)",
help="The sales volume in the last 6 months",
y_min=0,
y_max=100,
),
},
hide_index=True,
)
.. output::
https://doc-barchart-column.streamlit.app/
height: 300px
CheckboxColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None, default: 'bool | None' = None) -> 'ColumnConfig'
Configure a checkbox column in ``st.dataframe`` or ``st.data_editor``.
This is the default column type for boolean values. This command needs to be used in
the ``column_config`` parameter of ``st.dataframe`` or ``st.data_editor``.
When used with ``st.data_editor``, editing will be enabled with a checkbox widget.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
disabled : bool or None
Whether editing should be disabled for this column. If this is ``None``
(default), Streamlit will enable editing wherever possible.
If a column has mixed types, it may become uneditable regardless of
``disabled``.
required : bool or None
Whether edited cells in the column need to have a value. If this is
``False`` (default), the user can submit empty values for this column.
If this is ``True``, an edited cell in this column can only be
submitted if its value is not ``None``, and a new row will only be
submitted after the user fills in this column.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), checkboxes are center-aligned.
default : bool or None
Specifies the default value in this column when a new row is added by
the user. This defaults to ``None``.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"widgets": [
"st.selectbox",
"st.number_input",
"st.text_area",
"st.button",
],
"favorite": [True, False, False, True],
}
)
st.data_editor(
data_df,
column_config={
"favorite": st.column_config.CheckboxColumn(
"Your favorite?",
help="Select your **favorite** widgets",
default=False,
)
},
disabled=["widgets"],
hide_index=True,
)
.. output::
https://doc-checkbox-column.streamlit.app/
height: 300px
Column(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None) -> 'ColumnConfig'
Configure a generic column in ``st.dataframe`` or ``st.data_editor``.
The type of the column will be automatically inferred from the data type.
This command needs to be used in the ``column_config`` parameter of ``st.dataframe``
or ``st.data_editor``.
To change the type of the column and enable type-specific configuration options,
use one of the column types in the ``st.column_config`` namespace,
e.g. ``st.column_config.NumberColumn``.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
disabled : bool or None
Whether editing should be disabled for this column. If this is ``None``
(default), Streamlit will enable editing wherever possible.
If a column has mixed types, it may become uneditable regardless of
``disabled``.
required : bool or None
Whether edited cells in the column need to have a value. If this is
``False`` (default), the user can submit empty values for this column.
If this is ``True``, an edited cell in this column can only be
submitted if its value is not ``None``, and a new row will only be
submitted after the user fills in this column.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), the alignment depends on the column type (e.g., numbers
are right-aligned, text is left-aligned).
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"widgets": [
"st.selectbox",
"st.number_input",
"st.text_area",
"st.button",
],
}
)
st.data_editor(
data_df,
column_config={
"widgets": st.column_config.Column(
"Streamlit Widgets",
help="Streamlit **widget** commands 🎈",
width="medium",
required=True,
)
},
hide_index=True,
num_rows="dynamic",
)
.. output::
https://doc-column.streamlit.app/
height: 300px
DateColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None, default: 'datetime.date | None' = None, format: "str | Literal['localized', 'distance', 'iso8601'] | None" = None, min_value: 'datetime.date | None' = None, max_value: 'datetime.date | None' = None, step: 'int | None' = None) -> 'ColumnConfig'
Configure a date column in ``st.dataframe`` or ``st.data_editor``.
This is the default column type for date values. This command needs to be used in
the ``column_config`` parameter of ``st.dataframe`` or ``st.data_editor``. When used
with ``st.data_editor``, editing will be enabled with a date picker widget.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
disabled : bool or None
Whether editing should be disabled for this column. If this is ``None``
(default), Streamlit will enable editing wherever possible.
If a column has mixed types, it may become uneditable regardless of
``disabled``.
required : bool or None
Whether edited cells in the column need to have a value. If this is
``False`` (default), the user can submit empty values for this column.
If this is ``True``, an edited cell in this column can only be
submitted if its value is not ``None``, and a new row will only be
submitted after the user fills in this column.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), dates are left-aligned.
default : datetime.date or None
Specifies the default value in this column when a new row is added by
the user. This defaults to ``None``.
format : str, "localized", "distance", "iso8601", or None
A format string controlling how dates are displayed.
This can be one of the following values:
- ``None`` (default): Show the date in ``"YYYY-MM-DD"`` format (e.g.
"2025-03-04").
- ``"localized"``: Show the date in the default locale format (e.g.
"Mar 4, 2025" in the America/Los_Angeles timezone).
- ``"distance"``: Show the date in a relative format (e.g.
"a few seconds ago").
- ``"iso8601"``: Show the date in ISO 8601 format (e.g.
"2025-03-04").
- A momentJS format string: Format the date with a string, like
``"ddd, MMM Do"`` to show "Tue, Mar 4th". For available formats, see
`momentJS <https://momentjs.com/docs/#/displaying/format/>`_.
Formatting from ``column_config`` always takes precedence over
formatting from ``pandas.Styler``. The formatting does not impact the
return value when used in ``st.data_editor``.
min_value : datetime.date or None
The minimum date that can be entered. If this is ``None`` (default),
there will be no minimum.
max_value : datetime.date or None
The maximum date that can be entered. If this is ``None`` (default),
there will be no maximum.
step : int or None
The stepping interval in days. If this is ``None`` (default), the step
will be 1 day.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
from datetime import date
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"birthday": [
date(1980, 1, 1),
date(1990, 5, 3),
date(1974, 5, 19),
date(2001, 8, 17),
]
}
)
st.data_editor(
data_df,
column_config={
"birthday": st.column_config.DateColumn(
"Birthday",
min_value=date(1900, 1, 1),
max_value=date(2005, 1, 1),
format="DD.MM.YYYY",
step=1,
),
},
hide_index=True,
)
.. output::
https://doc-date-column.streamlit.app/
height: 300px
DatetimeColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None, default: 'datetime.datetime | None' = None, format: 'str | DateTimeFormat | None' = None, min_value: 'datetime.datetime | None' = None, max_value: 'datetime.datetime | None' = None, step: 'int | float | datetime.timedelta | None' = None, timezone: 'str | None' = None) -> 'ColumnConfig'
Configure a datetime column in ``st.dataframe`` or ``st.data_editor``.
This is the default column type for datetime values. This command needs to be
used in the ``column_config`` parameter of ``st.dataframe`` or
``st.data_editor``. When used with ``st.data_editor``, editing will be enabled
with a datetime picker widget.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
disabled : bool or None
Whether editing should be disabled for this column. If this is ``None``
(default), Streamlit will enable editing wherever possible.
If a column has mixed types, it may become uneditable regardless of
``disabled``.
required : bool or None
Whether edited cells in the column need to have a value. If this is
``False`` (default), the user can submit empty values for this column.
If this is ``True``, an edited cell in this column can only be
submitted if its value is not ``None``, and a new row will only be
submitted after the user fills in this column.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), datetimes are left-aligned.
default : datetime.datetime or None
Specifies the default value in this column when a new row is added by
the user. This defaults to ``None``.
format : str, "localized", "distance", "calendar", "iso8601", or None
A format string controlling how datetimes are displayed.
This can be one of the following values:
- ``None`` (default): Show the datetime in ``"YYYY-MM-DD HH:mm:ss"``
format (e.g. "2025-03-04 20:00:00").
- ``"localized"``: Show the datetime in the default locale format (e.g.
"Mar 4, 2025, 12:00:00 PM" in the America/Los_Angeles timezone).
- ``"distance"``: Show the datetime in a relative format (e.g.
"a few seconds ago").
- ``"calendar"``: Show the datetime in a calendar format (e.g.
"Today at 8:00 PM").
- ``"iso8601"``: Show the datetime in ISO 8601 format (e.g.
"2025-03-04T20:00:00.000Z").
- A momentJS format string: Format the datetime with a string, like
``"ddd ha"`` to show "Tue 8pm". For available formats, see
`momentJS <https://momentjs.com/docs/#/displaying/format/>`_.
Formatting from ``column_config`` always takes precedence over
formatting from ``pandas.Styler``. The formatting does not impact the
return value when used in ``st.data_editor``.
min_value : datetime.datetime or None
The minimum datetime that can be entered. If this is ``None``
(default), there will be no minimum.
max_value : datetime.datetime or None
The maximum datetime that can be entered. If this is ``None``
(default), there will be no maximum.
step : int, float, datetime.timedelta, or None
The stepping interval in seconds. If this is ``None`` (default), the
step will be 1 second.
timezone : str or None
The timezone of this column. If this is ``None`` (default), the
timezone is inferred from the underlying data.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
from datetime import datetime
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"appointment": [
datetime(2024, 2, 5, 12, 30),
datetime(2023, 11, 10, 18, 0),
datetime(2024, 3, 11, 20, 10),
datetime(2023, 9, 12, 3, 0),
]
}
)
st.data_editor(
data_df,
column_config={
"appointment": st.column_config.DatetimeColumn(
"Appointment",
min_value=datetime(2023, 6, 1),
max_value=datetime(2025, 1, 1),
format="D MMM YYYY, h:mm a",
step=60,
),
},
hide_index=True,
)
.. output::
https://doc-datetime-column.streamlit.app/
height: 300px
ImageColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None) -> 'ColumnConfig'
Configure an image column in ``st.dataframe`` or ``st.data_editor``.
Image columns display an inline thumbnail. When a user double clicks a
thumbnail in a cell, Streamlit displays a larger image. To display an
image, a cell must have one of the following values:
- A URL to fetch the image from. If you use `static file serving
<https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_, the
URL can be relative to your app's URL. Otherwise, the URL must be fully qualified with
a scheme, like ``"https://example.com/my_image.jpg"``.
Paths to local image files aren't supported.
- A data URL containing an SVG XML like ``"data:image/svg+xml;utf8,<svg xmlns=...</svg>"``.
- A data URL containing a Base64 encoded image like ``"data:image/png;base64,iVBO..."``.
Image columns aren't editable at this time. This command must be used in the
``column_config`` parameter of ``st.dataframe`` or ``st.data_editor``.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), images are center-aligned.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"apps": [
"https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/5435b8cb-6c6c-490b-9608-799b543655d3/Home_Page.png",
"https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/ef9a7627-13f2-47e5-8f65-3f69bb38a5c2/Home_Page.png",
"https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/31b99099-8eae-4ff8-aa89-042895ed3843/Home_Page.png",
"https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/6a399b09-241e-4ae7-a31f-7640dc1d181e/Home_Page.png",
],
}
)
st.data_editor(
data_df,
column_config={
"apps": st.column_config.ImageColumn(
"Preview Image", help="Streamlit app preview screenshots"
)
},
hide_index=True,
)
.. output::
https://doc-image-column.streamlit.app/
height: 300px
JsonColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None) -> 'ColumnConfig'
Configure a JSON column in ``st.dataframe`` or ``st.data_editor``.
Cells need to contain JSON strings or JSON-compatible objects. JSON columns
are not editable at the moment. This command needs to be used in the
``column_config`` parameter of ``st.dataframe`` or ``st.data_editor``.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), JSON content is left-aligned.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"json": [
{"foo": "bar", "bar": "baz"},
{"foo": "baz", "bar": "qux"},
{"foo": "qux", "bar": "foo"},
None,
],
}
)
st.dataframe(
data_df,
column_config={
"json": st.column_config.JsonColumn(
"JSON Data",
help="JSON strings or objects",
width="large",
),
},
hide_index=True,
)
.. output::
https://doc-json-column.streamlit.app/
height: 300px
LineChartColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, pinned: 'bool | None' = None, y_min: 'int | float | None' = None, y_max: 'int | float | None' = None, color: 'ChartColor | None' = None) -> 'ColumnConfig'
Configure a line chart column in ``st.dataframe`` or ``st.data_editor``.
Cells need to contain a list of numbers. Chart columns are not editable
at the moment. This command needs to be used in the ``column_config`` parameter
of ``st.dataframe`` or ``st.data_editor``.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
y_min : int, float, or None
The minimum value on the y-axis for all cells in the column. If this is
``None`` (default), every cell will use the minimum of its data.
y_max : int, float, or None
The maximum value on the y-axis for all cells in the column. If this is
``None`` (default), every cell will use the maximum of its data.
color : "auto", "auto-inverse", str, or None
The color to use for the chart. This can be one of the following:
- ``None`` (default): The primary color is used.
- ``"auto"``: If the data is increasing, the chart is green; if the
data is decreasing, the chart is red.
- ``"auto-inverse"``: If the data is increasing, the chart is red; if
the data is decreasing, the chart is green.
- A single color value that is applied to all charts in the column.
In addition to the basic color palette (red, orange, yellow, green,
blue, violet, gray/grey, and primary), this supports hex codes like
``"#483d8b"``.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"sales": [
[0, 4, 26, 80, 100, 40],
[80, 20, 80, 35, 40, 100],
[10, 20, 80, 80, 70, 0],
[10, 100, 20, 100, 30, 100],
],
}
)
st.data_editor(
data_df,
column_config={
"sales": st.column_config.LineChartColumn(
"Sales (last 6 months)",
width="medium",
help="The sales volume in the last 6 months",
y_min=0,
y_max=100,
),
},
hide_index=True,
)
.. output::
https://doc-linechart-column.streamlit.app/
height: 300px
LinkColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None, default: 'str | None' = None, max_chars: 'int | None' = None, validate: 'str | None' = None, display_text: 'str | None' = None) -> 'ColumnConfig'
Configure a link column in ``st.dataframe`` or ``st.data_editor``.
The cell values need to be string and will be shown as clickable links.
This command needs to be used in the column_config parameter of ``st.dataframe``
or ``st.data_editor``. When used with ``st.data_editor``, editing will be enabled
with a text input widget.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
disabled : bool or None
Whether editing should be disabled for this column. If this is ``None``
(default), Streamlit will enable editing wherever possible.
If a column has mixed types, it may become uneditable regardless of
``disabled``.
required : bool or None
Whether edited cells in the column need to have a value. If this is
``False`` (default), the user can submit empty values for this column.
If this is ``True``, an edited cell in this column can only be
submitted if its value is not ``None``, and a new row will only be
submitted after the user fills in this column.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), links without ``display_text`` are left-aligned, while links
with ``display_text`` (including icon-only links) are center-aligned.
default : str or None
Specifies the default value in this column when a new row is added by
the user. This defaults to ``None``.
max_chars : int or None
The maximum number of characters that can be entered. If this is
``None`` (default), there will be no maximum.
validate : str or None
A JS-flavored regular expression (e.g. ``"^https://.+$"``) that edited
values are validated against. If the user input is invalid, it will not
be submitted.
display_text : str or None
The text that is displayed in the cell. This can be one of the
following:
- ``None`` (default) to display the URL itself.
- A string that is displayed in every cell, e.g. ``"Open link"``.
- A Material icon that is displayed in every cell, e.g. ``":material/open_in_new:"``.
- A JS-flavored regular expression (detected by usage of parentheses)
to extract a part of the URL via a capture group. For example, use
``"https://(.*?)\.example\.com"`` to extract the display text
"foo" from the URL "\https://foo.example.com".
.. Comment: The backslash in front of foo.example.com prevents a hyperlink in docs.
For more complex cases, you may use `Pandas Styler's format
<https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.format.html>`_
function on the underlying dataframe. Note that this makes the app slow,
doesn't work with editable columns, and might be removed in the future.
Text formatting from ``column_config`` always takes precedence over
text formatting from ``pandas.Styler``.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"apps": [
"https://roadmap.streamlit.app",
"https://extras.streamlit.app",
"https://issues.streamlit.app",
"https://30days.streamlit.app",
],
"creator": [
"https://github.com/streamlit",
"https://github.com/arnaudmiribel",
"https://github.com/streamlit",
"https://github.com/streamlit",
],
}
)
st.data_editor(
data_df,
column_config={
"apps": st.column_config.LinkColumn(
"Trending apps",
help="The top trending Streamlit apps",
validate=r"^https://[a-z]+\.streamlit\.app$",
max_chars=100,
display_text=r"https://(.*?)\.streamlit\.app",
),
"creator": st.column_config.LinkColumn(
"App Creator", display_text="Open profile"
),
},
hide_index=True,
)
.. output::
https://doc-link-column.streamlit.app/
height: 300px
ListColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, pinned: 'bool | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, default: 'Iterable[str] | None' = None) -> 'ColumnConfig'
Configure a list column in ``st.dataframe`` or ``st.data_editor``.
This is the default column type for list-like values. This command needs to
be used in the ``column_config`` parameter of ``st.dataframe`` or
``st.data_editor``. When used with ``st.data_editor``, users can freely
type in new options and remove existing ones.
.. Note::
Editing for non-string or mixed type lists can cause issues with Arrow
serialization. We recommend that you disable editing for these columns
or convert all list values to strings.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
disabled : bool or None
Whether editing should be disabled for this column. If this is ``None``
(default), Streamlit will enable editing wherever possible.
If a column has mixed types, it may become uneditable regardless of
``disabled``.
required : bool or None
Whether edited cells in the column need to have a value. If this is
``False`` (default), the user can submit empty values for this column.
If this is ``True``, an edited cell in this column can only be
submitted if its value is not ``None``, and a new row will only be
submitted after the user fills in this column.
default : Iterable of str or None
Specifies the default value in this column when a new row is added by
the user. This defaults to ``None``.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"sales": [
[0, 4, 26, 80, 100, 40],
[80, 20, 80, 35, 40, 100],
[10, 20, 80, 80, 70, 0],
[10, 100, 20, 100, 30, 100],
],
}
)
st.data_editor(
data_df,
column_config={
"sales": st.column_config.ListColumn(
"Sales (last 6 months)",
help="The sales volume in the last 6 months",
width="medium",
),
},
hide_index=True,
)
.. output::
https://doc-list-column.streamlit.app/
height: 300px
MultiselectColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, pinned: 'bool | None' = None, default: 'Iterable[str] | None' = None, options: 'Iterable[str] | None' = None, accept_new_options: 'bool | None' = None, color: "str | Literal['auto'] | ThemeColor | Iterable[str | ThemeColor] | None" = None, format_func: 'Callable[[str], str] | None' = None) -> 'ColumnConfig'
Configure a multiselect column in ``st.dataframe`` or ``st.data_editor``.
This command needs to be used in the ``column_config`` parameter of
``st.dataframe`` or ``st.data_editor``. When used with ``st.data_editor``,
users can select options from a dropdown menu. You can configure the
column to allow freely typed options, too.
You can also use this column type to display colored labels in a read-only
``st.dataframe``.
.. Note::
Editing for non-string or mixed type lists can cause issues with Arrow
serialization. We recommend that you disable editing for these columns
or convert all list values to strings.
Parameters
----------
label : str or None
The label shown at the top of the column. If None (default),
the column name is used.
width : "small", "medium", "large", or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
disabled : bool or None
Whether editing should be disabled for this column. Defaults to False.
required : bool or None
Whether edited cells in the column need to have a value. If True, an edited cell
can only be submitted if it has a value other than None. Defaults to False.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
default : Iterable of str or None
Specifies the default value in this column when a new row is added by the user.
options : Iterable of str or None
The options that can be selected during editing.
accept_new_options : bool or None
Whether the user can add selections that aren't included in ``options``.
If this is ``False`` (default), the user can only select from the
items in ``options``. If this is ``True``, the user can enter new
items that don't exist in ``options``.
When a user enters and selects a new item, it is included in the
returned cell list value as a string. The new item is not added to
the options drop-down menu.
color : str, Iterable of str, or None
The color to use for different options. This can be:
- None (default): The options are displayed without color.
- ``"auto"``: The options are colored based on the configured categorical chart colors.
- A single color value that is used for all options. This can be one of
the following strings:
- ``"primary"`` to use the primary theme color.
- A CSS named color name like ``"darkBlue"`` or ``"maroon"``.
- A hex color code like ``"#483d8b"`` or ``"#6A5ACD80"``.
- An RGB or RGBA color code like ``"rgb(255,0,0)"`` or
``"RGB(70, 130, 180, .7)"``.
- An HSL or HSLA color code like ``"hsl(248, 53%, 58%)"``
or ``"HSL(147, 50%, 47%, .3)"``.
- An iterable of color values that are mapped to the options. The colors
are applied in sequence, cycling through the iterable if there are
more options than colors.
format_func : function or None
Function to modify the display of the options. It receives
the raw option defined in ``options`` as an argument and should output
the label to be shown for that option. When used in ``st.data_editor``,
this has no impact on the returned value. If this is ``None``
(default), the raw option is used as the label.
Examples
--------
**Example 1: Editable multiselect column**
To customize the label colors, provide a list of colors to the ``color``
parameter. You can also format the option labels with the ``format_func``
parameter.
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"category": [
["exploration", "visualization"],
["llm", "visualization"],
["exploration"],
],
}
)
st.data_editor(
data_df,
column_config={
"category": st.column_config.MultiselectColumn(
"App Categories",
help="The categories of the app",
options=[
"exploration",
"visualization",
"llm",
],
color=["#ffa421", "#803df5", "#00c0f2"],
format_func=lambda x: x.capitalize(),
),
},
)
.. output::
https://doc-multiselect-column-1.streamlit.app/
height: 300px
**Example 2: Colored tags for st.dataframe**
When using ``st.dataframe``, the multiselect column is read-only
and can be used to display colored tags. In this example, the dataframe
uses the primary theme color for all tags.
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"category": [
["exploration", "visualization"],
["llm", "visualization"],
["exploration"],
],
}
)
st.dataframe(
data_df,
column_config={
"category": st.column_config.MultiselectColumn(
"App Categories",
options=["exploration", "visualization", "llm"],
color="primary",
format_func=lambda x: x.capitalize(),
),
},
)
.. output::
https://doc-multiselect-column-2.streamlit.app/
height: 300px
NumberColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None, default: 'int | float | None' = None, format: 'str | NumberFormat | None' = None, min_value: 'int | float | None' = None, max_value: 'int | float | None' = None, step: 'int | float | None' = None) -> 'ColumnConfig'
Configure a number column in ``st.dataframe`` or ``st.data_editor``.
This is the default column type for integer and float values. This command needs to
be used in the ``column_config`` parameter of ``st.dataframe`` or ``st.data_editor``.
When used with ``st.data_editor``, editing will be enabled with a numeric input widget.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
disabled : bool or None
Whether editing should be disabled for this column. If this is ``None``
(default), Streamlit will enable editing wherever possible.
If a column has mixed types, it may become uneditable regardless of
``disabled``.
required : bool or None
Whether edited cells in the column need to have a value. If this is
``False`` (default), the user can submit empty values for this column.
If this is ``True``, an edited cell in this column can only be
submitted if its value is not ``None``, and a new row will only be
submitted after the user fills in this column.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), numbers are right-aligned. Some number-like types (e.g.,
durations) may use a different default alignment.
default : int, float, or None
Specifies the default value in this column when a new row is added by
the user. This defaults to ``None``.
format : str, "plain", "localized", "percent", "dollar", "euro", "yen", "accounting", "compact", "scientific", "engineering", or None
A format string controlling how numbers are displayed.
This can be one of the following values:
- ``None`` (default): Streamlit infers the formatting from the data.
- ``"plain"``: Show the full number without any formatting (e.g. "1234.567").
- ``"localized"``: Show the number in the default locale format (e.g. "1,234.567").
- ``"percent"``: Show the number as a percentage (e.g. "123456.70%").
- ``"dollar"``: Show the number as a dollar amount (e.g. "$1,234.57").
- ``"euro"``: Show the number as a euro amount (e.g. "€1,234.57").
- ``"yen"``: Show the number as a yen amount (e.g. "¥1,235").
- ``"accounting"``: Show the number in an accounting format (e.g. "1,234.00").
- ``"bytes"``: Show the number in a byte format (e.g. "1.2KB").
- ``"compact"``: Show the number in a compact format (e.g. "1.2K").
- ``"scientific"``: Show the number in scientific notation (e.g. "1.235E3").
- ``"engineering"``: Show the number in engineering notation (e.g. "1.235E3").
- printf-style format string: Format the number with a printf
specifier, like ``"%d"`` to show a signed integer (e.g. "1234") or
``"%X"`` to show an unsigned hexadecimal integer (e.g. "4D2"). You
can also add prefixes and suffixes. To show British pounds, use
``"£ %.2f"`` (e.g. "£ 1234.57"). Use ``,`` for thousand separators
(e.g. ``"%,d"`` yields ``"1,234"``). For more information, see
`sprintf-js
<https://github.com/alexei/sprintf.js?tab=readme-ov-file#format-specification>`_.
Formatting from ``column_config`` always takes precedence over
formatting from ``pandas.Styler``. The formatting does not impact the
return value when used in ``st.data_editor``.
min_value : int, float, or None
The minimum value that can be entered. If this is ``None`` (default),
there will be no minimum.
max_value : int, float, or None
The maximum value that can be entered. If this is ``None`` (default),
there will be no maximum.
step : int, float, or None
The precision of numbers that can be entered. If this ``None``
(default), integer columns will have a step of 1 and float columns will
have unrestricted precision. In this case, some floats may display like
integers. Setting ``step`` for float columns will ensure a consistent
number of digits after the decimal are displayed.
If ``format`` is a predefined format like ``"dollar"``, ``step``
overrides the display precision. If ``format`` is a printf-style format
string, ``step`` will not change the display precision.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"price": [20, 950, 250, 500],
}
)
st.data_editor(
data_df,
column_config={
"price": st.column_config.NumberColumn(
"Price (in USD)",
help="The price of the product in USD",
min_value=0,
max_value=1000,
step=1,
format="$%d",
)
},
hide_index=True,
)
.. output::
https://doc-number-column.streamlit.app/
height: 300px
ProgressColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, pinned: 'bool | None' = None, format: 'str | NumberFormat | None' = None, min_value: 'int | float | None' = None, max_value: 'int | float | None' = None, step: 'int | float | None' = None, color: 'ChartColor | None' = None) -> 'ColumnConfig'
Configure a progress column in ``st.dataframe`` or ``st.data_editor``.
Cells need to contain a number. Progress columns are not editable at the moment.
This command needs to be used in the ``column_config`` parameter of ``st.dataframe``
or ``st.data_editor``.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
format : str, "plain", "localized", "percent", "dollar", "euro", "yen", "accounting", "compact", "scientific", "engineering", or None
A format string controlling how the numbers are displayed.
This can be one of the following values:
- ``None`` (default): Streamlit infers the formatting from the data.
- ``"plain"``: Show the full number without any formatting (e.g. "1234.567").
- ``"localized"``: Show the number in the default locale format (e.g. "1,234.567").
- ``"percent"``: Show the number as a percentage (e.g. "123456.70%").
- ``"dollar"``: Show the number as a dollar amount (e.g. "$1,234.57").
- ``"euro"``: Show the number as a euro amount (e.g. "€1,234.57").
- ``"yen"``: Show the number as a yen amount (e.g. "¥1,235").
- ``"accounting"``: Show the number in an accounting format (e.g. "1,234.00").
- ``"bytes"``: Show the number in a byte format (e.g. "1.2KB").
- ``"compact"``: Show the number in a compact format (e.g. "1.2K").
- ``"scientific"``: Show the number in scientific notation (e.g. "1.235E3").
- ``"engineering"``: Show the number in engineering notation (e.g. "1.235E3").
- printf-style format string: Format the number with a printf
specifier, like ``"%d"`` to show a signed integer (e.g. "1234") or
``"%X"`` to show an unsigned hexadecimal integer (e.g. "4D2"). You
can also add prefixes and suffixes. To show British pounds, use
``"£ %.2f"`` (e.g. "£ 1234.57"). Use ``,`` for thousand separators
(e.g. ``"%,d"`` yields ``"1,234"``). For more information, see
`sprintf-js
<https://github.com/alexei/sprintf.js?tab=readme-ov-file#format-specification>`_.
Number formatting from ``column_config`` always takes precedence over
number formatting from ``pandas.Styler``. The number formatting does
not impact the return value when used in ``st.data_editor``.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
min_value : int, float, or None
The minimum value of the progress bar. If this is ``None`` (default),
the minimum will be 0.
max_value : int, float, or None
The maximum value of the progress bar. If this is ``None`` (default),
the maximum will be 100 for integer values and 1.0 for float values.
step : int, float, or None
The precision of numbers. If this is ``None`` (default), integer columns
will have a step of 1 and float columns will have a step of 0.01.
Setting ``step`` for float columns will ensure a consistent number of
digits after the decimal are displayed.
color : "auto", "auto-inverse", str, or None
The color to use for the chart. This can be one of the following:
- ``None`` (default): The primary color is used.
- ``"auto"``: If the value is more than half, the bar is green; if the
value is less than half, the bar is red.
- ``"auto-inverse"``: If the value is more than half, the bar is red;
if the value is less than half, the bar is green.
- A single color value that is applied to all charts in the column.
In addition to the basic color palette (red, orange, yellow, green,
blue, violet, gray/grey, and primary), this supports hex codes like
``"#483d8b"``.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"sales": [200, 550, 1000, 80],
}
)
st.data_editor(
data_df,
column_config={
"sales": st.column_config.ProgressColumn(
"Sales volume",
help="The sales volume in USD",
format="$%f",
min_value=0,
max_value=1000,
),
},
hide_index=True,
)
.. output::
https://doc-progress-column.streamlit.app/
height: 300px
SelectboxColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, pinned: 'bool | None' = None, default: 'SelectboxOptionValue | None' = None, options: 'Iterable[SelectboxOptionValue] | None' = None, format_func: 'Callable[[SelectboxOptionValue], str] | None' = None) -> 'ColumnConfig'
Configure a selectbox column in ``st.dataframe`` or ``st.data_editor``.
This is the default column type for Pandas categorical values. This command needs to
be used in the ``column_config`` parameter of ``st.dataframe`` or ``st.data_editor``.
When used with ``st.data_editor``, editing will be enabled with a selectbox widget.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
disabled : bool or None
Whether editing should be disabled for this column. If this is ``None``
(default), Streamlit will enable editing wherever possible.
If a column has mixed types, it may become uneditable regardless of
``disabled``.
required : bool or None
Whether edited cells in the column need to have a value. If this is
``False`` (default), the user can submit empty values for this column.
If this is ``True``, an edited cell in this column can only be
submitted if its value is not ``None``, and a new row will only be
submitted after the user fills in this column.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
default : str, int, float, bool, or None
Specifies the default value in this column when a new row is added by
the user. This defaults to ``None``.
options : Iterable[str, int, float, bool] or None
The options that can be selected during editing. If this is ``None``
(default), the options will be inferred from the underlying dataframe
column if its dtype is "category". For more information, see `Pandas docs
<https://pandas.pydata.org/docs/user_guide/categorical.html>`_).
format_func : function or None
Function to modify the display of the options. It receives
the raw option defined in ``options`` as an argument and should output
the label to be shown for that option. If this is ``None`` (default),
the raw option is used as the label.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"category": [
"📊 Data Exploration",
"📈 Data Visualization",
"🤖 LLM",
"📊 Data Exploration",
],
}
)
st.data_editor(
data_df,
column_config={
"category": st.column_config.SelectboxColumn(
"App Category",
help="The category of the app",
width="medium",
options=[
"📊 Data Exploration",
"📈 Data Visualization",
"🤖 LLM",
],
required=True,
)
},
hide_index=True,
)
.. output::
https://doc-selectbox-column.streamlit.app/
height: 300px
TextColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None, default: 'str | None' = None, max_chars: 'int | None' = None, validate: 'str | None' = None) -> 'ColumnConfig'
Configure a text column in ``st.dataframe`` or ``st.data_editor``.
This is the default column type for string values. This command needs to be used in the
``column_config`` parameter of ``st.dataframe`` or ``st.data_editor``. When used with
``st.data_editor``, editing will be enabled with a text input widget.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
disabled : bool or None
Whether editing should be disabled for this column. If this is ``None``
(default), Streamlit will enable editing wherever possible.
If a column has mixed types, it may become uneditable regardless of
``disabled``.
required : bool or None
Whether edited cells in the column need to have a value. If this is
``False`` (default), the user can submit empty values for this column.
If this is ``True``, an edited cell in this column can only be
submitted if its value is not ``None``, and a new row will only be
submitted after the user fills in this column.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), text is left-aligned.
default : str or None
Specifies the default value in this column when a new row is added by
the user. This defaults to ``None``.
max_chars : int or None
The maximum number of characters that can be entered. If this is
``None`` (default), there will be no maximum.
validate : str or None
A JS-flavored regular expression (e.g. ``"^[a-z]+$"``) that edited
values are validated against. If the user input is invalid, it will not
be submitted.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"widgets": [
"st.selectbox",
"st.number_input",
"st.text_area",
"st.button",
],
}
)
st.data_editor(
data_df,
column_config={
"widgets": st.column_config.TextColumn(
"Widgets",
help="Streamlit **widget** commands 🎈",
default="st.",
max_chars=50,
validate=r"^st\.[a-z_]+$",
)
},
hide_index=True,
)
.. output::
https://doc-text-column.streamlit.app/
height: 300px
TimeColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, disabled: 'bool | None' = None, required: 'bool | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None, default: 'datetime.time | None' = None, format: "str | Literal['localized', 'iso8601'] | None" = None, min_value: 'datetime.time | None' = None, max_value: 'datetime.time | None' = None, step: 'int | float | datetime.timedelta | None' = None) -> 'ColumnConfig'
Configure a time column in ``st.dataframe`` or ``st.data_editor``.
This is the default column type for time values. This command needs to be used in
the ``column_config`` parameter of ``st.dataframe`` or ``st.data_editor``. When
used with ``st.data_editor``, editing will be enabled with a time picker widget.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
disabled : bool or None
Whether editing should be disabled for this column. If this is ``None``
(default), Streamlit will enable editing wherever possible.
If a column has mixed types, it may become uneditable regardless of
``disabled``.
required : bool or None
Whether edited cells in the column need to have a value. If this is
``False`` (default), the user can submit empty values for this column.
If this is ``True``, an edited cell in this column can only be
submitted if its value is not ``None``, and a new row will only be
submitted after the user fills in this column.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), times are left-aligned.
default : datetime.time or None
Specifies the default value in this column when a new row is added by
the user. This defaults to ``None``.
format : str, "localized", "iso8601", or None
A format string controlling how times are displayed.
This can be one of the following values:
- ``None`` (default): Show the time in ``"HH:mm:ss"`` format (e.g.
"20:00:00").
- ``"localized"``: Show the time in the default locale format (e.g.
"12:00:00 PM" in the America/Los_Angeles timezone).
- ``"iso8601"``: Show the time in ISO 8601 format (e.g.
"20:00:00.000Z").
- A momentJS format string: Format the time with a string, like
``"ha"`` to show "8pm". For available formats, see
`momentJS <https://momentjs.com/docs/#/displaying/format/>`_.
Formatting from ``column_config`` always takes precedence over
formatting from ``pandas.Styler``. The formatting does not impact the
return value when used in ``st.data_editor``.
min_value : datetime.time or None
The minimum time that can be entered. If this is ``None`` (default),
there will be no minimum.
max_value : datetime.time or None
The maximum time that can be entered. If this is ``None`` (default),
there will be no maximum.
step : int, float, datetime.timedelta, or None
The stepping interval in seconds. If this is ``None`` (default), the
step will be 1 second.
Examples
--------
.. code-block:: python
:filename: streamlit_app.py
from datetime import time
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"appointment": [
time(12, 30),
time(18, 0),
time(9, 10),
time(16, 25),
]
}
)
st.data_editor(
data_df,
column_config={
"appointment": st.column_config.TimeColumn(
"Appointment",
min_value=time(8, 0, 0),
max_value=time(19, 0, 0),
format="hh:mm a",
step=60,
),
},
hide_index=True,
)
.. output::
https://doc-time-column.streamlit.app/
height: 300px
VideoColumn(label: 'str | None' = None, *, width: 'ColumnWidth | None' = None, help: 'str | None' = None, pinned: 'bool | None' = None, alignment: 'ContentAlignment | None' = None) -> 'ColumnConfig'
Configure a video column in ``st.dataframe`` or ``st.data_editor``.
Video columns display an icon. When a user double clicks the icon in a cell,
Streamlit displays playback controls. To display a video, a cell must have
one of the following values:
- A URL to fetch the video from. If you use `static file serving
<https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_, the
URL can be relative to your app's URL. Otherwise, the URL must be fully qualified with
a scheme, like ``"https://example.com/my_video.mp4"``.
Paths to local video files and YouTube URLs aren't supported.
- A data URL containing a Base64-encoded video, like ``"data:video/mp4;base64,AAAA..."``.
Video columns aren't editable at this time. This command must be used in the
``column_config`` parameter of ``st.dataframe`` or ``st.data_editor``.
Parameters
----------
label : str or None
The label shown at the top of the column. If this is ``None``
(default), the column name is used.
width : "small", "medium", "large", int, or None
The display width of the column. If this is ``None`` (default), the
column will be sized to fit the cell contents. Otherwise, this can be
one of the following:
- ``"small"``: 75px wide
- ``"medium"``: 200px wide
- ``"large"``: 400px wide
- An integer specifying the width in pixels
If the total width of all columns is less than the width of the
dataframe, the remaining space will be distributed evenly among all
columns.
help : str or None
A tooltip that gets displayed when hovering over the column label. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown, including
the Markdown directives described in the ``body`` parameter of
``st.markdown``.
pinned : bool or None
Whether the column is pinned. A pinned column will stay visible on the
left side no matter where the user scrolls. If this is ``None``
(default), Streamlit will decide: index columns are pinned, and data
columns are not pinned.
alignment : "left", "center", "right", or None
The horizontal alignment of cell content. If this is ``None``
(default), video icons are center-aligned.
Examples
--------
To show the playback controls, double click a cell in the video column.
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
data_df = pd.DataFrame(
{
"description": [
"Get started with Streamlit",
"Get started with Community Cloud",
],
"video": [
"https://s3-us-west-2.amazonaws.com/assets.streamlit.io/videos/hero-video.mp4",
"https://s3-us-west-2.amazonaws.com/assets.streamlit.io/videos/streamlit_sharing_silent.mp4",
],
}
)
st.dataframe(
data_df,
column_config={
"video": st.column_config.VideoColumn("Preview Video"),
},
)
.. output::
https://doc-video-column.streamlit.app/
height: 400px
DATA
__all__ = ['AreaChartColumn', 'AudioColumn', 'BarChartColumn', 'Checkb...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\column_config.py
streamlit.columns
Python Library Documentation: method columns in module streamlit.delta_generator
columns(spec: 'SpecType', *, gap: 'Gap | None' = 'small', vertical_alignment: "Literal['top', 'center', 'bottom']" = 'top', border: 'bool' = False, width: 'WidthWithoutContent' = 'stretch') -> 'list[DeltaGenerator]' method of streamlit.delta_generator.DeltaGenerator instance
Insert containers laid out as side-by-side columns.
Inserts a number of multi-element containers laid out side-by-side and
returns a list of container objects.
To add elements to the returned containers, you can use the ``with`` notation
(preferred) or just call methods directly on the returned object. See
examples below.
.. note::
To follow best design practices and maintain a good appearance on
all screen sizes, don't nest columns more than once.
Parameters
----------
spec : int or Iterable of numbers
Controls the number and width of columns to insert. Can be one of:
- An integer that specifies the number of columns. All columns have equal
width in this case.
- An Iterable of numbers (int or float) that specify the relative width of
each column. E.g. ``[0.7, 0.3]`` creates two columns where the first
one takes up 70% of the available with and the second one takes up 30%.
Or ``[1, 2, 3]`` creates three columns where the second one is two times
the width of the first one, and the third one is three times that width.
gap : "xxsmall", "xsmall", "small", "medium", "large", "xlarge", "xxlarge", or None
The size of the gap between the columns. This can be one of the
following:
- ``"xxsmall"``: 0.25rem gap between the columns.
- ``"xsmall"``: 0.5rem gap between the columns.
- ``"small"`` (default): 1rem gap between the columns.
- ``"medium"``: 2rem gap between the columns.
- ``"large"``: 4rem gap between the columns.
- ``"xlarge"``: 6rem gap between the columns.
- ``"xxlarge"``: 8rem gap between the columns.
- ``None``: No gap between the columns.
The rem unit is relative to the ``theme.baseFontSize``
configuration option.
vertical_alignment : "top", "center", or "bottom"
The vertical alignment of the content inside the columns. The
default is ``"top"``.
border : bool
Whether to show a border around the column containers. If this is
``False`` (default), no border is shown. If this is ``True``, a
border is shown around each column.
width : "stretch" or int
The width of the column group. This can be one of the following:
- ``"stretch"`` (default): The width of the column group matches the
width of the parent container.
- An integer specifying the width in pixels: The column group has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the column group matches the
width of the parent container.
Returns
-------
list of containers
A list of container objects.
Examples
--------
**Example 1: Use context management**
You can use the ``with`` statement to insert any element into a column:
>>> import streamlit as st
>>>
>>> col1, col2, col3 = st.columns(3)
>>>
>>> with col1:
... st.header("A cat")
... st.image("https://static.streamlit.io/examples/cat.jpg")
>>>
>>> with col2:
... st.header("A dog")
... st.image("https://static.streamlit.io/examples/dog.jpg")
>>>
>>> with col3:
... st.header("An owl")
... st.image("https://static.streamlit.io/examples/owl.jpg")
.. output::
https://doc-columns1.streamlit.app/
height: 620px
**Example 2: Use commands as container methods**
You can just call methods directly on the returned objects:
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = rng(0).standard_normal((10, 1))
>>> col1, col2 = st.columns([3, 1])
>>>
>>> col1.subheader("A wide column with a chart")
>>> col1.line_chart(df)
>>>
>>> col2.subheader("A narrow column with the data")
>>> col2.write(df)
.. output::
https://doc-columns2.streamlit.app/
height: 550px
**Example 3: Align widgets**
Use ``vertical_alignment="bottom"`` to align widgets.
>>> import streamlit as st
>>>
>>> left, middle, right = st.columns(3, vertical_alignment="bottom")
>>>
>>> left.text_input("Write something")
>>> middle.button("Click me", use_container_width=True)
>>> right.checkbox("Check me")
.. output::
https://doc-columns-bottom-widgets.streamlit.app/
height: 200px
**Example 4: Use vertical alignment to create grids**
Adjust vertical alignment to customize your grid layouts.
>>> import streamlit as st
>>>
>>> vertical_alignment = st.selectbox(
>>> "Vertical alignment", ["top", "center", "bottom"], index=2
>>> )
>>>
>>> left, middle, right = st.columns(3, vertical_alignment=vertical_alignment)
>>> left.image("https://static.streamlit.io/examples/cat.jpg")
>>> middle.image("https://static.streamlit.io/examples/dog.jpg")
>>> right.image("https://static.streamlit.io/examples/owl.jpg")
.. output::
https://doc-columns-vertical-alignment.streamlit.app/
height: 600px
**Example 5: Add borders**
Add borders to your columns instead of nested containers for consistent
heights.
>>> import streamlit as st
>>>
>>> left, middle, right = st.columns(3, border=True)
>>>
>>> left.markdown("Lorem ipsum " * 10)
>>> middle.markdown("Lorem ipsum " * 5)
>>> right.markdown("Lorem ipsum ")
.. output::
https://doc-columns-borders.streamlit.app/
height: 250px
streamlit.commands
Python Library Documentation: package streamlit.commands in streamlit
NAME
streamlit.commands
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PACKAGE CONTENTS
echo
execution_control
logo
navigation
page_config
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\commands\__init__.py
streamlit.components
Python Library Documentation: package streamlit.components in streamlit
NAME
streamlit.components
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PACKAGE CONTENTS
lib (package)
types (package)
v1 (package)
v2 (package)
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\components\__init__.py
streamlit.config
Python Library Documentation: module streamlit.config in streamlit
NAME
streamlit.config - Loads the configuration data.
CLASSES
builtins.str(builtins.object)
CustomThemeCategories(builtins.str, enum.Enum)
ShowErrorDetailsConfigOptions(builtins.str, enum.Enum)
enum.Enum(builtins.object)
CustomThemeCategories(builtins.str, enum.Enum)
ShowErrorDetailsConfigOptions(builtins.str, enum.Enum)
class CustomThemeCategories(builtins.str, enum.Enum)
| CustomThemeCategories(*values)
|
| Theme categories that can be set with custom theme config.
|
| Method resolution order:
| CustomThemeCategories
| builtins.str
| enum.Enum
| builtins.object
|
| Methods defined here:
|
| __format__(self, format_spec) from enum.Enum
| Default object formatter.
|
| Return str(self) if format_spec is empty. Raise TypeError otherwise.
|
| __new__(cls, value) from enum.Enum
| Create and return a new object. See help(type) for accurate signature.
|
| __repr__(self) from enum.Enum
| Return repr(self).
|
| __str__(self) from enum.Enum
| Return str(self).
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| DARK = <CustomThemeCategories.DARK: 'dark'>
|
| DARK_SIDEBAR = <CustomThemeCategories.DARK_SIDEBAR: 'dark.sidebar'>
|
| LIGHT = <CustomThemeCategories.LIGHT: 'light'>
|
| LIGHT_SIDEBAR = <CustomThemeCategories.LIGHT_SIDEBAR: 'light.sidebar'>
|
| SIDEBAR = <CustomThemeCategories.SIDEBAR: 'sidebar'>
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.str:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return bool(key in self).
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getitem__(self, key, /)
| Return self[key].
|
| __getnewargs__(...)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __sizeof__(self, /)
| Return the size of the string in memory, in bytes.
|
| capitalize(self, /)
| Return a capitalized version of the string.
|
| More specifically, make the first character have upper case and the rest lower
| case.
|
| casefold(self, /)
| Return a version of the string suitable for caseless comparisons.
|
| center(self, width, fillchar=' ', /)
| Return a centered string of length width.
|
| Padding is done using the specified fill character (default is a space).
|
| count(...)
| S.count(sub[, start[, end]]) -> int
|
| Return the number of non-overlapping occurrences of substring sub in
| string S[start:end]. Optional arguments start and end are
| interpreted as in slice notation.
|
| encode(self, /, encoding='utf-8', errors='strict')
| Encode the string using the codec registered for encoding.
|
| encoding
| The encoding in which to encode the string.
| errors
| The error handling scheme to use for encoding errors.
| The default is 'strict' meaning that encoding errors raise a
| UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
| 'xmlcharrefreplace' as well as any other name registered with
| codecs.register_error that can handle UnicodeEncodeErrors.
|
| endswith(...)
| S.endswith(suffix[, start[, end]]) -> bool
|
| Return True if S ends with the specified suffix, False otherwise.
| With optional start, test S beginning at that position.
| With optional end, stop comparing S at that position.
| suffix can also be a tuple of strings to try.
|
| expandtabs(self, /, tabsize=8)
| Return a copy where all tab characters are expanded using spaces.
|
| If tabsize is not given, a tab size of 8 characters is assumed.
|
| find(...)
| S.find(sub[, start[, end]]) -> int
|
| Return the lowest index in S where substring sub is found,
| such that sub is contained within S[start:end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Return -1 on failure.
|
| format(...)
| S.format(*args, **kwargs) -> str
|
| Return a formatted version of S, using substitutions from args and kwargs.
| The substitutions are identified by braces ('{' and '}').
|
| format_map(...)
| S.format_map(mapping) -> str
|
| Return a formatted version of S, using substitutions from mapping.
| The substitutions are identified by braces ('{' and '}').
|
| index(...)
| S.index(sub[, start[, end]]) -> int
|
| Return the lowest index in S where substring sub is found,
| such that sub is contained within S[start:end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Raises ValueError when the substring is not found.
|
| isalnum(self, /)
| Return True if the string is an alpha-numeric string, False otherwise.
|
| A string is alpha-numeric if all characters in the string are alpha-numeric and
| there is at least one character in the string.
|
| isalpha(self, /)
| Return True if the string is an alphabetic string, False otherwise.
|
| A string is alphabetic if all characters in the string are alphabetic and there
| is at least one character in the string.
|
| isascii(self, /)
| Return True if all characters in the string are ASCII, False otherwise.
|
| ASCII characters have code points in the range U+0000-U+007F.
| Empty string is ASCII too.
|
| isdecimal(self, /)
| Return True if the string is a decimal string, False otherwise.
|
| A string is a decimal string if all characters in the string are decimal and
| there is at least one character in the string.
|
| isdigit(self, /)
| Return True if the string is a digit string, False otherwise.
|
| A string is a digit string if all characters in the string are digits and there
| is at least one character in the string.
|
| isidentifier(self, /)
| Return True if the string is a valid Python identifier, False otherwise.
|
| Call keyword.iskeyword(s) to test whether string s is a reserved identifier,
| such as "def" or "class".
|
| islower(self, /)
| Return True if the string is a lowercase string, False otherwise.
|
| A string is lowercase if all cased characters in the string are lowercase and
| there is at least one cased character in the string.
|
| isnumeric(self, /)
| Return True if the string is a numeric string, False otherwise.
|
| A string is numeric if all characters in the string are numeric and there is at
| least one character in the string.
|
| isprintable(self, /)
| Return True if the string is printable, False otherwise.
|
| A string is printable if all of its characters are considered printable in
| repr() or if it is empty.
|
| isspace(self, /)
| Return True if the string is a whitespace string, False otherwise.
|
| A string is whitespace if all characters in the string are whitespace and there
| is at least one character in the string.
|
| istitle(self, /)
| Return True if the string is a title-cased string, False otherwise.
|
| In a title-cased string, upper- and title-case characters may only
| follow uncased characters and lowercase characters only cased ones.
|
| isupper(self, /)
| Return True if the string is an uppercase string, False otherwise.
|
| A string is uppercase if all cased characters in the string are uppercase and
| there is at least one cased character in the string.
|
| join(self, iterable, /)
| Concatenate any number of strings.
|
| The string whose method is called is inserted in between each given string.
| The result is returned as a new string.
|
| Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'
|
| ljust(self, width, fillchar=' ', /)
| Return a left-justified string of length width.
|
| Padding is done using the specified fill character (default is a space).
|
| lower(self, /)
| Return a copy of the string converted to lowercase.
|
| lstrip(self, chars=None, /)
| Return a copy of the string with leading whitespace removed.
|
| If chars is given and not None, remove characters in chars instead.
|
| partition(self, sep, /)
| Partition the string into three parts using the given separator.
|
| This will search for the separator in the string. If the separator is found,
| returns a 3-tuple containing the part before the separator, the separator
| itself, and the part after it.
|
| If the separator is not found, returns a 3-tuple containing the original string
| and two empty strings.
|
| removeprefix(self, prefix, /)
| Return a str with the given prefix string removed if present.
|
| If the string starts with the prefix string, return string[len(prefix):].
| Otherwise, return a copy of the original string.
|
| removesuffix(self, suffix, /)
| Return a str with the given suffix string removed if present.
|
| If the string ends with the suffix string and that suffix is not empty,
| return string[:-len(suffix)]. Otherwise, return a copy of the original
| string.
|
| replace(self, old, new, count=-1, /)
| Return a copy with all occurrences of substring old replaced by new.
|
| count
| Maximum number of occurrences to replace.
| -1 (the default value) means replace all occurrences.
|
| If the optional argument count is given, only the first count occurrences are
| replaced.
|
| rfind(...)
| S.rfind(sub[, start[, end]]) -> int
|
| Return the highest index in S where substring sub is found,
| such that sub is contained within S[start:end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Return -1 on failure.
|
| rindex(...)
| S.rindex(sub[, start[, end]]) -> int
|
| Return the highest index in S where substring sub is found,
| such that sub is contained within S[start:end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Raises ValueError when the substring is not found.
|
| rjust(self, width, fillchar=' ', /)
| Return a right-justified string of length width.
|
| Padding is done using the specified fill character (default is a space).
|
| rpartition(self, sep, /)
| Partition the string into three parts using the given separator.
|
| This will search for the separator in the string, starting at the end. If
| the separator is found, returns a 3-tuple containing the part before the
| separator, the separator itself, and the part after it.
|
| If the separator is not found, returns a 3-tuple containing two empty strings
| and the original string.
|
| rsplit(self, /, sep=None, maxsplit=-1)
| Return a list of the substrings in the string, using sep as the separator string.
|
| sep
| The separator used to split the string.
|
| When set to None (the default value), will split on any whitespace
| character (including \n \r \t \f and spaces) and will discard
| empty strings from the result.
| maxsplit
| Maximum number of splits.
| -1 (the default value) means no limit.
|
| Splitting starts at the end of the string and works to the front.
|
| rstrip(self, chars=None, /)
| Return a copy of the string with trailing whitespace removed.
|
| If chars is given and not None, remove characters in chars instead.
|
| split(self, /, sep=None, maxsplit=-1)
| Return a list of the substrings in the string, using sep as the separator string.
|
| sep
| The separator used to split the string.
|
| When set to None (the default value), will split on any whitespace
| character (including \n \r \t \f and spaces) and will discard
| empty strings from the result.
| maxsplit
| Maximum number of splits.
| -1 (the default value) means no limit.
|
| Splitting starts at the front of the string and works to the end.
|
| Note, str.split() is mainly useful for data that has been intentionally
| delimited. With natural text that includes punctuation, consider using
| the regular expression module.
|
| splitlines(self, /, keepends=False)
| Return a list of the lines in the string, breaking at line boundaries.
|
| Line breaks are not included in the resulting list unless keepends is given and
| true.
|
| startswith(...)
| S.startswith(prefix[, start[, end]]) -> bool
|
| Return True if S starts with the specified prefix, False otherwise.
| With optional start, test S beginning at that position.
| With optional end, stop comparing S at that position.
| prefix can also be a tuple of strings to try.
|
| strip(self, chars=None, /)
| Return a copy of the string with leading and trailing whitespace removed.
|
| If chars is given and not None, remove characters in chars instead.
|
| swapcase(self, /)
| Convert uppercase characters to lowercase and lowercase characters to uppercase.
|
| title(self, /)
| Return a version of the string where each word is titlecased.
|
| More specifically, words start with uppercased characters and all remaining
| cased characters have lower case.
|
| translate(self, table, /)
| Replace each character in the string using the given translation table.
|
| table
| Translation table, which must be a mapping of Unicode ordinals to
| Unicode ordinals, strings, or None.
|
| The table must implement lookup/indexing via __getitem__, for instance a
| dictionary or list. If this operation raises LookupError, the character is
| left untouched. Characters mapped to None are deleted.
|
| upper(self, /)
| Return a copy of the string converted to uppercase.
|
| zfill(self, width, /)
| Pad a numeric string with zeros on the left, to fill a field of the given width.
|
| The string is never truncated.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.str:
|
| maketrans(...)
| Return a translation table usable for str.translate().
|
| If there is only one argument, it must be a dictionary mapping Unicode
| ordinals (integers) or characters to Unicode ordinals, strings or None.
| Character keys will be then converted to ordinals.
| If there are two arguments, they must be strings of equal length, and
| in the resulting dictionary, each character in x will be mapped to the
| character at the same position in y. If there is a third argument, it
| must be a string, whose characters will be mapped to None in the result.
|
| ----------------------------------------------------------------------
| Methods inherited from enum.Enum:
|
| __dir__(self)
| Returns public methods and other interesting attributes.
|
| __init__(self, *args, **kwds)
| Initialize self. See help(type(self)) for accurate signature.
|
| __reduce_ex__(self, proto)
| Helper for pickle.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from enum.Enum:
|
| name
| The name of the Enum member.
|
| value
| The value of the Enum member.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from enum.EnumType:
|
| __members__
| Returns a mapping of member name->value.
|
| This mapping lists all enum members, including aliases. Note that this
| is a read-only view of the internal mapping.
class ShowErrorDetailsConfigOptions(builtins.str, enum.Enum)
| ShowErrorDetailsConfigOptions(*values)
|
| Valid options for the "client.showErrorDetails" config.
|
| Method resolution order:
| ShowErrorDetailsConfigOptions
| builtins.str
| enum.Enum
| builtins.object
|
| Methods defined here:
|
| __format__(self, format_spec) from enum.Enum
| Default object formatter.
|
| Return str(self) if format_spec is empty. Raise TypeError otherwise.
|
| __new__(cls, value) from enum.Enum
| Create and return a new object. See help(type) for accurate signature.
|
| __repr__(self) from enum.Enum
| Return repr(self).
|
| __str__(self) from enum.Enum
| Return str(self).
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| FULL = <ShowErrorDetailsConfigOptions.FULL: 'full'>
|
| NONE = <ShowErrorDetailsConfigOptions.NONE: 'none'>
|
| STACKTRACE = <ShowErrorDetailsConfigOptions.STACKTRACE: 'stacktrace'>
|
| TYPE = <ShowErrorDetailsConfigOptions.TYPE: 'type'>
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.str:
|
| __add__(self, value, /)
| Return self+value.
|
| __contains__(self, key, /)
| Return bool(key in self).
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getitem__(self, key, /)
| Return self[key].
|
| __getnewargs__(...)
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __mod__(self, value, /)
| Return self%value.
|
| __mul__(self, value, /)
| Return self*value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __rmod__(self, value, /)
| Return value%self.
|
| __rmul__(self, value, /)
| Return value*self.
|
| __sizeof__(self, /)
| Return the size of the string in memory, in bytes.
|
| capitalize(self, /)
| Return a capitalized version of the string.
|
| More specifically, make the first character have upper case and the rest lower
| case.
|
| casefold(self, /)
| Return a version of the string suitable for caseless comparisons.
|
| center(self, width, fillchar=' ', /)
| Return a centered string of length width.
|
| Padding is done using the specified fill character (default is a space).
|
| count(...)
| S.count(sub[, start[, end]]) -> int
|
| Return the number of non-overlapping occurrences of substring sub in
| string S[start:end]. Optional arguments start and end are
| interpreted as in slice notation.
|
| encode(self, /, encoding='utf-8', errors='strict')
| Encode the string using the codec registered for encoding.
|
| encoding
| The encoding in which to encode the string.
| errors
| The error handling scheme to use for encoding errors.
| The default is 'strict' meaning that encoding errors raise a
| UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
| 'xmlcharrefreplace' as well as any other name registered with
| codecs.register_error that can handle UnicodeEncodeErrors.
|
| endswith(...)
| S.endswith(suffix[, start[, end]]) -> bool
|
| Return True if S ends with the specified suffix, False otherwise.
| With optional start, test S beginning at that position.
| With optional end, stop comparing S at that position.
| suffix can also be a tuple of strings to try.
|
| expandtabs(self, /, tabsize=8)
| Return a copy where all tab characters are expanded using spaces.
|
| If tabsize is not given, a tab size of 8 characters is assumed.
|
| find(...)
| S.find(sub[, start[, end]]) -> int
|
| Return the lowest index in S where substring sub is found,
| such that sub is contained within S[start:end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Return -1 on failure.
|
| format(...)
| S.format(*args, **kwargs) -> str
|
| Return a formatted version of S, using substitutions from args and kwargs.
| The substitutions are identified by braces ('{' and '}').
|
| format_map(...)
| S.format_map(mapping) -> str
|
| Return a formatted version of S, using substitutions from mapping.
| The substitutions are identified by braces ('{' and '}').
|
| index(...)
| S.index(sub[, start[, end]]) -> int
|
| Return the lowest index in S where substring sub is found,
| such that sub is contained within S[start:end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Raises ValueError when the substring is not found.
|
| isalnum(self, /)
| Return True if the string is an alpha-numeric string, False otherwise.
|
| A string is alpha-numeric if all characters in the string are alpha-numeric and
| there is at least one character in the string.
|
| isalpha(self, /)
| Return True if the string is an alphabetic string, False otherwise.
|
| A string is alphabetic if all characters in the string are alphabetic and there
| is at least one character in the string.
|
| isascii(self, /)
| Return True if all characters in the string are ASCII, False otherwise.
|
| ASCII characters have code points in the range U+0000-U+007F.
| Empty string is ASCII too.
|
| isdecimal(self, /)
| Return True if the string is a decimal string, False otherwise.
|
| A string is a decimal string if all characters in the string are decimal and
| there is at least one character in the string.
|
| isdigit(self, /)
| Return True if the string is a digit string, False otherwise.
|
| A string is a digit string if all characters in the string are digits and there
| is at least one character in the string.
|
| isidentifier(self, /)
| Return True if the string is a valid Python identifier, False otherwise.
|
| Call keyword.iskeyword(s) to test whether string s is a reserved identifier,
| such as "def" or "class".
|
| islower(self, /)
| Return True if the string is a lowercase string, False otherwise.
|
| A string is lowercase if all cased characters in the string are lowercase and
| there is at least one cased character in the string.
|
| isnumeric(self, /)
| Return True if the string is a numeric string, False otherwise.
|
| A string is numeric if all characters in the string are numeric and there is at
| least one character in the string.
|
| isprintable(self, /)
| Return True if the string is printable, False otherwise.
|
| A string is printable if all of its characters are considered printable in
| repr() or if it is empty.
|
| isspace(self, /)
| Return True if the string is a whitespace string, False otherwise.
|
| A string is whitespace if all characters in the string are whitespace and there
| is at least one character in the string.
|
| istitle(self, /)
| Return True if the string is a title-cased string, False otherwise.
|
| In a title-cased string, upper- and title-case characters may only
| follow uncased characters and lowercase characters only cased ones.
|
| isupper(self, /)
| Return True if the string is an uppercase string, False otherwise.
|
| A string is uppercase if all cased characters in the string are uppercase and
| there is at least one cased character in the string.
|
| join(self, iterable, /)
| Concatenate any number of strings.
|
| The string whose method is called is inserted in between each given string.
| The result is returned as a new string.
|
| Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'
|
| ljust(self, width, fillchar=' ', /)
| Return a left-justified string of length width.
|
| Padding is done using the specified fill character (default is a space).
|
| lower(self, /)
| Return a copy of the string converted to lowercase.
|
| lstrip(self, chars=None, /)
| Return a copy of the string with leading whitespace removed.
|
| If chars is given and not None, remove characters in chars instead.
|
| partition(self, sep, /)
| Partition the string into three parts using the given separator.
|
| This will search for the separator in the string. If the separator is found,
| returns a 3-tuple containing the part before the separator, the separator
| itself, and the part after it.
|
| If the separator is not found, returns a 3-tuple containing the original string
| and two empty strings.
|
| removeprefix(self, prefix, /)
| Return a str with the given prefix string removed if present.
|
| If the string starts with the prefix string, return string[len(prefix):].
| Otherwise, return a copy of the original string.
|
| removesuffix(self, suffix, /)
| Return a str with the given suffix string removed if present.
|
| If the string ends with the suffix string and that suffix is not empty,
| return string[:-len(suffix)]. Otherwise, return a copy of the original
| string.
|
| replace(self, old, new, count=-1, /)
| Return a copy with all occurrences of substring old replaced by new.
|
| count
| Maximum number of occurrences to replace.
| -1 (the default value) means replace all occurrences.
|
| If the optional argument count is given, only the first count occurrences are
| replaced.
|
| rfind(...)
| S.rfind(sub[, start[, end]]) -> int
|
| Return the highest index in S where substring sub is found,
| such that sub is contained within S[start:end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Return -1 on failure.
|
| rindex(...)
| S.rindex(sub[, start[, end]]) -> int
|
| Return the highest index in S where substring sub is found,
| such that sub is contained within S[start:end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Raises ValueError when the substring is not found.
|
| rjust(self, width, fillchar=' ', /)
| Return a right-justified string of length width.
|
| Padding is done using the specified fill character (default is a space).
|
| rpartition(self, sep, /)
| Partition the string into three parts using the given separator.
|
| This will search for the separator in the string, starting at the end. If
| the separator is found, returns a 3-tuple containing the part before the
| separator, the separator itself, and the part after it.
|
| If the separator is not found, returns a 3-tuple containing two empty strings
| and the original string.
|
| rsplit(self, /, sep=None, maxsplit=-1)
| Return a list of the substrings in the string, using sep as the separator string.
|
| sep
| The separator used to split the string.
|
| When set to None (the default value), will split on any whitespace
| character (including \n \r \t \f and spaces) and will discard
| empty strings from the result.
| maxsplit
| Maximum number of splits.
| -1 (the default value) means no limit.
|
| Splitting starts at the end of the string and works to the front.
|
| rstrip(self, chars=None, /)
| Return a copy of the string with trailing whitespace removed.
|
| If chars is given and not None, remove characters in chars instead.
|
| split(self, /, sep=None, maxsplit=-1)
| Return a list of the substrings in the string, using sep as the separator string.
|
| sep
| The separator used to split the string.
|
| When set to None (the default value), will split on any whitespace
| character (including \n \r \t \f and spaces) and will discard
| empty strings from the result.
| maxsplit
| Maximum number of splits.
| -1 (the default value) means no limit.
|
| Splitting starts at the front of the string and works to the end.
|
| Note, str.split() is mainly useful for data that has been intentionally
| delimited. With natural text that includes punctuation, consider using
| the regular expression module.
|
| splitlines(self, /, keepends=False)
| Return a list of the lines in the string, breaking at line boundaries.
|
| Line breaks are not included in the resulting list unless keepends is given and
| true.
|
| startswith(...)
| S.startswith(prefix[, start[, end]]) -> bool
|
| Return True if S starts with the specified prefix, False otherwise.
| With optional start, test S beginning at that position.
| With optional end, stop comparing S at that position.
| prefix can also be a tuple of strings to try.
|
| strip(self, chars=None, /)
| Return a copy of the string with leading and trailing whitespace removed.
|
| If chars is given and not None, remove characters in chars instead.
|
| swapcase(self, /)
| Convert uppercase characters to lowercase and lowercase characters to uppercase.
|
| title(self, /)
| Return a version of the string where each word is titlecased.
|
| More specifically, words start with uppercased characters and all remaining
| cased characters have lower case.
|
| translate(self, table, /)
| Replace each character in the string using the given translation table.
|
| table
| Translation table, which must be a mapping of Unicode ordinals to
| Unicode ordinals, strings, or None.
|
| The table must implement lookup/indexing via __getitem__, for instance a
| dictionary or list. If this operation raises LookupError, the character is
| left untouched. Characters mapped to None are deleted.
|
| upper(self, /)
| Return a copy of the string converted to uppercase.
|
| zfill(self, width, /)
| Pad a numeric string with zeros on the left, to fill a field of the given width.
|
| The string is never truncated.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.str:
|
| maketrans(...)
| Return a translation table usable for str.translate().
|
| If there is only one argument, it must be a dictionary mapping Unicode
| ordinals (integers) or characters to Unicode ordinals, strings or None.
| Character keys will be then converted to ordinals.
| If there are two arguments, they must be strings of equal length, and
| in the resulting dictionary, each character in x will be mapped to the
| character at the same position in y. If there is a third argument, it
| must be a string, whose characters will be mapped to None in the result.
|
| ----------------------------------------------------------------------
| Methods inherited from enum.Enum:
|
| __dir__(self)
| Returns public methods and other interesting attributes.
|
| __init__(self, *args, **kwds)
| Initialize self. See help(type(self)) for accurate signature.
|
| __reduce_ex__(self, proto)
| Helper for pickle.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from enum.Enum:
|
| name
| The name of the Enum member.
|
| value
| The value of the Enum member.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from enum.EnumType:
|
| __members__
| Returns a mapping of member name->value.
|
| This mapping lists all enum members, including aliases. Note that this
| is a read-only view of the internal mapping.
FUNCTIONS
get_config_files(file_name: 'str') -> 'list[str]'
Return the list of config files (e.g. config.toml or secrets.toml) to be parsed.
Order is important, import is first to last, so options in later files
will take precedence over earlier ones.
get_config_options(force_reparse: 'bool' = False, options_from_flags: 'dict[str, Any] | None' = None) -> 'dict[str, ConfigOption]'
Create and return a dict mapping config option names to their values,
returning a cached dict if possible.
Config option values are sourced from the following locations. Values
set in locations further down the list overwrite those set earlier.
1. default values defined in this file
2. the global `~/.streamlit/config.toml` file
3. per-project `$CWD/.streamlit/config.toml` files
4. environment variables such as `STREAMLIT_SERVER_PORT`
5. command line flags passed to `streamlit run`
Parameters
----------
force_reparse : bool
Force config files to be parsed so that we pick up any changes to them.
options_from_flags : dict[str, any] or None
Config options that we received via CLI flag.
Returns
-------
dict[str, ConfigOption]
An ordered dict that maps config option names to their values.
get_option(key: 'str') -> 'Any'
Return the current value of a given Streamlit configuration option.
Run ``streamlit config show`` in a terminal to see all available options.
Parameters
----------
key : str
The config option key of the form "section.optionName". To see all
available options, run ``streamlit config show`` in a terminal.
Examples
--------
>>> import streamlit as st
>>>
>>> color = st.get_option("theme.primaryColor")
get_options_for_section(section: 'str') -> 'dict[str, Any]'
Get all of the config options for the given section.
Run `streamlit config show` in the terminal to see all available options.
Parameters
----------
section : str
The name of the config section to fetch options for.
Returns
-------
dict[str, Any]
A dict mapping the names of the options in the given section (without
the section name as a prefix) to their values.
get_where_defined(key: 'str') -> 'str'
Indicate where (e.g. in which file) this option was defined.
Parameters
----------
key : str
The config option key of the form "section.optionName"
is_manually_set(option_name: 'str') -> 'bool'
Check if a given option was actually defined by the user.
Parameters
----------
option_name : str
The option to check
Returns
-------
bool
True if the option has been set by the user.
on_config_parsed(func: 'Callable[[], None]', force_connect: 'bool' = False, lock: 'bool' = False) -> 'Callable[[], None]'
Wait for the config file to be parsed then call func.
If the config file has already been parsed, just calls func immediately
unless force_connect is set.
Parameters
----------
func : Callable[[], None]
A function to run on config parse.
force_connect : bool
Wait until the next config file parse to run func, even if config files
have already been parsed.
lock : bool
If set, grab _config_lock before running func.
Returns
-------
Callable[[], None]
A function that the caller can use to deregister func.
set_option(key: 'str', value: 'Any', where_defined: 'str' = '<user defined>') -> 'None'
Set config option.
Run `streamlit config show` in the terminal to see all available options.
This is an internal API. The public `st.set_option` API is implemented
in `set_user_option`.
Parameters
----------
key : str
The config option key of the form "section.optionName". To see all
available options, run `streamlit config show` on a terminal.
value
The new value to assign to this config option.
where_defined : str
Tells the config system where this was set.
set_user_option(key: 'str', value: 'Any') -> 'None'
Set a configuration option.
Currently, only ``client`` configuration options can be set within the
script itself:
- ``client.showErrorDetails``
- ``client.showSidebarNavigation``
- ``client.toolbarMode``
Calling ``st.set_option`` with any other option will raise a
``StreamlitAPIException``. When changing a configuration option in a
running app, you may need to trigger a rerun after changing the option to
see the effects.
Run ``streamlit config show`` in a terminal to see all available options.
Parameters
----------
key : str
The config option key of the form "section.optionName". To see all
available options, run ``streamlit config show`` in a terminal.
value
The new value to assign to this config option.
Examples
--------
>>> import streamlit as st
>>>
>>> st.set_option("client.showErrorDetails", True)
show_config() -> 'None'
Print all config options to the terminal.
DATA
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
Literal = typing.Literal
Special typing form to define literal types (a.k.a. value types).
This form can be used to indicate to type checkers that the corresponding
variable or function parameter has a value equivalent to the provided
literal (or one of several literals)::
def validate_simple(data: Any) -> Literal[True]: # always returns True
...
MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
...
open_helper('/some/path', 'r') # Passes type check
open_helper('/other/path', 'typo') # Error in type checker
Literal[...] cannot be subclassed. At runtime, an arbitrary value
is allowed as type argument to Literal[...], but type checkers may
impose restrictions.
TYPE_CHECKING = False
__annotations__ = {'_DEFINED_BY_ENV_VAR': 'Final', '_DEFINED_BY_FLAG':...
cat = <CustomThemeCategories.DARK_SIDEBAR: 'dark.sidebar'>
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\config.py
streamlit.config_option
Python Library Documentation: module streamlit.config_option in streamlit
NAME
streamlit.config_option - Class to store a key-value pair for the config system.
CLASSES
builtins.object
ConfigOption
class ConfigOption(builtins.object)
| ConfigOption(key: 'str', description: 'str | None' = None, default_val: 'Any | None' = None, visibility: 'str' = 'visible', scriptable: 'bool' = False, deprecated: 'bool' = False, deprecation_text: 'str | None' = None, expiration_date: 'str | None' = None, replaced_by: 'str | None' = None, type_: 'type' = <class 'str'>, sensitive: 'bool' = False, multiple: 'bool' = False) -> 'None'
|
| Stores a Streamlit configuration option.
|
| A configuration option, like 'browser.serverPort', which indicates which port
| to use when connecting to the proxy. There are two ways to create a
| ConfigOption:
|
| Simple ConfigOptions are created as follows:
|
| ConfigOption('browser.serverPort',
| description = 'Connect to the proxy at this port.',
| default_val = 8501)
|
| More complex config options resolve their values at runtime as follows:
|
| @ConfigOption('browser.serverPort')
| def _proxy_port():
| """Connect to the proxy at this port.
|
| Defaults to 8501.
| """
| return 8501
|
| NOTE: For complex config options, the function is called each time the
| option.value is evaluated!
|
| Attributes
| ----------
| key : str
| The fully qualified section.name
| value : any
| The value for this option. If this is a complex config option then
| the callback is called EACH TIME value is evaluated.
| section : str
| The section of this option. Example: 'global'.
| name : str
| See __init__.
| description : str
| See __init__.
| where_defined : str
| Indicates which file set this config option.
| ConfigOption.DEFAULT_DEFINITION means this file.
| is_default: bool
| True if the config value is equal to its default value.
| visibility : {"visible", "hidden"}
| See __init__.
| scriptable : bool
| See __init__.
| deprecated: bool
| See __init__.
| deprecation_text : str or None
| See __init__.
| expiration_date : str or None
| See __init__.
| replaced_by : str or None
| See __init__.
| sensitive : bool
| See __init__.
| env_var: str
| The name of the environment variable that can be used to set the option.
|
| Methods defined here:
|
| __call__(self, get_val_func: 'Callable[[], Any]') -> 'ConfigOption'
| Assign a function to compute the value for this option.
|
| This method is called when ConfigOption is used as a decorator.
|
| Parameters
| ----------
| get_val_func : function
| A function which will be called to get the value of this parameter.
| We will use its docString as the description.
|
| Returns
| -------
| ConfigOption
| Returns self, which makes testing easier. See config_test.py.
|
| __init__(self, key: 'str', description: 'str | None' = None, default_val: 'Any | None' = None, visibility: 'str' = 'visible', scriptable: 'bool' = False, deprecated: 'bool' = False, deprecation_text: 'str | None' = None, expiration_date: 'str | None' = None, replaced_by: 'str | None' = None, type_: 'type' = <class 'str'>, sensitive: 'bool' = False, multiple: 'bool' = False) -> 'None'
| Create a ConfigOption with the given name.
|
| Parameters
| ----------
| key : str
| Should be of the form "section.optionName"
| Examples: server.name, deprecation.v1_0_featureName
| description : str
| Like a comment for the config option.
| default_val : any
| The value for this config option.
| visibility : {"visible", "hidden"}
| Whether this option should be shown to users.
| scriptable : bool
| Whether this config option can be set within a user script.
| deprecated: bool
| Whether this config option is deprecated.
| deprecation_text : str or None
| Required if deprecated == True. Set this to a string explaining
| what to use instead.
| expiration_date : str or None
| Required if deprecated == True. set this to the date at which it
| will no longer be accepted. Format: 'YYYY-MM-DD'.
| replaced_by : str or None
| If this is option has been deprecated in favor or another option,
| set this to the path to the new option. Example:
| 'server.runOnSave'. If this is set, the 'deprecated' option
| will automatically be set to True, and deprecation_text will have a
| meaningful default (unless you override it).
| type_ : one of str, int, float or bool
| Useful to cast the config params sent by cmd option parameter.
| sensitive: bool
| Sensitive configuration options cannot be set by CLI parameter.
| multiple: bool
| Whether this config option can have multiple values.
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| is_expired(self) -> 'bool'
| Returns true if expiration_date is in the past.
|
| set_value(self, value: 'Any', where_defined: 'str | None' = None) -> 'None'
| Set the value of this option.
|
| Parameters
| ----------
| value
| The new value for this parameter.
| where_defined : str
| New value to remember where this parameter was set.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| env_var
| Get the name of the environment variable that can be used to set the option.
|
| value
| Get the value of this config option.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| DEFAULT_DEFINITION = '<default>'
|
| STREAMLIT_DEFINITION = '<streamlit>'
DATA
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\config_option.py
streamlit.config_util
Python Library Documentation: module streamlit.config_util in streamlit
NAME
streamlit.config_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUNCTIONS
process_theme_inheritance(config_options: 'dict[str, ConfigOption] | None', config_options_template: 'dict[str, ConfigOption]', set_option_func: 'Any', config_file_paths: 'Sequence[str] | None' = None) -> 'None'
Process theme inheritance if theme.base points to a theme file.
This function checks if theme.base is set to a file path or URL,
loads the theme file, and applies inheritance logic where the
current config.toml values override the theme.base file values.
Sets the merged theme options to the config.
Parameters
----------
config_options : dict[str, ConfigOption] | None
Current configuration options.
config_options_template : dict[str, ConfigOption]
Template of all valid config options.
set_option_func : Any
Function to set config option values.
config_file_paths : Sequence[str] | None, optional
Ordered list of config.toml file paths (global, project, script).
Used to label where_defined with scope for clearer provenance.
server_option_changed(old_options: 'dict[str, ConfigOption]', new_options: 'dict[str, ConfigOption]') -> 'bool'
Return True if and only if an option in the server section differs
between old_options and new_options.
show_config(section_descriptions: 'dict[str, str]', config_options: 'dict[str, ConfigOption]') -> 'None'
Print the given config sections/options to the terminal.
DATA
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\config_util.py
streamlit.connection
Python Library Documentation: function connection_factory in module streamlit.runtime.connection_factory
connection_factory(name, type=None, max_entries=None, ttl=None, **kwargs)
Create a new connection to a data store or API, or return an existing one.
Configuration options, credentials, and secrets for connections are
combined from the following sources:
- The keyword arguments passed to this command.
- The app's ``secrets.toml`` files.
- Any connection-specific configuration files.
The connection returned from ``st.connection`` is internally cached with
``st.cache_resource``. Connection types with a scope of ``"global"`` will be shared
between sessions.
Parameters
----------
name : str
The connection name used for secrets lookup in ``secrets.toml``.
Streamlit uses secrets under ``[connections.<name>]`` for the
connection. ``type`` will be inferred if ``name`` is one of the
following: ``"snowflake"``, ``"snowpark"``, or ``"sql"``.
type : str, connection class, or None
The type of connection to create. This can be one of the following:
- ``None`` (default): Streamlit will infer the connection type from
``name``. If the type is not inferable from ``name``, the type must
be specified in ``secrets.toml`` instead.
- ``"snowflake"``: Streamlit will initialize a connection with
|SnowflakeConnection|_.
- ``"snowflake-callers-rights"``: Streamlit will initialize a
``"snowflake"``-type connection, except the connection uses the
current viewer's identity tokens instead of the app's connection
configuration.
- ``"snowpark"``: Streamlit will initialize a connection with
|SnowparkConnection|_. This is deprecated.
- ``"sql"``: Streamlit will initialize a connection with
|SQLConnection|_.
- A string path to an importable class: This must be a dot-separated
module path ending in the importable class. Streamlit will import the
class and initialize a connection with it. The class must extend
``st.connections.BaseConnection``.
- An imported class reference: Streamlit will initialize a connection
with the referenced class, which must extend
``st.connections.BaseConnection``.
.. Important::
Connections of type ``"snowflake-callers-rights"`` only work when
they run in a Snowflake Snowpark Container Services environment. If
they are used in a local environment, they will raise exceptions.
For local development, use an environment variable or secret to
logically switch between a ``"snowflake"`` and
``"snowflake-callers-rights"`` connection depending on the runtime
environment.
.. |SnowflakeConnection| replace:: ``SnowflakeConnection``
.. _SnowflakeConnection: https://docs.streamlit.io/develop/api-reference/connections/st.connections.snowflakeconnection
.. |SnowparkConnection| replace:: ``SnowparkConnection``
.. _SnowparkConnection: https://docs.streamlit.io/develop/api-reference/connections/st.connections.snowparkconnection
.. |SQLConnection| replace:: ``SQLConnection``
.. _SQLConnection: https://docs.streamlit.io/develop/api-reference/connections/st.connections.sqlconnection
max_entries : int or None
The maximum number of connections to keep in the cache.
If this is ``None`` (default), the cache is unbounded. Otherwise, when
a new entry is added to a full cache, the oldest cached entry is
removed.
ttl : float, timedelta, or None
The maximum number of seconds to keep results in the cache.
If this is ``None`` (default), cached results do not expire with time.
**kwargs : any
Connection-specific keyword arguments that are passed to the
connection's ``._connect()`` method. ``**kwargs`` are typically
combined with (and take precedence over) key-value pairs in
``secrets.toml``. To learn more, see the specific connection's
documentation.
Returns
-------
Subclass of BaseConnection
An initialized connection object of the specified ``type``.
Examples
--------
**Example 1: Inferred connection type**
The easiest way to create a first-party (SQL, Snowflake, or Snowpark) connection is
to use their default names and define corresponding sections in your ``secrets.toml``
file. The following example creates a ``"sql"``-type connection.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[connections.sql]
dialect = "xxx"
host = "xxx"
username = "xxx"
password = "xxx"
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
conn = st.connection("sql")
**Example 2: Named connections**
Creating a connection with a custom name requires you to explicitly
specify the type. If ``type`` is not passed as a keyword argument, it must
be set in the appropriate section of ``secrets.toml``. The following
example creates two ``"sql"``-type connections, each with their own
custom name. The first defines ``type`` in the ``st.connection`` command;
the second defines ``type`` in ``secrets.toml``.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[connections.first_connection]
dialect = "xxx"
host = "xxx"
username = "xxx"
password = "xxx"
[connections.second_connection]
type = "sql"
dialect = "yyy"
host = "yyy"
username = "yyy"
password = "yyy"
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
conn1 = st.connection("first_connection", type="sql")
conn2 = st.connection("second_connection")
**Example 3: Using a path to the connection class**
Passing the full module path to the connection class can be useful,
especially when working with a custom connection. Although this is not the
typical way to create first party connections, the following example
creates the same type of connection as one with ``type="sql"``. Note that
``type`` is a string path.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[connections.my_sql_connection]
url = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
conn = st.connection(
"my_sql_connection", type="streamlit.connections.SQLConnection"
)
**Example 4: Importing the connection class**
You can pass the connection class directly to the ``st.connection``
command. Doing so allows static type checking tools such as ``mypy`` to
infer the exact return type of ``st.connection``. The following example
creates the same connection as in Example 3.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[connections.my_sql_connection]
url = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
from streamlit.connections import SQLConnection
conn = st.connection("my_sql_connection", type=SQLConnection)
streamlit.connections
Python Library Documentation: package streamlit.connections in streamlit
NAME
streamlit.connections
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PACKAGE CONTENTS
base_connection
snowflake_connection
snowpark_connection
sql_connection
util
CLASSES
abc.ABC(builtins.object)
streamlit.connections.base_connection.BaseConnection(abc.ABC, typing.Generic)
streamlit.connections.snowpark_connection.SnowparkConnection
streamlit.connections.sql_connection.SQLConnection
streamlit.connections.snowflake_connection.BaseSnowflakeConnection(streamlit.connections.base_connection.BaseConnection)
streamlit.connections.snowflake_connection.SnowflakeConnection
streamlit.connections.snowflake_connection.SnowflakeCallersRightsConnection
typing.Generic(builtins.object)
streamlit.connections.base_connection.BaseConnection(abc.ABC, typing.Generic)
streamlit.connections.snowpark_connection.SnowparkConnection
streamlit.connections.sql_connection.SQLConnection
class BaseConnection(abc.ABC, typing.Generic)
| BaseConnection(connection_name: 'str', **kwargs: 'Any') -> 'None'
|
| The abstract base class that all Streamlit Connections must inherit from.
|
| This base class provides connection authors with a standardized way to hook into the
| ``st.connection()`` factory function: connection authors are required to provide an
| implementation for the abstract method ``_connect`` in their subclasses.
|
| Additionally, it also provides a few methods/properties designed to make
| implementation of connections more convenient. See the docstrings for each of the
| methods of this class for more information
|
| By default, ``BaseConnection`` is a global-scoped connection. It has a class
| method |BaseConnection.scope()|_ that returns ``"global"``. To implement a session-scoped
| connection, override this method to return ``"session"`` in your subclass.
|
| .. |BaseConnection.scope()| replace:: ``BaseConnection.scope()``
| .. _BaseConnection.scope(): #baseconnectionscope
|
| .. note::
| While providing an implementation of ``_connect`` is technically all that's
| required to define a valid connection, connections should also provide the user
| with context-specific ways of interacting with the underlying connection object.
| For example, the first-party SQLConnection provides a ``query()`` method for
| reads and a ``session`` property for more complex operations.
|
| Method resolution order:
| BaseConnection
| abc.ABC
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __del__(self) -> 'None'
|
| __getattribute__(self, name: 'str') -> 'Any'
| Return getattr(self, name).
|
| __init__(self, connection_name: 'str', **kwargs: 'Any') -> 'None'
| Create a BaseConnection.
|
| This constructor is called by the connection factory machinery when a user
| script calls ``st.connection()``.
|
| Subclasses of BaseConnection that want to overwrite this method should take care
| to also call the base class' implementation.
|
| Parameters
| ----------
| connection_name : str
| The name of this connection. This corresponds to the
| ``[connections.<connection_name>]`` config section in ``st.secrets``.
| kwargs : dict
| Any other kwargs to pass to this connection class' ``_connect`` method.
|
| close(self) -> 'None'
| A function to invoke when this connection needs to be cleaned up.
|
| ``close`` is registered as an ``on_release`` hook in the resource cache when a
| connection is created with ``st.connection``.
|
| Returns
| -------
| None
|
| reset(self) -> 'None'
| Reset this connection so that it gets reinitialized the next time it's used.
|
| This method can be useful when a connection has become stale, an auth token has
| expired, or in similar scenarios where a broken connection might be fixed by
| reinitializing it. Note that some connection methods may already use ``reset()``
| in their error handling code.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("my_conn")
| >>>
| >>> # Reset the connection before using it if it isn't healthy
| >>> # Note: is_healthy() isn't a real method and is just shown for example here.
| >>> if not conn.is_healthy():
| ... conn.reset()
| >>>
| >>> # Do stuff with conn...
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| scope() -> "Literal['global', 'session']"
| Returns the scope of this connection type.
|
| This is a class method. ``"global"`` connection instances will be cached
| globally and are typically created once during the lifetime of an
| application. ``"session"`` connection instances will be cached per
| session and are typically created once per user session.
|
| A connection's scope can't be changed for different instances of the
| same connection type. If you want to switch between global and
| session-scoped connections, you should create two different connection
| types.
|
| Returns
| -------
| "global" or "session"
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset({'_connect'})
|
| __annotations__ = {}
|
| __orig_bases__ = (<class 'abc.ABC'>, typing.Generic[~RawConnectionT])
|
| __parameters__ = (~RawConnectionT,)
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.
ExperimentalBaseConnection = class BaseConnection(abc.ABC, typing.Generic)
| ExperimentalBaseConnection(connection_name: 'str', **kwargs: 'Any') -> 'None'
|
| The abstract base class that all Streamlit Connections must inherit from.
|
| This base class provides connection authors with a standardized way to hook into the
| ``st.connection()`` factory function: connection authors are required to provide an
| implementation for the abstract method ``_connect`` in their subclasses.
|
| Additionally, it also provides a few methods/properties designed to make
| implementation of connections more convenient. See the docstrings for each of the
| methods of this class for more information
|
| By default, ``BaseConnection`` is a global-scoped connection. It has a class
| method |BaseConnection.scope()|_ that returns ``"global"``. To implement a session-scoped
| connection, override this method to return ``"session"`` in your subclass.
|
| .. |BaseConnection.scope()| replace:: ``BaseConnection.scope()``
| .. _BaseConnection.scope(): #baseconnectionscope
|
| .. note::
| While providing an implementation of ``_connect`` is technically all that's
| required to define a valid connection, connections should also provide the user
| with context-specific ways of interacting with the underlying connection object.
| For example, the first-party SQLConnection provides a ``query()`` method for
| reads and a ``session`` property for more complex operations.
|
| Method resolution order:
| BaseConnection
| abc.ABC
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __del__(self) -> 'None'
|
| __getattribute__(self, name: 'str') -> 'Any'
| Return getattr(self, name).
|
| __init__(self, connection_name: 'str', **kwargs: 'Any') -> 'None'
| Create a BaseConnection.
|
| This constructor is called by the connection factory machinery when a user
| script calls ``st.connection()``.
|
| Subclasses of BaseConnection that want to overwrite this method should take care
| to also call the base class' implementation.
|
| Parameters
| ----------
| connection_name : str
| The name of this connection. This corresponds to the
| ``[connections.<connection_name>]`` config section in ``st.secrets``.
| kwargs : dict
| Any other kwargs to pass to this connection class' ``_connect`` method.
|
| close(self) -> 'None'
| A function to invoke when this connection needs to be cleaned up.
|
| ``close`` is registered as an ``on_release`` hook in the resource cache when a
| connection is created with ``st.connection``.
|
| Returns
| -------
| None
|
| reset(self) -> 'None'
| Reset this connection so that it gets reinitialized the next time it's used.
|
| This method can be useful when a connection has become stale, an auth token has
| expired, or in similar scenarios where a broken connection might be fixed by
| reinitializing it. Note that some connection methods may already use ``reset()``
| in their error handling code.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("my_conn")
| >>>
| >>> # Reset the connection before using it if it isn't healthy
| >>> # Note: is_healthy() isn't a real method and is just shown for example here.
| >>> if not conn.is_healthy():
| ... conn.reset()
| >>>
| >>> # Do stuff with conn...
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| scope() -> "Literal['global', 'session']"
| Returns the scope of this connection type.
|
| This is a class method. ``"global"`` connection instances will be cached
| globally and are typically created once during the lifetime of an
| application. ``"session"`` connection instances will be cached per
| session and are typically created once per user session.
|
| A connection's scope can't be changed for different instances of the
| same connection type. If you want to switch between global and
| session-scoped connections, you should create two different connection
| types.
|
| Returns
| -------
| "global" or "session"
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset({'_connect'})
|
| __annotations__ = {}
|
| __orig_bases__ = (<class 'abc.ABC'>, typing.Generic[~RawConnectionT])
|
| __parameters__ = (~RawConnectionT,)
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.
class SQLConnection(streamlit.connections.base_connection.BaseConnection)
| SQLConnection(connection_name: 'str', **kwargs: 'Any') -> 'None'
|
| A connection to a SQL database using a SQLAlchemy Engine.
|
| Initialize this connection object using ``st.connection("sql")`` or
| ``st.connection("<name>", type="sql")``. Connection parameters for a
| SQLConnection can be specified using ``secrets.toml`` and/or ``**kwargs``.
| Possible connection parameters include:
|
| - ``url`` or keyword arguments for |sqlalchemy.engine.URL.create()|_, except
| ``drivername``. Use ``dialect`` and ``driver`` instead of ``drivername``.
| - Keyword arguments for |sqlalchemy.create_engine()|_, including custom
| ``connect()`` arguments used by your specific ``dialect`` or ``driver``.
| - ``autocommit``. If this is ``False`` (default), the connection operates
| in manual commit (transactional) mode. If this is ``True``, the
| connection operates in autocommit (non-transactional) mode.
|
| If ``url`` exists as a connection parameter, Streamlit will pass it to
| ``sqlalchemy.engine.make_url()``. Otherwise, Streamlit requires (at a
| minimum) ``dialect``, ``username``, and ``host``. Streamlit will use
| ``dialect`` and ``driver`` (if defined) to derive ``drivername``, then pass
| the relevant connection parameters to ``sqlalchemy.engine.URL.create()``.
|
| In addition to the default keyword arguments for ``sqlalchemy.create_engine()``,
| your dialect may accept additional keyword arguments. For example, if you
| use ``dialect="snowflake"`` with `Snowflake SQLAlchemy
| <https://github.com/snowflakedb/snowflake-sqlalchemy#key-pair-authentication-support>`_,
| you can pass a value for ``private_key`` to use key-pair authentication. If
| you use ``dialect="bigquery"`` with `Google BigQuery
| <https://github.com/googleapis/python-bigquery-sqlalchemy#authentication>`_,
| you can pass a value for ``location``.
|
| SQLConnection provides the ``.query()`` convenience method, which can be
| used to run simple, read-only queries with both caching and simple error
| handling/retries. More complex database interactions can be performed by
| using the ``.session`` property to receive a regular SQLAlchemy Session.
|
| .. Important::
| `SQLAlchemy <https://pypi.org/project/SQLAlchemy/>`_ must be installed
| in your environment to use this connection. You must also install your
| driver, such as ``pyodbc`` or ``psycopg2``.
|
| .. |sqlalchemy.engine.URL.create()| replace:: ``sqlalchemy.engine.URL.create()``
| .. _sqlalchemy.engine.URL.create(): https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.engine.URL.create
| .. |sqlalchemy.engine.make_url()| replace:: ``sqlalchemy.engine.make_url()``
| .. _sqlalchemy.engine.make_url(): https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.engine.make_url
| .. |sqlalchemy.create_engine()| replace:: ``sqlalchemy.create_engine()``
| .. _sqlalchemy.create_engine(): https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine
|
| Examples
| --------
| **Example 1: Configuration with URL**
|
| You can configure your SQL connection using Streamlit's
| `Secrets management <https://docs.streamlit.io/develop/concepts/connections/secrets-management>`_.
| The following example specifies a SQL connection URL.
|
| ``.streamlit/secrets.toml``:
|
| >>> [connections.sql]
| >>> url = "xxx+xxx://xxx:xxx@xxx:xxx/xxx"
|
| Your app code:
|
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("sql")
| >>> df = conn.query("SELECT * FROM pet_owners")
| >>> st.dataframe(df)
|
| **Example 2: Configuration with dialect, host, and username**
|
| If you do not specify ``url``, you must at least specify ``dialect``,
| ``host``, and ``username`` instead. The following example also includes
| ``password``.
|
| ``.streamlit/secrets.toml``:
|
| >>> [connections.sql]
| >>> dialect = "xxx"
| >>> host = "xxx"
| >>> username = "xxx"
| >>> password = "xxx"
|
| Your app code:
|
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("sql")
| >>> df = conn.query("SELECT * FROM pet_owners")
| >>> st.dataframe(df)
|
| **Example 3: Configuration with keyword arguments**
|
| You can configure your SQL connection with keyword arguments (with or
| without ``secrets.toml``). For example, if you use Microsoft Entra ID with
| a Microsoft Azure SQL server, you can quickly set up a local connection for
| development using `interactive authentication
| <https://learn.microsoft.com/en-us/sql/connect/odbc/using-azure-active-directory?view=sql-server-ver16#new-andor-modified-dsn-and-connection-string-keywords>`_.
|
| This example requires the `Microsoft ODBC Driver for SQL Server
| <https://learn.microsoft.com/en-us/sql/connect/odbc/microsoft-odbc-driver-for-sql-server?view=sql-server-ver16>`_
| for *Windows* in addition to the ``sqlalchemy`` and ``pyodbc`` packages for
| Python.
|
| >>> import streamlit as st
| >>>
| >>> conn = st.connection(
| ... "sql",
| ... dialect="mssql",
| ... driver="pyodbc",
| ... host="xxx.database.windows.net",
| ... database="xxx",
| ... username="xxx",
| ... query={
| ... "driver": "ODBC Driver 18 for SQL Server",
| ... "authentication": "ActiveDirectoryInteractive",
| ... "encrypt": "yes",
| ... },
| ... )
| >>>
| >>> df = conn.query("SELECT * FROM pet_owners")
| >>> st.dataframe(df)
|
| Method resolution order:
| SQLConnection
| streamlit.connections.base_connection.BaseConnection
| abc.ABC
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| connect(self) -> 'SQLAlchemyConnection'
| Call ``.connect()`` on the underlying SQLAlchemy Engine, returning a new connection object.
|
| Calling this method is equivalent to calling ``self._instance.connect()``.
|
| NOTE: This method should not be confused with the internal ``_connect`` method used
| to implement a Streamlit Connection.
|
| Returns
| -------
| sqlalchemy.engine.Connection
| A new SQLAlchemy connection object.
|
| query(self, sql: 'str', *, show_spinner: 'bool | str' = 'Running `sql.query(...)`.', ttl: 'float | int | timedelta | None' = None, index_col: 'str | list[str] | None' = None, chunksize: 'int | None' = None, params: 'Any | None' = None, **kwargs: 'Any') -> 'DataFrame'
| Run a read-only query.
|
| This method implements query result caching and simple error
| handling/retries. The caching behavior is identical to that of using
| ``@st.cache_data``.
|
| .. note::
| Queries that are run without a specified ttl are cached indefinitely.
|
| All keyword arguments passed to this function are passed down to
| |pandas.read_sql|_, except ``ttl``.
|
| .. |pandas.read_sql| replace:: ``pandas.read_sql``
| .. _pandas.read_sql: https://pandas.pydata.org/docs/reference/api/pandas.read_sql.html
|
| Parameters
| ----------
| sql : str
| The read-only SQL query to execute.
| show_spinner : boolean or string
| Enable the spinner. The default is to show a spinner when there is a
| "cache miss" and the cached resource is being created. If a string, the value
| of the show_spinner param will be used for the spinner text.
| ttl : float, int, timedelta or None
| The maximum number of seconds to keep results in the cache, or
| None if cached results should not expire. The default is None.
| index_col : str, list of str, or None
| Column(s) to set as index(MultiIndex). Default is None.
| chunksize : int or None
| If specified, return an iterator where chunksize is the number of
| rows to include in each chunk. Default is None.
| params : list, tuple, dict or None
| List of parameters to pass to the execute method. The syntax used to pass
| parameters is database driver dependent. Check your database driver
| documentation for which of the five syntax styles, described in `PEP 249
| paramstyle <https://peps.python.org/pep-0249/#paramstyle>`_, is supported.
| Default is None.
| **kwargs: dict
| Additional keyword arguments are passed to |pandas.read_sql|_.
|
| .. |pandas.read_sql| replace:: ``pandas.read_sql``
| .. _pandas.read_sql: https://pandas.pydata.org/docs/reference/api/pandas.read_sql.html
|
| Returns
| -------
| pandas.DataFrame
| The result of running the query, formatted as a pandas DataFrame.
|
| Example
| -------
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("sql")
| >>> df = conn.query(
| ... "SELECT * FROM pet_owners WHERE owner = :owner",
| ... ttl=3600,
| ... params={"owner": "barbara"},
| ... )
| >>> st.dataframe(df)
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| driver
| The name of the driver used by the underlying SQLAlchemy Engine.
|
| This is equivalent to accessing ``self._instance.driver``.
|
| Returns
| -------
| str
| The name of the driver. For example, ``"pyodbc"`` or ``"psycopg2"``.
|
| engine
| The underlying SQLAlchemy Engine.
|
| This is equivalent to accessing ``self._instance``.
|
| Returns
| -------
| sqlalchemy.engine.base.Engine
| The underlying SQLAlchemy Engine.
|
| session
| Return a SQLAlchemy Session.
|
| Users of this connection should use the contextmanager pattern for writes,
| transactions, and anything more complex than simple read queries.
|
| See the usage example below, which assumes we have a table ``numbers`` with a
| single integer column ``val``. The `SQLAlchemy
| <https://docs.sqlalchemy.org/en/20/orm/session_basics.html>`_ docs also contain
| much more information on the usage of sessions.
|
| Returns
| -------
| sqlalchemy.orm.Session
| A SQLAlchemy Session.
|
| Example
| -------
| >>> import streamlit as st
| >>> conn = st.connection("sql")
| >>> n = st.slider("Pick a number")
| >>> if st.button("Add the number!"):
| ... with conn.session as session:
| ... session.execute("INSERT INTO numbers (val) VALUES (:n);", {"n": n})
| ... session.commit()
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __orig_bases__ = (streamlit.connections.base_connection.BaseConnection...
|
| __parameters__ = ()
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.connections.base_connection.BaseConnection:
|
| __del__(self) -> 'None'
|
| __getattribute__(self, name: 'str') -> 'Any'
| Return getattr(self, name).
|
| __init__(self, connection_name: 'str', **kwargs: 'Any') -> 'None'
| Create a BaseConnection.
|
| This constructor is called by the connection factory machinery when a user
| script calls ``st.connection()``.
|
| Subclasses of BaseConnection that want to overwrite this method should take care
| to also call the base class' implementation.
|
| Parameters
| ----------
| connection_name : str
| The name of this connection. This corresponds to the
| ``[connections.<connection_name>]`` config section in ``st.secrets``.
| kwargs : dict
| Any other kwargs to pass to this connection class' ``_connect`` method.
|
| close(self) -> 'None'
| A function to invoke when this connection needs to be cleaned up.
|
| ``close`` is registered as an ``on_release`` hook in the resource cache when a
| connection is created with ``st.connection``.
|
| Returns
| -------
| None
|
| reset(self) -> 'None'
| Reset this connection so that it gets reinitialized the next time it's used.
|
| This method can be useful when a connection has become stale, an auth token has
| expired, or in similar scenarios where a broken connection might be fixed by
| reinitializing it. Note that some connection methods may already use ``reset()``
| in their error handling code.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("my_conn")
| >>>
| >>> # Reset the connection before using it if it isn't healthy
| >>> # Note: is_healthy() isn't a real method and is just shown for example here.
| >>> if not conn.is_healthy():
| ... conn.reset()
| >>>
| >>> # Do stuff with conn...
|
| ----------------------------------------------------------------------
| Class methods inherited from streamlit.connections.base_connection.BaseConnection:
|
| scope() -> "Literal['global', 'session']"
| Returns the scope of this connection type.
|
| This is a class method. ``"global"`` connection instances will be cached
| globally and are typically created once during the lifetime of an
| application. ``"session"`` connection instances will be cached per
| session and are typically created once per user session.
|
| A connection's scope can't be changed for different instances of the
| same connection type. If you want to switch between global and
| session-scoped connections, you should create two different connection
| types.
|
| Returns
| -------
| "global" or "session"
|
| ----------------------------------------------------------------------
| Data descriptors inherited from streamlit.connections.base_connection.BaseConnection:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.
class SnowflakeCallersRightsConnection(SnowflakeConnection)
| SnowflakeCallersRightsConnection(connection_name: 'str', **kwargs: 'Any') -> 'None'
|
| A caller's rights connection to Snowflake using the Snowflake Connector for Python.
|
| This will only work when running on Snowpark Container Services or another
| compatible platform.
|
| See ``BaseSnowflakeConnection`` for complete docs.
|
| Method resolution order:
| SnowflakeCallersRightsConnection
| SnowflakeConnection
| BaseSnowflakeConnection
| streamlit.connections.base_connection.BaseConnection
| abc.ABC
| typing.Generic
| builtins.object
|
| Class methods defined here:
|
| scope() -> "Literal['session']"
| Returns ``"session"``.
|
| Caller's rights Snowflake connections rely on per-session connection tokens and
| therefore must be session-scoped.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __parameters__ = ()
|
| ----------------------------------------------------------------------
| Methods inherited from BaseSnowflakeConnection:
|
| close(self) -> 'None'
| Closes the underlying Snowflake connection.
|
| cursor(self) -> 'SnowflakeCursor'
| Create a new cursor object from this connection.
|
| Snowflake Connector cursors implement the Python Database API v2.0
| specification (PEP-249). For more information, see the
| `Snowflake Connector for Python documentation
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#object-cursor>`_.
|
| Returns
| -------
| snowflake.connector.cursor.SnowflakeCursor
| A cursor object for the connection.
|
| Example
| -------
| The following example uses a cursor to insert multiple rows into a
| table. The ``qmark`` parameter style is specified as an optional
| keyword argument. Alternatively, the parameter style can be declared in
| your connection configuration file. For more information, see the
| `Snowflake Connector for Python documentation
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-example#using-qmark-or-numeric-binding>`_.
|
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("snowflake", "paramstyle"="qmark")
| >>> rows_to_insert = [("Mary", "dog"), ("John", "cat"), ("Robert", "bird")]
| >>> conn.cursor().executemany(
| ... "INSERT INTO mytable (name, pet) VALUES (?, ?)", rows_to_insert
| ... )
|
| query(self, sql: 'str', *, ttl: 'float | int | timedelta | None' = None, show_spinner: 'bool | str' = 'Running `snowflake.query(...)`.', params: 'Any' = None, **kwargs: 'Any') -> 'DataFrame'
| Run a read-only SQL query.
|
| This method implements query result caching and simple error
| handling/retries. The caching behavior is identical to that of using
| ``@st.cache_data``.
|
| .. note::
| Queries that are run without a specified ``ttl`` are cached
| indefinitely.
|
| Parameters
| ----------
| sql : str
| The read-only SQL query to execute.
| ttl : float, int, timedelta or None
| The maximum number of seconds to keep results in the cache. If this
| is ``None`` (default), cached results do not expire with time.
| show_spinner : boolean or string
| Whether to enable the spinner. When a cached query is executed, no
| spinner is displayed because the result is immediately available.
| When a new query is executed, the default is to show a spinner with
| the message "Running ``snowflake.query(...)``."
|
| If this is ``False``, no spinner displays while executing the
| query. If this is a string, the string will be used as the message
| for the spinner.
| params : list, tuple, dict or None
| List of parameters to pass to the Snowflake Connector for Python
| ``Cursor.execute()`` method. This connector supports binding data
| to a SQL statement using qmark bindings. For more information and
| examples, see the `Snowflake Connector for Python documentation
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-example#using-qmark-or-numeric-binding>`_.
| This defaults to ``None``.
|
| Returns
| -------
| pandas.DataFrame
| The result of running the query, formatted as a pandas DataFrame.
|
| Example
| -------
|
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("snowflake")
| >>> df = conn.query("SELECT * FROM my_table")
| >>> st.dataframe(df)
|
| session(self) -> 'Session'
| Create a new Snowpark session from this connection.
|
| For information on how to use Snowpark sessions, see the
| `Snowpark developer guide
| <https://docs.snowflake.com/en/developer-guide/snowpark/python/working-with-dataframes>`_
| and `Snowpark API Reference
| <https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/latest/snowpark/session>`_.
|
| Returns
| -------
| snowflake.snowpark.Session
| A new Snowpark session for this connection.
|
| Example
| -------
| The following example creates a new Snowpark session and uses it to run
| a query.
|
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("snowflake")
| >>> session = conn.session()
| >>> df = session.sql("SELECT * FROM my_table").collect()
|
| write_pandas(self, df: 'DataFrame', table_name: 'str', database: 'str | None' = None, schema: 'str | None' = None, chunk_size: 'int | None' = None, **kwargs: 'Any') -> 'tuple[bool, int, int]'
| Write a ``pandas.DataFrame`` to a table in a Snowflake database.
|
| This convenience method is a thin wrapper around
| ``snowflake.connector.pandas_tools.write_pandas()`` using the
| underlying connection. The ``conn`` parameter is passed automatically.
| For more information and additional keyword arguments, see the
| `Snowflake Connector for Python documentation
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#write_pandas>`_.
|
| Parameters
| ----------
| df: pandas.DataFrame
| The ``pandas.DataFrame`` object containing the data to be copied
| into the table.
| table_name: str
| Name of the table where the data should be copied to.
| database: str
| Name of the database containing the table. By default, the function
| writes to the database that is currently in use in the session.
|
| .. Note::
| If you specify this parameter, you must also specify the schema
| parameter.
|
| schema: str
| Name of the schema containing the table. By default, the function
| writes to the table in the schema that is currently in use in the
| session.
| chunk_size: int
| Number of elements to insert at a time. By default, the function
| inserts all elements in one chunk.
| **kwargs: Any
| Additional keyword arguments for
| ``snowflake.connector.pandas_tools.write_pandas()``.
|
| Returns
| -------
| tuple[bool, int, int]
| A tuple containing three values:
|
| 1. A boolean value that is ``True`` if the write was successful.
| 2. An integer giving the number of chunks of data that were copied.
| 3. An integer giving the number of rows that were inserted.
|
| Example
| -------
| The following example uses the database and schema currently in use in
| the session and copies the data into a table named "my_table."
|
| >>> import streamlit as st
| >>> import pandas as pd
| >>>
| >>> df = pd.DataFrame(
| ... {"Name": ["Mary", "John", "Robert"], "Pet": ["dog", "cat", "bird"]}
| ... )
| >>> conn = st.connection("snowflake")
| >>> conn.write_pandas(df, "my_table")
|
| ----------------------------------------------------------------------
| Readonly properties inherited from BaseSnowflakeConnection:
|
| raw_connection
| Access the underlying connection object from the Snowflake Connector for Python.
|
| For information on how to use the Snowflake Connector for Python, see
| the `Snowflake Connector for Python documentation
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-example>`_.
|
| Returns
| -------
| snowflake.connector.connection.SnowflakeConnection
| The connection object.
|
| Example
| -------
| The following example uses a cursor to submit an asynchronous query,
| saves the query ID, then periodically checks the query status through
| the connection before retrieving the results.
|
| >>> import streamlit as st
| >>> import time
| >>>
| >>> conn = st.connection("snowflake")
| >>> cur = conn.cursor()
| >>> cur.execute_async("SELECT * FROM my_table")
| >>> query_id = cur.sfqid
| >>> while True:
| ... status = conn.raw_connection.get_query_status(query_id)
| ... if conn.raw_connection.is_still_running(status):
| ... time.sleep(1)
| ... else:
| ... break
| >>> cur.get_results_from_sfqid(query_id)
| >>> df = cur.fetchall()
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from BaseSnowflakeConnection:
|
| __orig_bases__ = (streamlit.connections.base_connection.BaseConnection...
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.connections.base_connection.BaseConnection:
|
| __del__(self) -> 'None'
|
| __getattribute__(self, name: 'str') -> 'Any'
| Return getattr(self, name).
|
| __init__(self, connection_name: 'str', **kwargs: 'Any') -> 'None'
| Create a BaseConnection.
|
| This constructor is called by the connection factory machinery when a user
| script calls ``st.connection()``.
|
| Subclasses of BaseConnection that want to overwrite this method should take care
| to also call the base class' implementation.
|
| Parameters
| ----------
| connection_name : str
| The name of this connection. This corresponds to the
| ``[connections.<connection_name>]`` config section in ``st.secrets``.
| kwargs : dict
| Any other kwargs to pass to this connection class' ``_connect`` method.
|
| reset(self) -> 'None'
| Reset this connection so that it gets reinitialized the next time it's used.
|
| This method can be useful when a connection has become stale, an auth token has
| expired, or in similar scenarios where a broken connection might be fixed by
| reinitializing it. Note that some connection methods may already use ``reset()``
| in their error handling code.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("my_conn")
| >>>
| >>> # Reset the connection before using it if it isn't healthy
| >>> # Note: is_healthy() isn't a real method and is just shown for example here.
| >>> if not conn.is_healthy():
| ... conn.reset()
| >>>
| >>> # Do stuff with conn...
|
| ----------------------------------------------------------------------
| Data descriptors inherited from streamlit.connections.base_connection.BaseConnection:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.
class SnowflakeConnection(BaseSnowflakeConnection)
| SnowflakeConnection(connection_name: 'str', **kwargs: 'Any') -> 'None'
|
| A connection to Snowflake using the Snowflake Connector for Python.
|
| For standard connections, create an instance of this using
| ``st.connection("snowflake")`` or
| ``st.connection("<name>", type="snowflake")``. Connection parameters for a
| SnowflakeConnection can be specified using ``secrets.toml`` and/or
| ``**kwargs``. Connection parameters are passed to
| |snowflake.connector.connect()|_.
|
| When an app is running in Streamlit in Snowflake,
| ``st.connection("snowflake")`` connects automatically using the app owner's
| role without further configuration. ``**kwargs`` are ignored in this
| case. Use ``secrets.toml`` and ``**kwargs`` to configure your connection
| for local development.
|
| When an app is running in Snowpark Container Services and has caller's rights
| enabled, ``st.connection("snowflake-callers-rights")`` connects automatically
| using the current user's identity tokens. This is a session-scoped connection
| to ensure that the identity stays tied to the active user. Unlike with
| ``"snowflake"`` connections, it will use the Snowpark Container Services
| connection settings even when other ``**kwargs`` are provided.
|
| The Snowflake connection includes several convenience methods. For example, you
| can directly execute a SQL query with ``.query()`` or access the underlying
| Snowflake Connector object with ``.raw_connection``.
|
| .. |snowflake.connector.connect()| replace:: ``snowflake.connector.connect()``
| .. _snowflake.connector.connect(): https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#label-snowflake-connector-methods-connect
|
| .. Important::
| - `snowflake-snowpark-python <https://pypi.org/project/snowflake-snowpark-python/>`_
| must be installed in your environment to use this connection. You can
| install it as an extra with Streamlit:
|
| .. code-block:: shell
|
| pip install streamlit[snowflake]
|
| - Account identifiers must be of the form ``<orgname>-<account_name>``
| where ``<orgname>`` is the name of your Snowflake organization and
| ``<account_name>`` is the unique name of your account within your
| organization. This is dash-separated, not dot-separated like when used
| in SQL queries. For more information, see `Account identifiers
| <https://docs.snowflake.com/en/user-guide/admin-account-identifier>`_.
|
| - Caller's rights connections rely on credentials provided when a user first
| connects to a Streamlit app. These credentials are only valid for about
| two minutes. Therefore, caller's rights connections must be created at
| the top of an app or else the connection may fail.
|
| - To develop locally with a caller's rights connection, use an
| environment variable to logically switch between a ``"snowflake"``
| connection locally and a ``"snowflake-callers-rights"`` connection in
| Snowpark Container Services.
|
| Examples
| --------
| **Example 1: Configuration with Streamlit secrets**
|
| You can configure your Snowflake connection using Streamlit's
| `Secrets management <https://docs.streamlit.io/develop/concepts/connections/secrets-management>`_.
| For example, if you have MFA enabled on your account, you can connect using
| `key-pair authentication <https://docs.snowflake.com/en/user-guide/key-pair-auth>`_.
|
| .. code-block:: toml
| :filename: ~/.snowflake/connections.toml
|
| [connections.snowflake]
| account = "xxx-xxx"
| user = "xxx"
| private_key_file = "/xxx/xxx/xxx.p8"
| role = "xxx"
| warehouse = "xxx"
| database = "xxx"
| schema = "xxx"
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| conn = st.connection("snowflake")
| df = conn.query("SELECT * FROM my_table")
|
| **Example 2: Configuration with keyword arguments and external authentication**
|
| You can configure your Snowflake connection with keyword arguments. The
| keyword arguments are merged with (and take precedence over) the values in
| ``secrets.toml``. However, if you name your connection ``"snowflake"`` and
| don't have a ``[connections.snowflake]`` dictionary in your
| ``secrets.toml`` file, Streamlit will ignore any keyword arguments and use
| the default Snowflake connection as described in Example 5 and Example 6.
| To configure your connection using only keyword arguments, declare a name
| for the connection other than ``"snowflake"``.
|
| For example, if your Snowflake account supports SSO, you can set up a quick
| local connection for development using `browser-based SSO
| <https://docs.snowflake.com/en/user-guide/admin-security-fed-auth-use#how-browser-based-sso-works>`_.
| Because there is nothing configured in ``secrets.toml``, the name is an
| empty string and the type is set to ``"snowflake"``. This prevents
| Streamlit from ignoring the keyword arguments and using a default
| Snowflake connection.
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| conn = st.connection(
| "",
| type="snowflake",
| account="xxx-xxx",
| user="xxx",
| authenticator="externalbrowser",
| )
| df = conn.query("SELECT * FROM my_table")
|
| **Example 3: Named connection with Snowflake's connection configuration file**
|
| Snowflake's Python Connector supports a `connection configuration file
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-connect#connecting-using-the-connections-toml-file>`_,
| which is well integrated with Streamlit's ``SnowflakeConnection``. If you
| already have one or more connections configured, all you need to do is pass
| the name of the connection to use.
|
| .. code-block:: toml
| :filename: ~/.snowflake/connections.toml
|
| [my_connection]
| account = "xxx-xxx"
| user = "xxx"
| password = "xxx"
| warehouse = "xxx"
| database = "xxx"
| schema = "xxx"
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| conn = st.connection("my_connection", type="snowflake")
| df = conn.query("SELECT * FROM my_table")
|
| **Example 4: Named connection with Streamlit secrets and Snowflake's connection configuration file**
|
| If you have a Snowflake configuration file with a connection named
| ``my_connection`` as in Example 3, you can pass the connection name through
| ``secrets.toml``.
|
| .. code-block:: toml
| :filename: .streamlit/secrets.toml
|
| [connections.snowflake]
| connection_name = "my_connection"
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| conn = st.connection("snowflake")
| df = conn.query("SELECT * FROM my_table")
|
| **Example 5: Default connection with an environment variable**
|
| If you don't have a ``[connections.snowflake]`` dictionary in your
| ``secrets.toml`` file and use ``st.connection("snowflake")``, Streamlit
| will use the default connection for the `Snowflake Python Connector
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-connect#setting-a-default-connection>`_.
|
| If you have a Snowflake configuration file with a connection named
| ``my_connection`` as in Example 3, you can set an environment variable to
| declare it as the default Snowflake connection.
|
| .. code-block:: toml
| :filename: .streamlit/secrets.toml
|
| SNOWFLAKE_DEFAULT_CONNECTION_NAME = "my_connection"
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| conn = st.connection("snowflake")
| df = conn.query("SELECT * FROM my_table")
|
| **Example 6: Default connection in Snowflake's connection configuration file**
|
| If you have a Snowflake configuration file that defines your ``default``
| connection, Streamlit will automatically use it if no other connection is
| declared.
|
| .. code-block:: toml
| :filename: ~/.snowflake/connections.toml
|
| [default]
| account = "xxx-xxx"
| user = "xxx"
| password = "xxx"
| warehouse = "xxx"
| database = "xxx"
| schema = "xxx"
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| conn = st.connection("snowflake")
| df = conn.query("SELECT * FROM my_table")
|
| **Example 7: Caller's rights connection when running in Snowpark Container Services**
|
| You can use ``"snowflake-callers-rights"`` type connections in any
| environment running on Snowpark Container Services, including Streamlit in
| Snowflake on containers and any self-managed caller's rights Service.
|
| This will use the Snowpark-provided account, host, database, and schema to connect.
| Additionally, it will set ``client_session_keep_alive`` to ``True``. These values
| may be overridden with ``**kwargs`` in ``st.connection``. For a complete list
| of keyword arguments, see the documentation for |snowflake.connector.connect()|_.
|
| .. |snowflake.connector.connect()| replace:: ``snowflake.connector.connect()``
| .. _snowflake.connector.connect(): https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#label-snowflake-connector-methods-connect
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| conn = st.connection("snowflake-callers-rights")
| df = conn.query("SELECT * FROM my_table")
|
| If you want to develop locally with a caller's rights connection, use an
| environment variable to logically switch between a ``"snowflake"``
| connection locally and a ``"snowflake-callers-rights"`` connection in
| Snowpark Container Services.
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| conn = (
| st.connection("snowflake")
| if "LOCAL_DEVELOPMENT" in st.secrets and st.secrets["LOCAL_DEVELOPMENT"]
| else st.connection("snowflake-callers-rights")
| )
| df = conn.query("SELECT * FROM my_table")
|
| Method resolution order:
| SnowflakeConnection
| BaseSnowflakeConnection
| streamlit.connections.base_connection.BaseConnection
| abc.ABC
| typing.Generic
| builtins.object
|
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __parameters__ = ()
|
| ----------------------------------------------------------------------
| Methods inherited from BaseSnowflakeConnection:
|
| close(self) -> 'None'
| Closes the underlying Snowflake connection.
|
| cursor(self) -> 'SnowflakeCursor'
| Create a new cursor object from this connection.
|
| Snowflake Connector cursors implement the Python Database API v2.0
| specification (PEP-249). For more information, see the
| `Snowflake Connector for Python documentation
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#object-cursor>`_.
|
| Returns
| -------
| snowflake.connector.cursor.SnowflakeCursor
| A cursor object for the connection.
|
| Example
| -------
| The following example uses a cursor to insert multiple rows into a
| table. The ``qmark`` parameter style is specified as an optional
| keyword argument. Alternatively, the parameter style can be declared in
| your connection configuration file. For more information, see the
| `Snowflake Connector for Python documentation
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-example#using-qmark-or-numeric-binding>`_.
|
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("snowflake", "paramstyle"="qmark")
| >>> rows_to_insert = [("Mary", "dog"), ("John", "cat"), ("Robert", "bird")]
| >>> conn.cursor().executemany(
| ... "INSERT INTO mytable (name, pet) VALUES (?, ?)", rows_to_insert
| ... )
|
| query(self, sql: 'str', *, ttl: 'float | int | timedelta | None' = None, show_spinner: 'bool | str' = 'Running `snowflake.query(...)`.', params: 'Any' = None, **kwargs: 'Any') -> 'DataFrame'
| Run a read-only SQL query.
|
| This method implements query result caching and simple error
| handling/retries. The caching behavior is identical to that of using
| ``@st.cache_data``.
|
| .. note::
| Queries that are run without a specified ``ttl`` are cached
| indefinitely.
|
| Parameters
| ----------
| sql : str
| The read-only SQL query to execute.
| ttl : float, int, timedelta or None
| The maximum number of seconds to keep results in the cache. If this
| is ``None`` (default), cached results do not expire with time.
| show_spinner : boolean or string
| Whether to enable the spinner. When a cached query is executed, no
| spinner is displayed because the result is immediately available.
| When a new query is executed, the default is to show a spinner with
| the message "Running ``snowflake.query(...)``."
|
| If this is ``False``, no spinner displays while executing the
| query. If this is a string, the string will be used as the message
| for the spinner.
| params : list, tuple, dict or None
| List of parameters to pass to the Snowflake Connector for Python
| ``Cursor.execute()`` method. This connector supports binding data
| to a SQL statement using qmark bindings. For more information and
| examples, see the `Snowflake Connector for Python documentation
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-example#using-qmark-or-numeric-binding>`_.
| This defaults to ``None``.
|
| Returns
| -------
| pandas.DataFrame
| The result of running the query, formatted as a pandas DataFrame.
|
| Example
| -------
|
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("snowflake")
| >>> df = conn.query("SELECT * FROM my_table")
| >>> st.dataframe(df)
|
| session(self) -> 'Session'
| Create a new Snowpark session from this connection.
|
| For information on how to use Snowpark sessions, see the
| `Snowpark developer guide
| <https://docs.snowflake.com/en/developer-guide/snowpark/python/working-with-dataframes>`_
| and `Snowpark API Reference
| <https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/latest/snowpark/session>`_.
|
| Returns
| -------
| snowflake.snowpark.Session
| A new Snowpark session for this connection.
|
| Example
| -------
| The following example creates a new Snowpark session and uses it to run
| a query.
|
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("snowflake")
| >>> session = conn.session()
| >>> df = session.sql("SELECT * FROM my_table").collect()
|
| write_pandas(self, df: 'DataFrame', table_name: 'str', database: 'str | None' = None, schema: 'str | None' = None, chunk_size: 'int | None' = None, **kwargs: 'Any') -> 'tuple[bool, int, int]'
| Write a ``pandas.DataFrame`` to a table in a Snowflake database.
|
| This convenience method is a thin wrapper around
| ``snowflake.connector.pandas_tools.write_pandas()`` using the
| underlying connection. The ``conn`` parameter is passed automatically.
| For more information and additional keyword arguments, see the
| `Snowflake Connector for Python documentation
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-api#write_pandas>`_.
|
| Parameters
| ----------
| df: pandas.DataFrame
| The ``pandas.DataFrame`` object containing the data to be copied
| into the table.
| table_name: str
| Name of the table where the data should be copied to.
| database: str
| Name of the database containing the table. By default, the function
| writes to the database that is currently in use in the session.
|
| .. Note::
| If you specify this parameter, you must also specify the schema
| parameter.
|
| schema: str
| Name of the schema containing the table. By default, the function
| writes to the table in the schema that is currently in use in the
| session.
| chunk_size: int
| Number of elements to insert at a time. By default, the function
| inserts all elements in one chunk.
| **kwargs: Any
| Additional keyword arguments for
| ``snowflake.connector.pandas_tools.write_pandas()``.
|
| Returns
| -------
| tuple[bool, int, int]
| A tuple containing three values:
|
| 1. A boolean value that is ``True`` if the write was successful.
| 2. An integer giving the number of chunks of data that were copied.
| 3. An integer giving the number of rows that were inserted.
|
| Example
| -------
| The following example uses the database and schema currently in use in
| the session and copies the data into a table named "my_table."
|
| >>> import streamlit as st
| >>> import pandas as pd
| >>>
| >>> df = pd.DataFrame(
| ... {"Name": ["Mary", "John", "Robert"], "Pet": ["dog", "cat", "bird"]}
| ... )
| >>> conn = st.connection("snowflake")
| >>> conn.write_pandas(df, "my_table")
|
| ----------------------------------------------------------------------
| Readonly properties inherited from BaseSnowflakeConnection:
|
| raw_connection
| Access the underlying connection object from the Snowflake Connector for Python.
|
| For information on how to use the Snowflake Connector for Python, see
| the `Snowflake Connector for Python documentation
| <https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-example>`_.
|
| Returns
| -------
| snowflake.connector.connection.SnowflakeConnection
| The connection object.
|
| Example
| -------
| The following example uses a cursor to submit an asynchronous query,
| saves the query ID, then periodically checks the query status through
| the connection before retrieving the results.
|
| >>> import streamlit as st
| >>> import time
| >>>
| >>> conn = st.connection("snowflake")
| >>> cur = conn.cursor()
| >>> cur.execute_async("SELECT * FROM my_table")
| >>> query_id = cur.sfqid
| >>> while True:
| ... status = conn.raw_connection.get_query_status(query_id)
| ... if conn.raw_connection.is_still_running(status):
| ... time.sleep(1)
| ... else:
| ... break
| >>> cur.get_results_from_sfqid(query_id)
| >>> df = cur.fetchall()
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from BaseSnowflakeConnection:
|
| __orig_bases__ = (streamlit.connections.base_connection.BaseConnection...
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.connections.base_connection.BaseConnection:
|
| __del__(self) -> 'None'
|
| __getattribute__(self, name: 'str') -> 'Any'
| Return getattr(self, name).
|
| __init__(self, connection_name: 'str', **kwargs: 'Any') -> 'None'
| Create a BaseConnection.
|
| This constructor is called by the connection factory machinery when a user
| script calls ``st.connection()``.
|
| Subclasses of BaseConnection that want to overwrite this method should take care
| to also call the base class' implementation.
|
| Parameters
| ----------
| connection_name : str
| The name of this connection. This corresponds to the
| ``[connections.<connection_name>]`` config section in ``st.secrets``.
| kwargs : dict
| Any other kwargs to pass to this connection class' ``_connect`` method.
|
| reset(self) -> 'None'
| Reset this connection so that it gets reinitialized the next time it's used.
|
| This method can be useful when a connection has become stale, an auth token has
| expired, or in similar scenarios where a broken connection might be fixed by
| reinitializing it. Note that some connection methods may already use ``reset()``
| in their error handling code.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("my_conn")
| >>>
| >>> # Reset the connection before using it if it isn't healthy
| >>> # Note: is_healthy() isn't a real method and is just shown for example here.
| >>> if not conn.is_healthy():
| ... conn.reset()
| >>>
| >>> # Do stuff with conn...
|
| ----------------------------------------------------------------------
| Class methods inherited from streamlit.connections.base_connection.BaseConnection:
|
| scope() -> "Literal['global', 'session']"
| Returns the scope of this connection type.
|
| This is a class method. ``"global"`` connection instances will be cached
| globally and are typically created once during the lifetime of an
| application. ``"session"`` connection instances will be cached per
| session and are typically created once per user session.
|
| A connection's scope can't be changed for different instances of the
| same connection type. If you want to switch between global and
| session-scoped connections, you should create two different connection
| types.
|
| Returns
| -------
| "global" or "session"
|
| ----------------------------------------------------------------------
| Data descriptors inherited from streamlit.connections.base_connection.BaseConnection:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.
class SnowparkConnection(streamlit.connections.base_connection.BaseConnection)
| SnowparkConnection(connection_name: 'str', **kwargs: 'Any') -> 'None'
|
| A connection to Snowpark using snowflake.snowpark.session.Session. Initialize using
| ``st.connection("<name>", type="snowpark")``.
|
| In addition to providing access to the Snowpark Session, SnowparkConnection supports
| direct SQL querying using ``query("...")`` and thread safe access using
| ``with conn.safe_session():``. See methods below for more information.
| SnowparkConnections should always be created using ``st.connection()``, **not**
| initialized directly.
|
| .. note::
| We don't expect this iteration of SnowparkConnection to be able to scale
| well in apps with many concurrent users due to the lock contention that will occur
| over the single underlying Session object under high load.
|
| .. deprecated::
| ``SnowparkConnection`` is deprecated and will be removed in a future release.
| Please use ``st.connection("<name>", type="snowflake")`` with
| ``SnowflakeConnection`` instead, which provides the same functionality
| with better support and additional features.
|
| Method resolution order:
| SnowparkConnection
| streamlit.connections.base_connection.BaseConnection
| abc.ABC
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__(self, connection_name: 'str', **kwargs: 'Any') -> 'None'
| Create a BaseConnection.
|
| This constructor is called by the connection factory machinery when a user
| script calls ``st.connection()``.
|
| Subclasses of BaseConnection that want to overwrite this method should take care
| to also call the base class' implementation.
|
| Parameters
| ----------
| connection_name : str
| The name of this connection. This corresponds to the
| ``[connections.<connection_name>]`` config section in ``st.secrets``.
| kwargs : dict
| Any other kwargs to pass to this connection class' ``_connect`` method.
|
| query(self, sql: 'str', ttl: 'float | int | timedelta | None' = None) -> 'DataFrame'
| Run a read-only SQL query.
|
| This method implements both query result caching (with caching behavior
| identical to that of using ``@st.cache_data``) as well as simple error handling/retries.
|
| .. note::
| Queries that are run without a specified ttl are cached indefinitely.
|
| Parameters
| ----------
| sql : str
| The read-only SQL query to execute.
| ttl : float, int, timedelta or None
| The maximum number of seconds to keep results in the cache, or
| None if cached results should not expire. The default is None.
|
| Returns
| -------
| pandas.DataFrame
| The result of running the query, formatted as a pandas DataFrame.
|
| Example
| -------
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("snowpark")
| >>> df = conn.query("SELECT * FROM pet_owners")
| >>> st.dataframe(df)
|
| safe_session(self) -> 'Iterator[Session]'
| Grab the underlying Snowpark session in a thread-safe manner.
|
| As operations on a Snowpark session are not thread safe, we need to take care
| when using a session in the context of a Streamlit app where each script run
| occurs in its own thread. Using the contextmanager pattern to do this ensures
| that access on this connection's underlying Session is done in a thread-safe
| manner.
|
| Information on how to use Snowpark sessions can be found in the `Snowpark documentation
| <https://docs.snowflake.com/en/developer-guide/snowpark/python/working-with-dataframes>`_.
|
| Example
| -------
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("snowpark")
| >>> with conn.safe_session() as session:
| ... df = session.table("mytable").limit(10).to_pandas()
| >>>
| >>> st.dataframe(df)
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| session
| Access the underlying Snowpark session.
|
| .. note::
| Snowpark sessions are **not** thread safe. Users of this method are
| responsible for ensuring that access to the session returned by this method is
| done in a thread-safe manner. For most users, we recommend using the thread-safe
| safe_session() method and a ``with`` block.
|
| Information on how to use Snowpark sessions can be found in the `Snowpark documentation
| <https://docs.snowflake.com/en/developer-guide/snowpark/python/working-with-dataframes>`_.
|
| Example
| -------
| >>> import streamlit as st
| >>>
| >>> session = st.connection("snowpark").session
| >>> df = session.table("mytable").limit(10).to_pandas()
| >>> st.dataframe(df)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __orig_bases__ = (streamlit.connections.base_connection.BaseConnection...
|
| __parameters__ = ()
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.connections.base_connection.BaseConnection:
|
| __del__(self) -> 'None'
|
| __getattribute__(self, name: 'str') -> 'Any'
| Return getattr(self, name).
|
| close(self) -> 'None'
| A function to invoke when this connection needs to be cleaned up.
|
| ``close`` is registered as an ``on_release`` hook in the resource cache when a
| connection is created with ``st.connection``.
|
| Returns
| -------
| None
|
| reset(self) -> 'None'
| Reset this connection so that it gets reinitialized the next time it's used.
|
| This method can be useful when a connection has become stale, an auth token has
| expired, or in similar scenarios where a broken connection might be fixed by
| reinitializing it. Note that some connection methods may already use ``reset()``
| in their error handling code.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> conn = st.connection("my_conn")
| >>>
| >>> # Reset the connection before using it if it isn't healthy
| >>> # Note: is_healthy() isn't a real method and is just shown for example here.
| >>> if not conn.is_healthy():
| ... conn.reset()
| >>>
| >>> # Do stuff with conn...
|
| ----------------------------------------------------------------------
| Class methods inherited from streamlit.connections.base_connection.BaseConnection:
|
| scope() -> "Literal['global', 'session']"
| Returns the scope of this connection type.
|
| This is a class method. ``"global"`` connection instances will be cached
| globally and are typically created once during the lifetime of an
| application. ``"session"`` connection instances will be cached per
| session and are typically created once per user session.
|
| A connection's scope can't be changed for different instances of the
| same connection type. If you want to switch between global and
| session-scoped connections, you should create two different connection
| types.
|
| Returns
| -------
| "global" or "session"
|
| ----------------------------------------------------------------------
| Data descriptors inherited from streamlit.connections.base_connection.BaseConnection:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.
DATA
__all__ = ['BaseConnection', 'ExperimentalBaseConnection', 'SQLConnect...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\connections\__init__.py
streamlit.container
Python Library Documentation: method container in module streamlit.delta_generator
container(*, border: 'bool | None' = None, key: 'Key | None' = None, width: 'Width' = 'stretch', height: 'Height' = 'content', horizontal: 'bool' = False, horizontal_alignment: 'HorizontalAlignment' = 'left', vertical_alignment: 'VerticalAlignment' = 'top', gap: 'Gap | None' = 'small', autoscroll: 'bool | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Insert a multi-element container.
Inserts an invisible container into your app that can be used to hold
multiple elements. This allows you to, for example, insert multiple
elements into your app out of order.
To add elements to the returned container, you can use the ``with``
notation (preferred) or just call commands directly on the returned
object. See examples below.
Parameters
----------
border : bool or None
Whether to show a border around the container. If ``None`` (default), a
border is shown if the container is set to a fixed height and not
shown otherwise.
key : str or None
An optional string to give this element a stable identity. If
this is ``None`` (default), the element's identity will be
determined based on the values of the other parameters.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
width : "stretch", "content", or int
The width of the container. This can be one of the following:
- ``"stretch"`` (default): The width of the container matches the
width of the parent container.
- ``"content"``: The width of the container matches the width of
its content.
- An integer specifying the width in pixels: The container has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the container matches the width
of the parent container.
height : "content", "stretch", or int
The height of the container. This can be one of the following:
- ``"content"`` (default): The height of the container matches the
height of its content.
- ``"stretch"``: The height of the container matches the height of
its content or the height of the parent container, whichever is
larger. If the container is not in a parent container, the height
of the container matches the height of its content.
- An integer specifying the height in pixels: The container has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
.. note::
Use scrolling containers sparingly. If you use scrolling
containers, avoid heights that exceed 500 pixels. Otherwise,
the scroll surface of the container might cover the majority of
the screen on mobile devices, which makes it hard to scroll the
rest of the app.
horizontal : bool
Whether to use horizontal flexbox layout. If this is ``False``
(default), the container's elements are laid out vertically. If
this is ``True``, the container's elements are laid out
horizontally and will overflow to the next line if they don't fit
within the container's width.
horizontal_alignment : "left", "center", "right", or "distribute"
The horizontal alignment of the elements inside the container. This
can be one of the following:
- ``"left"`` (default): Elements are aligned to the left side of
the container.
- ``"center"``: Elements are horizontally centered inside the
container.
- ``"right"``: Elements are aligned to the right side of the
container.
- ``"distribute"``: Elements are distributed evenly in the
container. This increases the horizontal gap between elements to
fill the width of the container. A standalone element is aligned
to the left.
When ``horizontal`` is ``False``, ``"distribute"`` aligns the
elements the same as ``"left"``.
vertical_alignment : "top", "center", "bottom", or "distribute"
The vertical alignment of the elements inside the container. This
can be one of the following:
- ``"top"`` (default): Elements are aligned to the top of the
container.
- ``"center"``: Elements are vertically centered inside the
container.
- ``"bottom"``: Elements are aligned to the bottom of the
container.
- ``"distribute"``: Elements are distributed evenly in the
container. This increases the vertical gap between elements to
fill the height of the container. A standalone element is aligned
to the top.
When ``horizontal`` is ``True``, ``"distribute"`` aligns the
elements the same as ``"top"``.
gap : "xxsmall", "xsmall", "small", "medium", "large", "xlarge", "xxlarge", or None
The minimum gap size between the elements inside the container.
This can be one of the following:
- ``"xxsmall"``: 0.25rem gap between the elements.
- ``"xsmall"``: 0.5rem gap between the elements.
- ``"small"`` (default): 1rem gap between the elements.
- ``"medium"``: 2rem gap between the elements.
- ``"large"``: 4rem gap between the elements.
- ``"xlarge"``: 6rem gap between the elements.
- ``"xxlarge"``: 8rem gap between the elements.
- ``None``: No gap between the elements.
The rem unit is relative to the ``theme.baseFontSize``
configuration option.
The minimum gap applies to both the vertical and horizontal gaps
between the elements. Elements may have larger gaps in one
direction if you use a distributed horizontal alignment or fixed
height.
autoscroll : bool or None
Whether to automatically scroll to the bottom when new content is
added. This only has an effect when the container has a fixed
height (scrolling enabled). If this is ``None`` (default),
auto-scroll is enabled when the container has a fixed height and
contains |st.chat_message|_ elements. If this is ``True``,
auto-scroll is always enabled for containers with fixed height.
If this is ``False``, auto-scroll is always disabled.
.. |st.chat_message| replace:: ``st.chat_message``
.. _st.chat_message: https://docs.streamlit.io/develop/api-reference/chat/st.chat_message
Examples
--------
**Example 1: Inserting elements using ``with`` notation**
You can use the ``with`` statement to insert any element into a
container.
>>> import streamlit as st
>>>
>>> with st.container():
... st.write("This is inside the container")
...
... # You can call any Streamlit command, including custom components:
... st.bar_chart(np.random.randn(50, 3))
>>>
>>> st.write("This is outside the container")
.. output::
https://doc-container1.streamlit.app/
height: 520px
**Example 2: Inserting elements out of order**
When you create a container, its position in the app remains fixed and
you can add elements to it at any time. This allows you to insert
elements out of order in your app. You can also write to the container
by calling commands directly on the container object.
>>> import streamlit as st
>>>
>>> container = st.container(border=True)
>>> container.write("This is inside the container")
>>> st.write("This is outside the container")
>>>
>>> container.write("This is inside too")
.. output::
https://doc-container2.streamlit.app/
height: 300px
**Example 3: Grid layout with columns and containers**
You can create a grid with a fixed number of elements per row by using
columns and containers.
>>> import streamlit as st
>>>
>>> row1 = st.columns(3)
>>> row2 = st.columns(3)
>>>
>>> for col in row1 + row2:
>>> tile = col.container(height=120)
>>> tile.title(":balloon:")
.. output::
https://doc-container3.streamlit.app/
height: 350px
**Example 4: Vertically scrolling container**
You can create a vertically scrolling container by setting a fixed
height.
>>> import streamlit as st
>>>
>>> long_text = "Lorem ipsum. " * 1000
>>>
>>> with st.container(height=300):
>>> st.markdown(long_text)
.. output::
https://doc-container4.streamlit.app/
height: 400px
**Example 5: Horizontal container**
You can create a row of widgets using a horizontal container. Use
``horizontal_alignment`` to specify the alignment of the elements.
>>> import streamlit as st
>>>
>>> flex = st.container(horizontal=True, horizontal_alignment="right")
>>>
>>> for card in range(3):
>>> flex.button(f"Button {card + 1}")
.. output::
https://doc-container5.streamlit.app/
height: 250px
streamlit.context
Python Library Documentation: ContextProxy in module streamlit.runtime.context object
class ContextProxy(builtins.object)
| An interface to access user session context.
|
| ``st.context`` provides a read-only interface to access headers and cookies
| for the current user session.
|
| Each property (``st.context.headers`` and ``st.context.cookies``) returns
| a dictionary of named values.
|
| Readonly properties defined here:
|
| cookies
| A read-only, dict-like object containing cookies sent in the initial request.
|
| Examples
| --------
| **Example 1: Access all available cookies**
|
| Show a dictionary of cookies:
|
| >>> import streamlit as st
| >>>
| >>> st.context.cookies
|
| **Example 2: Access a specific cookie**
|
| Show the value of a specific cookie:
|
| >>> import streamlit as st
| >>>
| >>> st.context.cookies["_ga"]
|
| headers
| A read-only, dict-like object containing headers sent in the initial request.
|
| Keys are case-insensitive and may be repeated. When keys are repeated,
| dict-like methods will only return the last instance of each key. Use
| ``.get_all(key="your_repeated_key")`` to see all values if the same
| header is set multiple times.
|
| Examples
| --------
| **Example 1: Access all available headers**
|
| Show a dictionary of headers (with only the last instance of any
| repeated key):
|
| >>> import streamlit as st
| >>>
| >>> st.context.headers
|
| **Example 2: Access a specific header**
|
| Show the value of a specific header (or the last instance if it's
| repeated):
|
| >>> import streamlit as st
| >>>
| >>> st.context.headers["host"]
|
| Show of list of all headers for a given key:
|
| >>> import streamlit as st
| >>>
| >>> st.context.headers.get_all("pragma")
|
| ip_address
| The read-only IP address of the user's connection.
|
| This should not be used for security measures because it can easily be
| spoofed. When a user accesses the app through ``localhost``, the IP
| address is ``None``. Otherwise, the IP address is determined from the
| WebSocket connection and may be an IPv4 or IPv6 address.
|
| Examples
| --------
| Check if the user has an IPv4 or IPv6 address:
|
| >>> import streamlit as st
| >>>
| >>> ip = st.context.ip_address
| >>> if ip is None:
| >>> st.write("No IP address. This is expected in local development.")
| >>> elif ip.contains(":"):
| >>> st.write("You have an IPv6 address.")
| >>> elif ip.contains("."):
| >>> st.write("You have an IPv4 address.")
| >>> else:
| >>> st.error("This should not happen.")
|
| is_embedded
| Whether the app is embedded.
|
| This property returns a boolean value indicating whether the app is
| running in an embedded context. This is determined by the presence of
| ``embed=true`` as a query parameter in the URL. This is the only way to
| determine if the app is currently configured for embedding because
| embedding settings are not accessible through ``st.query_params`` or
| ``st.context.url``.
|
| Examples
| --------
| Conditionally show content when the app is running in an embedded
| context:
|
| >>> import streamlit as st
| >>>
| >>> if st.context.is_embedded:
| >>> st.write("You are running the app in an embedded context.")
|
| locale
| The read-only locale of the user's browser.
|
| ``st.context.locale`` returns the value of |navigator.language|_ from
| the user's DOM. This is a string representing the user's preferred
| language (e.g. "en-US").
|
| .. |navigator.language| replace:: ``navigator.language``
| .. _navigator.language: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language
|
| Examples
| --------
| Access the user's locale to display locally:
|
| >>> import streamlit as st
| >>>
| >>> if st.context.locale == "fr-FR":
| >>> st.write("Bonjour!")
| >>> else:
| >>> st.write("Hello!")
|
| theme
| A read-only, dictionary-like object containing theme information.
|
| Theme information is restricted to the ``type`` of the theme (dark or
| light) and is inferred from the background color of the app.
|
| .. note::
| Changes made to the background color through CSS are not included.
| Additionally, the theme type may be incorrect during a change in
| theme, like in the following situations:
|
| - When the app is first loaded within a session
| - When the user changes the theme in the settings menu
|
| For more information and to upvote an improvement, see GitHub issue
| `#11920 <https://github.com/streamlit/streamlit/issues/11920>`_.
|
| Attributes
| ----------
| type : "light", "dark"
| The theme type inferred from the background color of the app.
|
| Examples
| --------
| Access the theme type of the app:
|
| >>> import streamlit as st
| >>>
| >>> st.write(f"The current theme type is {st.context.theme.type}.")
|
| timezone
| The read-only timezone of the user's browser.
|
| Examples
| --------
| Access the user's timezone, and format a datetime to display locally:
|
| >>> import streamlit as st
| >>> from datetime import datetime, timezone
| >>> import pytz
| >>>
| >>> tz = st.context.timezone
| >>> tz_obj = pytz.timezone(tz)
| >>>
| >>> now = datetime.now(timezone.utc)
| >>>
| >>> f"The user's timezone is {tz}."
| >>> f"The UTC time is {now}."
| >>> f"The user's local time is {now.astimezone(tz_obj)}"
|
| timezone_offset
| The read-only timezone offset of the user's browser.
|
| Examples
| --------
| Access the user's timezone offset, and format a datetime to display locally:
|
| >>> import streamlit as st
| >>> from datetime import datetime, timezone, timedelta
| >>>
| >>> tzoff = st.context.timezone_offset
| >>> tz_obj = timezone(-timedelta(minutes=tzoff))
| >>>
| >>> now = datetime.now(timezone.utc)
| >>>
| >>> f"The user's timezone is {tz}."
| >>> f"The UTC time is {now}."
| >>> f"The user's local time is {now.astimezone(tz_obj)}"
|
| url
| The read-only URL of the app in the user's browser.
|
| ``st.context.url`` returns the URL through which the user is accessing
| the app. This includes the scheme, domain name, port, and path. If
| query parameters or anchors are present in the URL, they are removed
| and not included in this value.
|
| Examples
| --------
| Conditionally show content when you access your app through
| ``localhost``:
|
| >>> import streamlit as st
| >>>
| >>> if st.context.url.startswith("http://localhost"):
| >>> st.write("You are running the app locally.")
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
streamlit.cursor
Python Library Documentation: module streamlit.cursor in streamlit
NAME
streamlit.cursor
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CLASSES
builtins.object
Cursor
LockedCursor
RunningCursor
typing.Generic(builtins.object)
SparseList
class Cursor(builtins.object)
| Cursor(transient_index: 'int | None' = None, transient_elements: 'SparseList[Element] | None' = None) -> 'None'
|
| A pointer to a delta location in the app.
|
| When adding an element to the app, you should always call
| get_locked_cursor() on that element's respective Cursor.
|
| Parameters
| ----------
| transient_index: int | None
| The running index of the transient elements.
| transient_elements: SparseList[Element] | None
| The list of active transient elements.
|
| Methods defined here:
|
| __init__(self, transient_index: 'int | None' = None, transient_elements: 'SparseList[Element] | None' = None) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| get_locked_cursor(self, **props: 'Any') -> 'LockedCursor'
|
| get_transient_cursor(self) -> 'Cursor'
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| delta_path
| The complete path of the delta pointed to by this cursor - its
| container, parent path, and index.
|
| index
| The index of the Delta within its parent block.
|
| is_locked
|
| parent_path
| The cursor's parent's path within its container.
|
| props
| Other data in this cursor. This is a temporary measure that will go
| away when we implement improved return values for elements.
|
| This is only implemented in LockedCursor.
|
| root_container
| The top-level container this cursor lives within - either
| RootContainer.MAIN or RootContainer.SIDEBAR.
|
| transient_elements
|
| transient_index
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class LockedCursor(Cursor)
| LockedCursor(root_container: 'int', parent_path: 'tuple[int, ...]' = (), index: 'int' = 0, transient_index: 'int | None' = None, transient_elements: 'SparseList[Element] | None' = None, **props: 'Any') -> 'None'
|
| Method resolution order:
| LockedCursor
| Cursor
| builtins.object
|
| Methods defined here:
|
| __init__(self, root_container: 'int', parent_path: 'tuple[int, ...]' = (), index: 'int' = 0, transient_index: 'int | None' = None, transient_elements: 'SparseList[Element] | None' = None, **props: 'Any') -> 'None'
| A locked pointer to a location in the app.
|
| LockedCursors always point to the same location, even when you call
| get_locked_cursor() on them.
|
| Parameters
| ----------
| root_container: int
| The root container this cursor lives in.
| parent_path: tuple of ints
| The full path of this cursor, consisting of the IDs of all ancestors. The
| 0th item is the topmost ancestor.
| index: int
| transient_index: int | None
| The running index of the transient elements.
| transient_elements: SparseList[Element]
| The list of active transient elements.
| **props: any
| Anything else you want to store in this cursor. This is a temporary
| measure that will go away when we implement improved return values
| for elements.
|
| get_locked_cursor(self, **props: 'Any') -> 'LockedCursor'
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| index
| The index of the Delta within its parent block.
|
| is_locked
|
| parent_path
| The cursor's parent's path within its container.
|
| props
| Other data in this cursor. This is a temporary measure that will go
| away when we implement improved return values for elements.
|
| This is only implemented in LockedCursor.
|
| root_container
| The top-level container this cursor lives within - either
| RootContainer.MAIN or RootContainer.SIDEBAR.
|
| ----------------------------------------------------------------------
| Methods inherited from Cursor:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| get_transient_cursor(self) -> 'Cursor'
|
| ----------------------------------------------------------------------
| Readonly properties inherited from Cursor:
|
| delta_path
| The complete path of the delta pointed to by this cursor - its
| container, parent path, and index.
|
| transient_elements
|
| transient_index
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Cursor:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class RunningCursor(Cursor)
| RunningCursor(root_container: 'int', parent_path: 'tuple[int, ...]' = (), transient_index: 'int | None' = None, transient_elements: 'SparseList[Element] | None' = None) -> 'None'
|
| Method resolution order:
| RunningCursor
| Cursor
| builtins.object
|
| Methods defined here:
|
| __init__(self, root_container: 'int', parent_path: 'tuple[int, ...]' = (), transient_index: 'int | None' = None, transient_elements: 'SparseList[Element] | None' = None) -> 'None'
| A moving pointer to a delta location in the app.
|
| RunningCursors auto-increment to the next available location when you
| call get_locked_cursor() on them.
|
| Parameters
| ----------
| root_container: int
| The root container this cursor lives in.
| parent_path: tuple of ints
| The full path of this cursor, consisting of the IDs of all ancestors.
| The 0th item is the topmost ancestor.
| transient_index: int | None
| The running index of the transient elements.
| transient_elements: SparseList[Element]
| The list of active transient elements.
|
| get_locked_cursor(self, **props: 'Any') -> 'LockedCursor'
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| index
| The index of the Delta within its parent block.
|
| is_locked
|
| parent_path
| The cursor's parent's path within its container.
|
| root_container
| The top-level container this cursor lives within - either
| RootContainer.MAIN or RootContainer.SIDEBAR.
|
| ----------------------------------------------------------------------
| Methods inherited from Cursor:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| get_transient_cursor(self) -> 'Cursor'
|
| ----------------------------------------------------------------------
| Readonly properties inherited from Cursor:
|
| delta_path
| The complete path of the delta pointed to by this cursor - its
| container, parent path, and index.
|
| props
| Other data in this cursor. This is a temporary measure that will go
| away when we implement improved return values for elements.
|
| This is only implemented in LockedCursor.
|
| transient_elements
|
| transient_index
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Cursor:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class SparseList(typing.Generic)
| SparseList() -> 'None'
|
| A list-like data structure that only stores non-empty items.
|
| Method resolution order:
| SparseList
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __contains__(self, index: 'int') -> 'bool'
|
| __delitem__(self, index: 'int') -> 'None'
|
| __getitem__(self, index: 'int') -> 'T'
|
| __init__(self) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self) -> 'Iterator[T]'
|
| __len__(self) -> 'int'
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| __setitem__(self, index: 'int', value: 'T') -> 'None'
|
| items(self) -> 'Iterator[tuple[int, T]]'
| Iterate through (index, value) for filled entries.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| __orig_bases__ = (typing.Generic[~T],)
|
| __parameters__ = (~T,)
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.
FUNCTIONS
get_container_cursor(root_container: 'int | None') -> 'RunningCursor | None'
Return the top-level RunningCursor for the given container.
This is the cursor that is used when user code calls something like
`st.foo` (which uses the main container) or `st.sidebar.foo` (which uses
the sidebar container).
make_delta_path(root_container: 'int', parent_path: 'tuple[int, ...]', index: 'int') -> 'list[int]'
DATA
T = ~T
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\cursor.py
streamlit.data_editor
Python Library Documentation: method data_editor in module streamlit.delta_generator
data_editor(data: 'DataTypes', *, width: 'Width' = 'stretch', height: "Height | Literal['auto']" = 'auto', use_container_width: 'bool | None' = None, hide_index: 'bool | None' = None, column_order: 'Iterable[str] | None' = None, column_config: 'ColumnConfigMappingInput | None' = None, num_rows: "Literal['fixed', 'dynamic', 'add', 'delete']" = 'fixed', disabled: 'bool | Iterable[str | int]' = False, key: 'Key | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, row_height: 'int | None' = None, placeholder: 'str | None' = None) -> 'DataTypes' method of streamlit.delta_generator.DeltaGenerator instance
Display a data editor widget.
The data editor widget allows you to edit dataframes and many other data structures in a table-like UI.
Parameters
----------
data : Anything supported by st.dataframe
The data to edit in the data editor.
.. note::
- Styles from ``pandas.Styler`` will only be applied to non-editable columns.
- Text and number formatting from ``column_config`` always takes
precedence over text and number formatting from ``pandas.Styler``.
- If your dataframe starts with an empty column, you should set
the column datatype in the underlying dataframe to ensure your
intended datatype, especially for integers versus floats.
- Mixing data types within a column can make the column uneditable.
- Additionally, the following data types are not yet supported for editing:
``complex``, ``tuple``, ``bytes``, ``bytearray``,
``memoryview``, ``dict``, ``set``, ``frozenset``,
``fractions.Fraction``, ``pandas.Interval``, and
``pandas.Period``.
- To prevent overflow in JavaScript, columns containing
``datetime.timedelta`` and ``pandas.Timedelta`` values will
default to uneditable, but this can be changed through column
configuration.
width : "stretch", "content", or int
The width of the data editor. This can be one of the following:
- ``"stretch"`` (default): The width of the editor matches the
width of the parent container.
- ``"content"``: The width of the editor matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The editor has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the editor matches the width
of the parent container.
height : "auto", "content", "stretch", or int
The height of the data editor. This can be one of the following:
- ``"auto"`` (default): Streamlit sets the height to show at most
ten rows.
- ``"content"``: The height of the editor matches the height of
its content. The height is capped at 10,000 pixels to prevent
performance issues with very large dataframes.
- ``"stretch"``: The height of the editor expands to fill the
available vertical space in its parent container. When multiple
elements with stretch height are in the same container, they
share the available vertical space evenly. The editor will
maintain a minimum height to display up to three rows, but
otherwise won't exceed the available height in its parent
container.
- An integer specifying the height in pixels: The editor has a
fixed height.
Vertical scrolling within the editor is enabled when the height
does not accommodate all rows.
use_container_width : bool
Whether to override ``width`` with the width of the parent
container. If this is ``True`` (default), Streamlit sets the width
of the data editor to match the width of the parent container. If
this is ``False``, Streamlit sets the data editor's width according
to ``width``.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
hide_index : bool or None
Whether to hide the index column(s). If ``hide_index`` is ``None``
(default), the visibility of index columns is automatically
determined based on the data.
column_order : Iterable[str] or None
The ordered list of columns to display. If this is ``None``
(default), Streamlit displays all columns in the order inherited
from the underlying data structure. If this is a list, the
indicated columns will display in the order they appear within the
list. Columns may be omitted or repeated within the list.
For example, ``column_order=("col2", "col1")`` will display
``"col2"`` first, followed by ``"col1"``, and will hide all other
non-index columns.
``column_order`` does not accept positional column indices and
can't move the index column(s).
.. note::
Columns omitted from ``column_order`` are hidden by default
but can still be shown by the user via the column visibility
menu in the table toolbar. If a column contains sensitive data
that should not be exposed to the user, remove it from the
data before passing it to the function.
column_config : dict or None
Configuration to customize how columns are displayed. If this is
``None`` (default), columns are styled based on the underlying data
type of each column.
Column configuration can modify column names, visibility, type,
width, format, editing properties like min/max, and more. If this
is a dictionary, the keys are column names (strings) and/or
positional column indices (integers), and the values are one of the
following:
- ``None`` to hide the column. Hidden columns can still be shown
by the user via the table toolbar.
- A string to set the display label of the column.
- One of the column types defined under ``st.column_config``. For
example, to show a column as dollar amounts, use
``st.column_config.NumberColumn("Dollar values", format="$ %d")``.
See more info on the available column types and config options
`here <https://docs.streamlit.io/develop/api-reference/data/st.column_config>`_.
To configure the index column(s), use ``"_index"`` as the column
name, or use a positional column index where ``0`` refers to the
first index column.
num_rows : "fixed", "dynamic", "add", or "delete"
Specifies if the user can add and/or delete rows in the data editor.
- ``"fixed"`` (default): The user can't add or delete rows.
- ``"dynamic"``: The user can add and delete rows, and column
sorting is disabled.
- ``"add"``: The user can only add rows (no deleting), and column
sorting is disabled.
- ``"delete"``: The user can only delete rows (no adding), and
column sorting remains enabled.
disabled : bool or Iterable[str | int]
Controls the editing of columns. This can be one of the following:
- ``False`` (default): All columns that support editing are editable.
- ``True``: All columns are disabled for editing.
- An Iterable of column names and/or positional indices: The
specified columns are disabled for editing while the remaining
columns are editable where supported. For example,
``disabled=["col1", "col2"]`` will disable editing for the
columns named "col1" and "col2".
To disable editing for the index column(s), use ``"_index"`` as the
column name, or use a positional column index where ``0`` refers to
the first index column.
key : str, int, or None
An optional string to use as the unique key for this widget.
If this is ``None`` (default), a key will be generated for
the widget based on the values of the other parameters. No
two widgets may have the same key.
A key lets you access the widget's value via
``st.session_state[key]`` (read-only). For more details, see
`Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
on_change : callable
An optional callback invoked when this data_editor's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
row_height : int or None
The height of each row in the data editor in pixels. If ``row_height``
is ``None`` (default), Streamlit will use a default row height,
which fits one line of text.
placeholder : str or None
The text that should be shown for missing values. If this is
``None`` (default), missing values are displayed as "None". To
leave a cell empty, use an empty string (``""``). Other common
values are ``"null"``, ``"NaN"`` and ``"-"``.
Returns
-------
pandas.DataFrame, pandas.Series, pyarrow.Table, numpy.ndarray, list, set, tuple, or dict.
The edited data. The edited data is returned in its original data type if
it corresponds to any of the supported return types. All other data types
are returned as a ``pandas.DataFrame``.
Examples
--------
**Example 1: Basic usage**
>>> import pandas as pd
>>> import streamlit as st
>>>
>>> df = pd.DataFrame(
>>> [
>>> {"command": "st.selectbox", "rating": 4, "is_widget": True},
>>> {"command": "st.balloons", "rating": 5, "is_widget": False},
>>> {"command": "st.time_input", "rating": 3, "is_widget": True},
>>> ]
>>> )
>>> edited_df = st.data_editor(df)
>>>
>>> favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
>>> st.markdown(f"Your favorite command is **{favorite_command}** 🎈")
.. output::
https://doc-data-editor.streamlit.app/
height: 350px
**Example 2: Allowing users to add and delete rows**
You can allow your users to add and delete rows by setting ``num_rows``
to "dynamic":
>>> import streamlit as st
>>> import pandas as pd
>>>
>>> df = pd.DataFrame(
>>> [
>>> {"command": "st.selectbox", "rating": 4, "is_widget": True},
>>> {"command": "st.balloons", "rating": 5, "is_widget": False},
>>> {"command": "st.time_input", "rating": 3, "is_widget": True},
>>> ]
>>> )
>>> edited_df = st.data_editor(df, num_rows="dynamic")
>>>
>>> favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
>>> st.markdown(f"Your favorite command is **{favorite_command}** 🎈")
.. output::
https://doc-data-editor1.streamlit.app/
height: 450px
**Example 3: Data editor configuration**
You can customize the data editor via ``column_config``, ``hide_index``,
``column_order``, or ``disabled``:
>>> import pandas as pd
>>> import streamlit as st
>>>
>>> df = pd.DataFrame(
>>> [
>>> {"command": "st.selectbox", "rating": 4, "is_widget": True},
>>> {"command": "st.balloons", "rating": 5, "is_widget": False},
>>> {"command": "st.time_input", "rating": 3, "is_widget": True},
>>> ]
>>> )
>>> edited_df = st.data_editor(
>>> df,
>>> column_config={
>>> "command": "Streamlit Command",
>>> "rating": st.column_config.NumberColumn(
>>> "Your rating",
>>> help="How much do you like this command (1-5)?",
>>> min_value=1,
>>> max_value=5,
>>> step=1,
>>> format="%d ⭐",
>>> ),
>>> "is_widget": "Widget ?",
>>> },
>>> disabled=["command", "is_widget"],
>>> hide_index=True,
>>> )
>>>
>>> favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
>>> st.markdown(f"Your favorite command is **{favorite_command}** 🎈")
.. output::
https://doc-data-editor-config.streamlit.app/
height: 350px
streamlit.dataframe
Python Library Documentation: method dataframe in module streamlit.delta_generator
dataframe(data: 'Data' = None, width: 'Width' = 'stretch', height: "Height | Literal['auto']" = 'auto', *, use_container_width: 'bool | None' = None, hide_index: 'bool | None' = None, column_order: 'Iterable[str] | None' = None, column_config: 'ColumnConfigMappingInput | None' = None, key: 'Key | None' = None, on_select: "Literal['ignore', 'rerun'] | WidgetCallback" = 'ignore', selection_mode: 'SelectionMode | Iterable[SelectionMode]' = 'multi-row', selection_default: 'DataframeState | None' = None, row_height: 'int | None' = None, placeholder: 'str | None' = None) -> 'DeltaGenerator | DataframeState' method of streamlit.delta_generator.DeltaGenerator instance
Display a dataframe as an interactive table.
This command works with a wide variety of collection-like and
dataframe-like object types.
Parameters
----------
data : dataframe-like, collection-like, or None
The data to display.
Dataframe-like objects include dataframe and series objects from
popular libraries like Dask, Modin, Numpy, pandas, Polars, PyArrow,
Snowpark, Xarray, and more. You can use database cursors and
clients that comply with the
`Python Database API Specification v2.0 (PEP 249)
<https://peps.python.org/pep-0249/>`_. Additionally, you can use
anything that supports the `Python dataframe interchange protocol
<https://data-apis.org/dataframe-protocol/latest/>`_.
For example, you can use the following:
- ``pandas.DataFrame``, ``pandas.Series``, ``pandas.Index``,
``pandas.Styler``, and ``pandas.Array``
- ``polars.DataFrame``, ``polars.LazyFrame``, and ``polars.Series``
- ``snowflake.snowpark.dataframe.DataFrame``,
``snowflake.snowpark.table.Table``
If a data type is not recognized, Streamlit will convert the object
to a ``pandas.DataFrame`` or ``pyarrow.Table`` using a
``.to_pandas()`` or ``.to_arrow()`` method, respectively, if
available.
If ``data`` is a ``pandas.Styler``, it will be used to style its
underlying ``pandas.DataFrame``. Streamlit supports custom cell
values, colors, and font weights. It does not support some of the
more exotic styling options, like bar charts, hovering, and
captions. For these styling options, use column configuration
instead. Text and number formatting from ``column_config`` always
takes precedence over text and number formatting from ``pandas.Styler``.
Collection-like objects include all Python-native ``Collection``
types, such as ``dict``, ``list``, and ``set``.
If ``data`` is ``None``, Streamlit renders an empty table.
width : "stretch", "content", or int
The width of the dataframe element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
height : "auto", "content", "stretch", or int
The height of the dataframe element. This can be one of the following:
- ``"auto"`` (default): Streamlit sets the height to show at most
ten rows.
- ``"content"``: The height of the element matches the height of
its content. The height is capped at 10,000 pixels to prevent
performance issues with very large dataframes.
- ``"stretch"``: The height of the element expands to fill the
available vertical space in its parent container. When multiple
elements with stretch height are in the same container, they
share the available vertical space evenly. The dataframe will
maintain a minimum height to display up to three rows, but
otherwise won't exceed the available height in its parent
container.
- An integer specifying the height in pixels: The element has a
fixed height.
Vertical scrolling within the dataframe element is enabled when the
height does not accommodate all rows.
use_container_width : bool
Whether to override ``width`` with the width of the parent
container. If this is ``True`` (default), Streamlit sets the width
of the dataframe to match the width of the parent container. If
this is ``False``, Streamlit sets the dataframe's width according
to ``width``.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
hide_index : bool or None
Whether to hide the index column(s). If ``hide_index`` is ``None``
(default), the visibility of index columns is automatically
determined based on the data and other configurations.
column_order : Iterable[str] or None
The ordered list of columns to display. If this is ``None``
(default), Streamlit displays all columns in the order inherited
from the underlying data structure. If this is a list, the
indicated columns will display in the order they appear within the
list. Columns may be omitted or repeated within the list.
For example, ``column_order=("col2", "col1")`` will display
``"col2"`` first, followed by ``"col1"``, and will hide all other
non-index columns.
``column_order`` does not accept positional column indices and
can't move the index column(s).
.. note::
Columns omitted from ``column_order`` are hidden by default
but can still be shown by the user via the column visibility
menu in the table toolbar. If a column contains sensitive data
that should not be exposed to the user, remove it from the
data before passing it to the function.
column_config : dict or None
Configuration to customize how columns are displayed. If this is
``None`` (default), columns are styled based on the underlying data
type of each column.
Column configuration can modify column names, visibility, type,
width, format, and more. If this is a dictionary, the keys are
column names (strings) and/or positional column indices (integers),
and the values are one of the following:
- ``None`` to hide the column. Hidden columns can still be shown
by the user via the table toolbar.
- A string to set the display label of the column.
- One of the column types defined under ``st.column_config``. For
example, to show a column as dollar amounts, use
``st.column_config.NumberColumn("Dollar values", format="$ %d")``.
See more info on the available column types and config options
`here <https://docs.streamlit.io/develop/api-reference/data/st.column_config>`_.
To configure the index column(s), use ``"_index"`` as the column
name, or use a positional column index where ``0`` refers to the
first index column.
key : str, int, or None
An optional string to use for giving this element a stable
identity. If this is ``None`` (default), the element's identity
will be determined based on the values of the other parameters.
If selections are activated, a key lets you read or update the
selection state via ``st.session_state[key]``. The value in
Session State must be a dictionary consistent with the
``DataframeState`` schema. For more details, see `Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
on_select : "ignore" or "rerun" or callable
How the dataframe should respond to user selection events. This
controls whether or not the dataframe behaves like an input widget.
``on_select`` can be one of the following:
- ``"ignore"`` (default): Streamlit will not react to any selection
events in the dataframe. The dataframe will not behave like an
input widget.
- ``"rerun"``: Streamlit will rerun the app when the user selects
rows, columns, or cells in the dataframe. In this case,
``st.dataframe`` will return the selection data as a dictionary.
- A ``callable``: Streamlit will rerun the app and execute the
``callable`` as a callback function before the rest of the app.
In this case, ``st.dataframe`` will return the selection data
as a dictionary.
selection_mode : "single-row", "single-row-required", "multi-row", "single-column", "multi-column", "single-cell", "multi-cell", or Iterable of these
The types of selections Streamlit should allow when selections are
enabled with ``on_select``. This can be one of the following:
- "multi-row" (default): Multiple rows can be selected at a time.
- "single-row": Only one row can be selected at a time.
- "single-row-required": Exactly one row must always be selected
(radio-like behavior). Auto-selects the first row if no default
is given.
- "multi-column": Multiple columns can be selected at a time.
- "single-column": Only one column can be selected at a time.
- "multi-cell": A rectangular range of cells can be selected.
- "single-cell": Only one cell can be selected at a time.
- An ``Iterable`` of the above options: The table will allow
selection based on the modes specified. For example, to allow the
user to select multiple rows and multiple cells, use
``["multi-row", "multi-cell"]``.
When column selections are enabled, column sorting is disabled.
selection_default : dict or None
The default selection state to apply on first render when selections
are activated and no prior selection is stored. This uses the same
schema as ``st.session_state[key]`` for selections, for example:
``{"selection": {"rows": [0, 2]}}``.
``selection_default`` is only applied when ``on_select`` is not
``"ignore"``. It does not override user selections on subsequent
runs, and multi-cell selections cannot be set programmatically.
row_height : int or None
The height of each row in the dataframe in pixels. If ``row_height``
is ``None`` (default), Streamlit will use a default row height,
which fits one line of text.
placeholder : str or None
The text that should be shown for missing values. If this is
``None`` (default), missing values are displayed as "None". To
leave a cell empty, use an empty string (``""``). Other common
values are ``"null"``, ``"NaN"`` and ``"-"``.
Returns
-------
element or dict
If ``on_select`` is ``"ignore"`` (default), this command returns an
internal placeholder for the dataframe element that can be used
with the ``.add_rows()`` method. Otherwise, this command returns a
dictionary-like object that supports both key and attribute
notation. The attributes are described by the ``DataframeState``
dictionary schema.
Examples
--------
**Example 1: Display a dataframe**
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... rng(0).standard_normal((50, 20)), columns=("col %d" % i for i in range(20))
... )
>>>
>>> st.dataframe(df)
.. output::
https://doc-dataframe.streamlit.app/
height: 500px
**Example 2: Use Pandas Styler**
You can also pass a Pandas Styler object to change the style of
the rendered DataFrame:
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... rng(0).standard_normal((10, 20)), columns=("col %d" % i for i in range(20))
... )
>>>
>>> st.dataframe(df.style.highlight_max(axis=0))
.. output::
https://doc-dataframe1.streamlit.app/
height: 500px
**Example 3: Use column configuration**
You can customize a dataframe via ``column_config``, ``hide_index``, or ``column_order``.
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... {
... "name": ["Roadmap", "Extras", "Issues"],
... "url": [
... "https://roadmap.streamlit.app",
... "https://extras.streamlit.app",
... "https://issues.streamlit.app",
... ],
... "stars": rng(0).integers(0, 1000, size=3),
... "views_history": rng(0).integers(0, 5000, size=(3, 30)).tolist(),
... }
... )
>>>
>>> st.dataframe(
... df,
... column_config={
... "name": "App name",
... "stars": st.column_config.NumberColumn(
... "Github Stars",
... help="Number of stars on GitHub",
... format="%d ⭐",
... ),
... "url": st.column_config.LinkColumn("App URL"),
... "views_history": st.column_config.LineChartColumn(
... "Views (past 30 days)", y_min=0, y_max=5000
... ),
... },
... hide_index=True,
... )
.. output::
https://doc-dataframe-config.streamlit.app/
height: 350px
**Example 4: Customize your index**
You can use column configuration to format your index.
>>> from datetime import datetime, date
>>> import numpy as np
>>> import pandas as pd
>>> import streamlit as st
>>>
>>> @st.cache_data
>>> def load_data():
>>> year = datetime.now().year
>>> df = pd.DataFrame(
... {
... "Date": [date(year, month, 1) for month in range(1, 4)],
... "Total": np.random.randint(1000, 5000, size=3),
... }
... )
>>> df.set_index("Date", inplace=True)
>>> return df
>>>
>>> df = load_data()
>>> config = {
... "_index": st.column_config.DateColumn("Month", format="MMM YYYY"),
... "Total": st.column_config.NumberColumn("Total ($)"),
... }
>>>
>>> st.dataframe(df, column_config=config)
.. output::
https://doc-dataframe-config-index.streamlit.app/
height: 225px
streamlit.dataframe_util
Python Library Documentation: module streamlit.dataframe_util in streamlit
NAME
streamlit.dataframe_util - A bunch of useful utilities for dealing with dataframes.
CLASSES
enum.Enum(builtins.object)
DataFormat
typing.Protocol(typing.Generic)
ArrowStreamExportable
DBAPICursor
DataFrameGenericAlias
DataframeInterchangeCompatible
PandasCompatible
class ArrowStreamExportable(typing.Protocol)
| ArrowStreamExportable(*args, **kwargs)
|
| Protocol for objects implementing the Arrow PyCapsule Interface.
|
| Objects implementing this protocol can export their data as an Arrow stream
| via the C Data Interface using PyCapsules. This is the recommended way for
| cross-library Arrow data exchange, replacing the deprecated DataFrame
| Interchange Protocol.
|
| https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html
|
| Method resolution order:
| ArrowStreamExportable
| typing.Protocol
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __arrow_c_stream__(self, requested_schema: 'Any' = None) -> 'Any'
|
| __init__ = _no_init_or_replace_init(self, *args, **kwargs) from typing
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __subclasshook__ = _proto_hook(other) from typing
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __parameters__ = ()
|
| __protocol_attrs__ = {'__arrow_c_stream__'}
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Protocol:
|
| __init_subclass__(*args, **kwargs)
| Function to initialize subclasses.
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
class DBAPICursor(typing.Protocol)
| DBAPICursor(*args, **kwargs)
|
| Protocol for DBAPI 2.0 Cursor objects (PEP 249).
|
| This is a simplified version of the DBAPI Cursor protocol
| that only contains the methods that are relevant or used for
| our DB API Integration.
|
| Specification: https://peps.python.org/pep-0249/
| Inspired by: https://github.com/python/typeshed/blob/main/stdlib/_typeshed/dbapi.pyi
|
| Method resolution order:
| DBAPICursor
| typing.Protocol
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__ = _no_init_or_replace_init(self, *args, **kwargs) from typing
|
| fetchall(self) -> 'Sequence[Sequence[Any]]'
|
| fetchmany(self, size: 'int' = Ellipsis, /) -> 'Sequence[Sequence[Any]]'
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __subclasshook__ = _proto_hook(other) from typing
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| description
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __non_callable_proto_members__ = {'description'}
|
| __parameters__ = ()
|
| __protocol_attrs__ = {'description', 'fetchall', 'fetchmany'}
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Protocol:
|
| __init_subclass__(*args, **kwargs)
| Function to initialize subclasses.
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
class DataFormat(enum.Enum)
| DataFormat(*values)
|
| DataFormat is used to determine the format of the data.
|
| Method resolution order:
| DataFormat
| enum.Enum
| builtins.object
|
| Data and other attributes defined here:
|
| COLUMN_INDEX_MAPPING = <DataFormat.COLUMN_INDEX_MAPPING: 3>
|
| COLUMN_SERIES_MAPPING = <DataFormat.COLUMN_SERIES_MAPPING: 4>
|
| COLUMN_VALUE_MAPPING = <DataFormat.COLUMN_VALUE_MAPPING: 5>
|
| DASK_OBJECT = <DataFormat.DASK_OBJECT: 6>
|
| DBAPI_CURSOR = <DataFormat.DBAPI_CURSOR: 7>
|
| DUCKDB_RELATION = <DataFormat.DUCKDB_RELATION: 8>
|
| EMPTY = <DataFormat.EMPTY: 2>
|
| KEY_VALUE_DICT = <DataFormat.KEY_VALUE_DICT: 9>
|
| LIST_OF_RECORDS = <DataFormat.LIST_OF_RECORDS: 10>
|
| LIST_OF_ROWS = <DataFormat.LIST_OF_ROWS: 11>
|
| LIST_OF_VALUES = <DataFormat.LIST_OF_VALUES: 12>
|
| MODIN_OBJECT = <DataFormat.MODIN_OBJECT: 13>
|
| NUMPY_LIST = <DataFormat.NUMPY_LIST: 14>
|
| NUMPY_MATRIX = <DataFormat.NUMPY_MATRIX: 15>
|
| PANDAS_ARRAY = <DataFormat.PANDAS_ARRAY: 16>
|
| PANDAS_DATAFRAME = <DataFormat.PANDAS_DATAFRAME: 17>
|
| PANDAS_INDEX = <DataFormat.PANDAS_INDEX: 18>
|
| PANDAS_SERIES = <DataFormat.PANDAS_SERIES: 19>
|
| PANDAS_STYLER = <DataFormat.PANDAS_STYLER: 20>
|
| POLARS_DATAFRAME = <DataFormat.POLARS_DATAFRAME: 21>
|
| POLARS_LAZYFRAME = <DataFormat.POLARS_LAZYFRAME: 22>
|
| POLARS_SERIES = <DataFormat.POLARS_SERIES: 23>
|
| PYARROW_ARRAY = <DataFormat.PYARROW_ARRAY: 24>
|
| PYARROW_TABLE = <DataFormat.PYARROW_TABLE: 25>
|
| PYSPARK_OBJECT = <DataFormat.PYSPARK_OBJECT: 26>
|
| SET_OF_VALUES = <DataFormat.SET_OF_VALUES: 27>
|
| SNOWPANDAS_OBJECT = <DataFormat.SNOWPANDAS_OBJECT: 28>
|
| SNOWPARK_OBJECT = <DataFormat.SNOWPARK_OBJECT: 29>
|
| TUPLE_OF_VALUES = <DataFormat.TUPLE_OF_VALUES: 30>
|
| UNKNOWN = <DataFormat.UNKNOWN: 1>
|
| XARRAY_DATASET = <DataFormat.XARRAY_DATASET: 31>
|
| XARRAY_DATA_ARRAY = <DataFormat.XARRAY_DATA_ARRAY: 32>
|
| ----------------------------------------------------------------------
| Data descriptors inherited from enum.Enum:
|
| name
| The name of the Enum member.
|
| value
| The value of the Enum member.
|
| ----------------------------------------------------------------------
| Static methods inherited from enum.EnumType:
|
| __contains__(value)
| Return True if `value` is in `cls`.
|
| `value` is in `cls` if:
| 1) `value` is a member of `cls`, or
| 2) `value` is the value of one of the `cls`'s members.
|
| __getitem__(name)
| Return the member matching `name`.
|
| __iter__()
| Return members in definition order.
|
| __len__()
| Return the number of members (no aliases)
|
| ----------------------------------------------------------------------
| Readonly properties inherited from enum.EnumType:
|
| __members__
| Returns a mapping of member name->value.
|
| This mapping lists all enum members, including aliases. Note that this
| is a read-only view of the internal mapping.
class DataFrameGenericAlias(typing.Protocol)
| DataFrameGenericAlias(*args, **kwargs)
|
| Technically not a GenericAlias, but serves the same purpose in
| OptionSequence below, in that it is a type which admits DataFrame,
| but is generic. This allows OptionSequence to be a fully generic type,
| significantly increasing its usefulness.
|
| We can't use types.GenericAlias, as it is only available from python>=3.9,
| and isn't easily back-ported.
|
| Method resolution order:
| DataFrameGenericAlias
| typing.Protocol
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__ = _no_init_or_replace_init(self, *args, **kwargs) from typing
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __subclasshook__ = _proto_hook(other) from typing
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| iloc
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __orig_bases__ = (typing.Protocol[+V_co],)
|
| __parameters__ = (+V_co,)
|
| __protocol_attrs__ = {'iloc'}
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Protocol:
|
| __init_subclass__(*args, **kwargs)
| Function to initialize subclasses.
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
class DataframeInterchangeCompatible(typing.Protocol)
| DataframeInterchangeCompatible(*args, **kwargs)
|
| Protocol for objects support the dataframe-interchange protocol.
|
| https://data-apis.org/dataframe-protocol/latest/index.html
|
| Method resolution order:
| DataframeInterchangeCompatible
| typing.Protocol
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __dataframe__(self, allow_copy: 'bool') -> 'Any'
|
| __init__ = _no_init_or_replace_init(self, *args, **kwargs) from typing
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __subclasshook__ = _proto_hook(other) from typing
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __parameters__ = ()
|
| __protocol_attrs__ = {'__dataframe__'}
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Protocol:
|
| __init_subclass__(*args, **kwargs)
| Function to initialize subclasses.
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
class PandasCompatible(typing.Protocol)
| PandasCompatible(*args, **kwargs)
|
| Protocol for Pandas compatible objects that have a `to_pandas` method.
|
| Method resolution order:
| PandasCompatible
| typing.Protocol
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__ = _no_init_or_replace_init(self, *args, **kwargs) from typing
|
| to_pandas(self) -> 'DataFrame | Series[Any]'
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __subclasshook__ = _proto_hook(other) from typing
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __parameters__ = ()
|
| __protocol_attrs__ = {'to_pandas'}
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Protocol:
|
| __init_subclass__(*args, **kwargs)
| Function to initialize subclasses.
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
FUNCTIONS
convert_anything_to_arrow_bytes(data: 'Any', max_unevaluated_rows: 'int' = 10000) -> 'bytes'
Try to convert different formats to Arrow IPC format (bytes).
This method tries to directly convert the input data to Arrow bytes
for some supported formats, but falls back to conversion to a Pandas
DataFrame and then to Arrow bytes.
Parameters
----------
data : dataframe-, array-, or collections-like object
The data to convert to Arrow bytes.
max_unevaluated_rows: int
If unevaluated data is detected this func will evaluate it,
taking max_unevaluated_rows, defaults to 10k.
Returns
-------
bytes
The serialized Arrow IPC bytes.
convert_anything_to_list(obj: 'OptionSequence[V_co]') -> 'list[V_co]'
Try to convert different formats to a list.
If the input is a dataframe-like object, we just select the first
column to iterate over. Non sequence-like objects and scalar types,
will just be wrapped into a list.
Parameters
----------
obj : dataframe-, array-, or collections-like object
The object to convert to a list.
Returns
-------
list
The converted list.
convert_anything_to_pandas_df(data: 'Any', max_unevaluated_rows: 'int' = 10000, ensure_copy: 'bool' = False) -> 'DataFrame'
Try to convert different formats to a Pandas Dataframe.
Parameters
----------
data : dataframe-, array-, or collections-like object
The data to convert to a Pandas DataFrame.
max_unevaluated_rows: int
If unevaluated data is detected this func will evaluate it,
taking max_unevaluated_rows, defaults to 10k.
ensure_copy: bool
If True, make sure to always return a copy of the data. If False, it depends on
the type of the data. For example, a Pandas DataFrame will be returned as-is.
Returns
-------
pandas.DataFrame
convert_arrow_bytes_to_pandas_df(source: 'bytes') -> 'DataFrame'
Convert Arrow bytes (IPC format) to pandas.DataFrame.
Using this function in production needs to make sure that
the pyarrow version >= 14.0.1, because of a critical
security vulnerability in pyarrow < 14.0.1.
Parameters
----------
source : bytes
A bytes object to convert.
Returns
-------
pandas.DataFrame
The converted dataframe.
convert_arrow_table_to_arrow_bytes(table: 'pa.Table') -> 'bytes'
Serialize pyarrow.Table to Arrow IPC bytes.
Parameters
----------
table : pyarrow.Table
A table to convert.
Returns
-------
bytes
The serialized Arrow IPC bytes.
convert_pandas_df_to_arrow_bytes(df: 'DataFrame', *, downcast_large_types: 'bool' = False) -> 'bytes'
Serialize pandas.DataFrame to Arrow IPC bytes.
Parameters
----------
df : pandas.DataFrame
A dataframe to convert.
downcast_large_types : bool
If ``True``, downcast ``large_string``, ``large_binary``, and
``large_list`` Arrow types to their standard-width counterparts
before serializing. This is needed for consumers that bundle older
Arrow libraries which cannot decode the large type codes
(e.g. custom components v1).
Returns
-------
bytes
The serialized Arrow IPC bytes.
convert_pandas_df_to_data_format(df: 'DataFrame', data_format: 'DataFormat') -> 'DataFrame | Series[Any] | pa.Table | pa.Array | np.ndarray[Any, np.dtype[Any]] | tuple[Any] | list[Any] | set[Any] | dict[str, Any]'
Convert a Pandas DataFrame to the specified data format.
Parameters
----------
df : pd.DataFrame
The dataframe to convert.
data_format : DataFormat
The data format to convert to.
Returns
-------
pd.DataFrame, pd.Series, pyarrow.Table, np.ndarray, xarray.Dataset,
xarray.DataArray, polars.Dataframe, polars.Series, list, set, tuple, or dict.
The converted dataframe.
determine_arrow_column_fix(column: 'Series[Any] | Index[Any]') -> "Literal['string', 'list'] | None"
Determine the fix needed for Arrow compatibility.
Returns the conversion type needed for Arrow compatibility:
- "string": convert column values to strings
- "list": convert iterable values (e.g., frozensets, ExtensionArrays) to lists
- None: column is already Arrow-compatible
determine_data_format(input_data: 'Any') -> 'DataFormat'
Determine the data format of the input data.
Parameters
----------
input_data : Any
The input data to determine the data format of.
Returns
-------
DataFormat
The data format of the input data.
fix_arrow_incompatible_column_types(df: 'DataFrame', selected_columns: 'list[str] | None' = None) -> 'DataFrame'
Fix column types that are not supported by Arrow table.
This includes mixed types (e.g. mix of integers and strings)
as well as complex numbers (complex128 type). These types will cause
errors during conversion of the dataframe to an Arrow table.
It is fixed by converting column values to strings or lists as appropriate.
This is sufficient for displaying the data on the frontend.
Parameters
----------
df : pandas.DataFrame
A dataframe to fix.
selected_columns: List[str] or None
A list of columns to fix. If None, all columns are evaluated.
Returns
-------
The fixed dataframe.
has_range_index(df: 'DataFrame') -> 'bool'
True if the dataframe has a range index.
is_dask_object(obj: 'object') -> 'bool'
True if obj is a Dask DataFrame, Series, or Index.
is_dataframe_like(obj: 'object') -> 'bool'
True if the object is a dataframe-like object.
This does not include basic collection types like list, dict, tuple, etc.
is_dbapi_cursor(obj: 'object') -> 'TypeGuard[DBAPICursor]'
True if obj looks like a DB API 2.0 Cursor.
https://peps.python.org/pep-0249/
is_duckdb_relation(obj: 'object') -> 'bool'
True if obj is a DuckDB relation.
https://duckdb.org/docs/api/python/relational_api
is_modin_data_object(obj: 'object') -> 'bool'
True if obj is of Modin Dataframe or Series.
is_pandas_data_object(obj: 'object') -> 'bool'
True if obj is a Pandas object (e.g. DataFrame, Series, Index, Styler, ...).
is_pandas_styler(obj: 'object') -> 'TypeGuard[Styler]'
True if obj is a pandas Styler.
is_pandas_version_less_than(v: 'str') -> 'bool'
Return True if the current Pandas version is less than the input version.
Parameters
----------
v : str
Version string, e.g. "0.25.0"
Returns
-------
bool
Raises
------
InvalidVersion
If the version strings are not valid.
is_polars_dataframe(obj: 'object') -> 'bool'
True if obj is a Polars Dataframe.
is_polars_lazyframe(obj: 'object') -> 'bool'
True if obj is a Polars Lazyframe.
is_polars_series(obj: 'object') -> 'bool'
True if obj is a Polars Series.
is_pyarrow_version_less_than(v: 'str') -> 'bool'
Return True if the current Pyarrow version is less than the input version.
Parameters
----------
v : str
Version string, e.g. "0.25.0"
Returns
-------
bool
Raises
------
InvalidVersion
If the version strings are not valid.
is_pyspark_data_object(obj: 'object') -> 'bool'
True if obj is a PySpark or PySpark Connect dataframe.
is_snowpandas_data_object(obj: 'object') -> 'bool'
True if obj is a Snowpark Pandas DataFrame or Series.
is_snowpark_data_object(obj: 'object') -> 'bool'
True if obj is a Snowpark DataFrame or Table.
is_snowpark_row_list(obj: 'object') -> 'bool'
True if obj is a list of snowflake.snowpark.row.Row.
is_unevaluated_data_object(obj: 'object') -> 'bool'
True if the object is one of the supported unevaluated data objects.
Currently supported objects are:
- Snowpark DataFrame / Table
- PySpark DataFrame
- Modin DataFrame / Series
- Snowpandas DataFrame / Series / Index
- Dask DataFrame / Series / Index
- Polars LazyFrame
- Generator functions
- DB API 2.0 Cursor (PEP 249)
- DuckDB Relation (Relational API)
Unevaluated means that the data is not yet in the local memory.
Unevaluated data objects are treated differently from other data objects by only
requesting a subset of the data instead of loading all data into th memory
is_xarray_data_array(obj: 'object') -> 'bool'
True if obj is a Xarray DataArray.
is_xarray_dataset(obj: 'object') -> 'bool'
True if obj is a Xarray Dataset.
DATA
Data = typing.Union[ForwardRef('DataFrame'), ForwardRef...rtable, stre...
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
Literal = typing.Literal
Special typing form to define literal types (a.k.a. value types).
This form can be used to indicate to type checkers that the corresponding
variable or function parameter has a value equivalent to the provided
literal (or one of several literals)::
def validate_simple(data: Any) -> Literal[True]: # always returns True
...
MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
...
open_helper('/some/path', 'r') # Passes type check
open_helper('/other/path', 'typo') # Error in type checker
Literal[...] cannot be subclassed. At runtime, an arbitrary value
is allowed as type argument to Literal[...], but type checkers may
impose restrictions.
OptionSequence = typing.Union[collections.abc.Iterable[+V_co], st..., ...
TYPE_CHECKING = False
TypeAlias = typing.TypeAlias
Special form for marking type aliases.
Use TypeAlias to indicate that an assignment should
be recognized as a proper type alias definition by type
checkers.
For example::
Predicate: TypeAlias = Callable[..., bool]
It's invalid when used anywhere except as in the example above.
TypeGuard = typing.TypeGuard
Special typing construct for marking user-defined type guard functions.
``TypeGuard`` can be used to annotate the return type of a user-defined
type guard function. ``TypeGuard`` only accepts a single type argument.
At runtime, functions marked this way should return a boolean.
``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static
type checkers to determine a more precise type of an expression within a
program's code flow. Usually type narrowing is done by analyzing
conditional code flow and applying the narrowing to a block of code. The
conditional expression here is sometimes referred to as a "type guard".
Sometimes it would be convenient to use a user-defined boolean function
as a type guard. Such a function should use ``TypeGuard[...]`` as its
return type to alert static type checkers to this intention.
Using ``-> TypeGuard`` tells the static type checker that for a given
function:
1. The return value is a boolean.
2. If the return value is ``True``, the type of its argument
is the type inside ``TypeGuard``.
For example::
def is_str_list(val: list[object]) -> TypeGuard[list[str]]:
'''Determines whether all objects in the list are strings'''
return all(isinstance(x, str) for x in val)
def func1(val: list[object]):
if is_str_list(val):
# Type of ``val`` is narrowed to ``list[str]``.
print(" ".join(val))
else:
# Type of ``val`` remains as ``list[object]``.
print("Not a list of strings!")
Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower
form of ``TypeA`` (it can even be a wider form) and this may lead to
type-unsafe results. The main reason is to allow for things like
narrowing ``list[object]`` to ``list[str]`` even though the latter is not
a subtype of the former, since ``list`` is invariant. The responsibility of
writing type-safe type guards is left to the user.
``TypeGuard`` also works with type variables. For more information, see
PEP 647 (User-Defined Type Guards).
Union = typing.Union
Union type; Union[X, Y] means either X or Y.
On Python 3.10 and higher, the | operator
can also be used to denote unions;
X | Y means the same thing to the type checker as Union[X, Y].
To define a union, use e.g. Union[int, str]. Details:
- The arguments must be types and there must be at least one.
- None as an argument is a special case and is replaced by
type(None).
- Unions of unions are flattened, e.g.::
assert Union[Union[int, str], float] == Union[int, str, float]
- Unions of a single argument vanish, e.g.::
assert Union[int] == int # The constructor actually returns int
- Redundant arguments are skipped, e.g.::
assert Union[int, str, int] == Union[int, str]
- When comparing unions, the argument order is ignored, e.g.::
assert Union[int, str] == Union[str, int]
- You cannot subclass or instantiate a union.
- You can use Optional[X] as a shorthand for Union[X, None].
V_co = +V_co
__annotations__ = {'Data': 'TypeAlias', 'OptionSequence': 'TypeAlias',...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\dataframe_util.py
streamlit.date_input
Python Library Documentation: method date_input in module streamlit.delta_generator
date_input(label: 'str', value: 'DateValue' = 'today', min_value: 'NullableScalarDateValue' = None, max_value: 'NullableScalarDateValue' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, format: 'str' = 'YYYY/MM/DD', disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'DateWidgetReturn' method of streamlit.delta_generator.DeltaGenerator instance
Display a date input widget.
The date input widget can be configured to accept a single date or a
date range. The first day of the week is determined from the user's
locale in their browser.
Parameters
----------
label : str
A short label explaining to the user what this date input is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
value : "today", datetime.date, datetime.datetime, str, list/tuple of these, or None
The value of this widget when it first renders. This can be one of
the following:
- ``"today"`` (default): The widget initializes with the current date.
- A ``datetime.date`` or ``datetime.datetime`` object: The widget
initializes with the given date, ignoring any time if included.
- An ISO-formatted date (YYYY-MM-DD) or datetime
(YYYY-MM-DD hh:mm:ss) string: The widget initializes with the
given date, ignoring any time if included.
- A list or tuple with up to two of the above: The widget will
initialize with the given date interval and return a tuple of the
selected interval. You can pass an empty list to initialize the
widget with an empty interval or a list with one value to
initialize only the beginning date of the iterval.
- ``None``: The widget initializes with no date and returns
``None`` until the user selects a date.
min_value : "today", datetime.date, datetime.datetime, str, or None
The minimum selectable date. This can be any of the date types
accepted by ``value``, except list or tuple.
If this is ``None`` (default), the minimum selectable date is ten
years before the initial value. If the initial value is an
interval, the minimum selectable date is ten years before the start
date of the interval. If no initial value is set, the minimum
selectable date is ten years before today.
max_value : "today", datetime.date, datetime.datetime, str, or None
The maximum selectable date. This can be any of the date types
accepted by ``value``, except list or tuple.
If this is ``None`` (default), the maximum selectable date is ten
years after the initial value. If the initial value is an interval,
the maximum selectable date is ten years after the end date of the
interval. If no initial value is set, the maximum selectable date
is ten years after today.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``format`` resets the widget even when a key is
provided.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this date_input's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
format : str
A format string controlling how the interface should display dates.
Supports ``"YYYY/MM/DD"`` (default), ``"DD/MM/YYYY"``, or ``"MM/DD/YYYY"``.
You may also use a period (.) or hyphen (-) as separators.
disabled : bool
An optional boolean that disables the date input if set to
``True``. The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "stretch" or int
The width of the date input widget. This can be one of the following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Dates use ISO 8601 format (YYYY-MM-DD) in the URL. Invalid
query parameter values are ignored and removed from the URL.
If ``value`` is ``None``, an empty query parameter (e.g.,
``?vacation=``) clears the widget. Date ranges use repeated
parameters (e.g.,
``?vacation=2025-01-01&vacation=2025-01-31``).
Returns
-------
datetime.date or a tuple with 0-2 dates or None
The current value of the date input widget or ``None`` if no date has been
selected.
Examples
--------
**Example 1: Basic usage**
>>> import datetime
>>> import streamlit as st
>>>
>>> d = st.date_input("When's your birthday", datetime.date(2019, 7, 6))
>>> st.write("Your birthday is:", d)
.. output::
https://doc-date-input.streamlit.app/
height: 380px
**Example 2: Date range**
>>> import datetime
>>> import streamlit as st
>>>
>>> today = datetime.datetime.now()
>>> next_year = today.year + 1
>>> jan_1 = datetime.date(next_year, 1, 1)
>>> dec_31 = datetime.date(next_year, 12, 31)
>>>
>>> d = st.date_input(
... "Select your vacation for next year",
... (jan_1, datetime.date(next_year, 1, 7)),
... jan_1,
... dec_31,
... format="MM.DD.YYYY",
... )
>>> d
.. output::
https://doc-date-input1.streamlit.app/
height: 380px
**Example 3: Empty initial value**
To initialize an empty date input, use ``None`` as the value:
>>> import datetime
>>> import streamlit as st
>>>
>>> d = st.date_input("When's your birthday", value=None)
>>> st.write("Your birthday is:", d)
.. output::
https://doc-date-input-empty.streamlit.app/
height: 380px
streamlit.datetime_input
Python Library Documentation: method datetime_input in module streamlit.delta_generator
datetime_input(label: 'str', value: 'DateTimeValue' = 'now', min_value: 'DateTimeValue' = None, max_value: 'DateTimeValue' = None, *, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, format: 'str' = 'YYYY/MM/DD', step: 'int | timedelta' = datetime.timedelta(seconds=900), disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'datetime | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a date and time input widget.
Parameters
----------
label : str
A short label explaining to the user what this datetime input is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
value : "now", datetime.datetime, datetime.date, datetime.time, str, or None
The value of this widget when it first renders. This can be one of
the following:
- ``"now"`` (default): The widget initializes with the current date and time.
- A ``datetime.datetime`` object: The widget initializes with the given
datetime, stripping any timezone information.
- A ``datetime.date`` object: The widget initializes with the given date
at 00:00.
- A ``datetime.time`` object: The widget initializes with today's date
and the provided time.
- An ISO-formatted datetime (YYYY-MM-DD hh:mm[:ss]) or date/time
string: The widget initializes with the parsed value.
- ``None``: The widget initializes with no value and returns ``None``
until the user selects a datetime.
min_value : "now", datetime.datetime, datetime.date, datetime.time, str, or None
The minimum selectable datetime. This can be any of the datetime
types accepted by ``value``.
If this is ``None`` (default), the minimum selectable datetime is
ten years before the initial value. If no initial value is set, the
minimum selectable datetime is ten years before today at 00:00.
max_value : "now", datetime.datetime, datetime.date, datetime.time, str, or None
The maximum selectable datetime. This can be any of the datetime
types accepted by ``value``.
If this is ``None`` (default), the maximum selectable datetime is
ten years after the initial value. If no initial value is set, the
maximum selectable datetime is ten years after today at 23:59.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``format`` or ``step`` resets the widget even
when a key is provided.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this datetime_input's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
format : str
A format string controlling how the interface displays dates.
Supports ``"YYYY/MM/DD"`` (default), ``"DD/MM/YYYY"``, or ``"MM/DD/YYYY"``.
You may also use a period (.) or hyphen (-) as separators. This
doesn't affect the time format.
step : int or timedelta
The stepping interval in seconds. This defaults to ``900`` (15
minutes). You can also pass a ``datetime.timedelta`` object. The
value must be between 60 seconds and 23 hours.
disabled : bool
An optional boolean that disables the widget if set to ``True``.
The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "stretch" or int
The width of the widget. This can be one of the following:
- ``"stretch"`` (default): The width of the widget matches the width
of the parent container.
- An integer specifying the width in pixels: The widget has a fixed
width. If the specified width is greater than the width of the
parent container, the widget matches the container width.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Datetimes use ISO 8601 format (YYYY-MM-DDThh:mm) in the URL.
Invalid query parameter values are ignored and removed from
the URL. If ``value`` is ``None``, an empty query parameter
(e.g., ``?my_key=``) clears the widget.
Returns
-------
datetime.datetime or None
The current value of the datetime input widget (without timezone)
or ``None`` if no value has been selected.
Examples
--------
**Example 1: Basic usage**
>>> import datetime
>>> import streamlit as st
>>>
>>> event_time = st.datetime_input(
... "Schedule your event",
... datetime.datetime(2025, 11, 19, 16, 45),
... )
>>> st.write("Event scheduled for", event_time)
.. output::
https://doc-datetime-input.streamlit.app/
height: 500px
**Example 2: Empty initial value**
To initialize an empty datetime input, use ``None`` as the value:
>>> import datetime
>>> import streamlit as st
>>>
>>> event_time = st.datetime_input("Schedule your event", value=None)
>>> st.write("Event scheduled for", event_time)
.. output::
https://doc-datetime-input-empty.streamlit.app/
height: 500px
streamlit.delta_generator
Python Library Documentation: module streamlit.delta_generator in streamlit
NAME
streamlit.delta_generator - Allows us to create and absorb changes (aka Deltas) to elements.
CLASSES
streamlit.components.v2.bidi_component.main.BidiComponentMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.alert.AlertMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.arrow.ArrowMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.balloons.BalloonsMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.bokeh_chart.BokehMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.code.CodeMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.deck_gl_json_chart.PydeckMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.empty.EmptyMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.exception.ExceptionMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.form.FormMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.graphviz_chart.GraphvizMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.heading.HeadingMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.help.HelpMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.html.HtmlMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.iframe.IframeMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.image.ImageMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.json.JsonMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.layouts.LayoutsMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.map.MapMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.markdown.MarkdownMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.media.MediaMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.metric.MetricMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.pdf.PdfMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.plotly_chart.PlotlyMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.progress.ProgressMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.pyplot.PyplotMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.snow.SnowMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.space.SpaceMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.spinner.SpinnerMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.table.TableMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.text.TextMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.toast.ToastMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.vega_charts.VegaChartsMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.audio_input.AudioInputMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.button.ButtonMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.button_group.ButtonGroupMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.camera_input.CameraInputMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.chat.ChatMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.checkbox.CheckboxMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.color_picker.ColorPickerMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.data_editor.DataEditorMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.feedback.FeedbackMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.file_uploader.FileUploaderMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.menu_button.MenuButtonMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.multiselect.MultiSelectMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.number_input.NumberInputMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.radio.RadioMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.select_slider.SelectSliderMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.selectbox.SelectboxMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.slider.SliderMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.text_widgets.TextWidgetsMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.widgets.time_widgets.TimeWidgetsMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
streamlit.elements.write.WriteMixin(builtins.object)
DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
class DeltaGenerator(streamlit.elements.alert.AlertMixin, streamlit.elements.widgets.audio_input.AudioInputMixin, streamlit.elements.balloons.BalloonsMixin, streamlit.elements.bokeh_chart.BokehMixin, streamlit.elements.widgets.button.ButtonMixin, streamlit.elements.widgets.button_group.ButtonGroupMixin, streamlit.elements.widgets.camera_input.CameraInputMixin, streamlit.elements.widgets.chat.ChatMixin, streamlit.elements.widgets.checkbox.CheckboxMixin, streamlit.elements.code.CodeMixin, streamlit.elements.widgets.color_picker.ColorPickerMixin, streamlit.elements.empty.EmptyMixin, streamlit.elements.exception.ExceptionMixin, streamlit.elements.widgets.feedback.FeedbackMixin, streamlit.elements.widgets.file_uploader.FileUploaderMixin, streamlit.elements.form.FormMixin, streamlit.elements.graphviz_chart.GraphvizMixin, streamlit.elements.heading.HeadingMixin, streamlit.elements.help.HelpMixin, streamlit.elements.html.HtmlMixin, streamlit.elements.iframe.IframeMixin, streamlit.elements.image.ImageMixin, streamlit.elements.layouts.LayoutsMixin, streamlit.elements.markdown.MarkdownMixin, streamlit.elements.map.MapMixin, streamlit.elements.media.MediaMixin, streamlit.elements.metric.MetricMixin, streamlit.elements.widgets.menu_button.MenuButtonMixin, streamlit.elements.widgets.multiselect.MultiSelectMixin, streamlit.elements.widgets.number_input.NumberInputMixin, streamlit.elements.pdf.PdfMixin, streamlit.elements.plotly_chart.PlotlyMixin, streamlit.elements.progress.ProgressMixin, streamlit.elements.deck_gl_json_chart.PydeckMixin, streamlit.elements.pyplot.PyplotMixin, streamlit.elements.widgets.radio.RadioMixin, streamlit.elements.widgets.selectbox.SelectboxMixin, streamlit.elements.widgets.select_slider.SelectSliderMixin, streamlit.elements.widgets.slider.SliderMixin, streamlit.elements.snow.SnowMixin, streamlit.elements.space.SpaceMixin, streamlit.elements.spinner.SpinnerMixin, streamlit.elements.table.TableMixin, streamlit.elements.json.JsonMixin, streamlit.elements.text.TextMixin, streamlit.elements.widgets.text_widgets.TextWidgetsMixin, streamlit.elements.widgets.time_widgets.TimeWidgetsMixin, streamlit.elements.toast.ToastMixin, streamlit.elements.write.WriteMixin, streamlit.elements.arrow.ArrowMixin, streamlit.elements.vega_charts.VegaChartsMixin, streamlit.elements.widgets.data_editor.DataEditorMixin, streamlit.components.v2.bidi_component.main.BidiComponentMixin)
| DeltaGenerator(root_container: 'int | None' = 0, cursor: 'Cursor | None' = None, parent: 'DeltaGenerator | None' = None, block_type: 'str | None' = None) -> 'None'
|
| Creator of Delta protobuf messages.
|
| Parameters
| ----------
| root_container: BlockPath_pb2.BlockPath.ContainerValue or None
| The root container for this DeltaGenerator. If None, this is a null
| DeltaGenerator which doesn't print to the app at all (useful for
| testing).
|
| cursor: cursor.Cursor or None
| This is either:
| - None: if this is the running DeltaGenerator for a top-level
| container (MAIN or SIDEBAR)
| - RunningCursor: if this is the running DeltaGenerator for a
| non-top-level container (created with dg.container())
| - LockedCursor: if this is a locked DeltaGenerator returned by some
| other DeltaGenerator method. E.g. the dg returned in dg =
| st.text("foo").
|
| parent: DeltaGenerator
| To support the `with dg` notation, DGs are arranged as a tree. Each DG
| remembers its own parent, and the root of the tree is the main DG.
|
| block_type: None or "vertical" or "horizontal" or "column" or "expandable"
| If this is a block DG, we track its type to prevent nested columns/expanders
|
| Method resolution order:
| DeltaGenerator
| streamlit.elements.alert.AlertMixin
| streamlit.elements.widgets.audio_input.AudioInputMixin
| streamlit.elements.balloons.BalloonsMixin
| streamlit.elements.bokeh_chart.BokehMixin
| streamlit.elements.widgets.button.ButtonMixin
| streamlit.elements.widgets.button_group.ButtonGroupMixin
| streamlit.elements.widgets.camera_input.CameraInputMixin
| streamlit.elements.widgets.chat.ChatMixin
| streamlit.elements.widgets.checkbox.CheckboxMixin
| streamlit.elements.code.CodeMixin
| streamlit.elements.widgets.color_picker.ColorPickerMixin
| streamlit.elements.empty.EmptyMixin
| streamlit.elements.exception.ExceptionMixin
| streamlit.elements.widgets.feedback.FeedbackMixin
| streamlit.elements.widgets.file_uploader.FileUploaderMixin
| streamlit.elements.form.FormMixin
| streamlit.elements.graphviz_chart.GraphvizMixin
| streamlit.elements.heading.HeadingMixin
| streamlit.elements.help.HelpMixin
| streamlit.elements.html.HtmlMixin
| streamlit.elements.iframe.IframeMixin
| streamlit.elements.image.ImageMixin
| streamlit.elements.layouts.LayoutsMixin
| streamlit.elements.markdown.MarkdownMixin
| streamlit.elements.map.MapMixin
| streamlit.elements.media.MediaMixin
| streamlit.elements.metric.MetricMixin
| streamlit.elements.widgets.menu_button.MenuButtonMixin
| streamlit.elements.widgets.multiselect.MultiSelectMixin
| streamlit.elements.widgets.number_input.NumberInputMixin
| streamlit.elements.pdf.PdfMixin
| streamlit.elements.plotly_chart.PlotlyMixin
| streamlit.elements.progress.ProgressMixin
| streamlit.elements.deck_gl_json_chart.PydeckMixin
| streamlit.elements.pyplot.PyplotMixin
| streamlit.elements.widgets.radio.RadioMixin
| streamlit.elements.widgets.selectbox.SelectboxMixin
| streamlit.elements.widgets.select_slider.SelectSliderMixin
| streamlit.elements.widgets.slider.SliderMixin
| streamlit.elements.snow.SnowMixin
| streamlit.elements.space.SpaceMixin
| streamlit.elements.spinner.SpinnerMixin
| streamlit.elements.table.TableMixin
| streamlit.elements.json.JsonMixin
| streamlit.elements.text.TextMixin
| streamlit.elements.widgets.text_widgets.TextWidgetsMixin
| streamlit.elements.widgets.time_widgets.TimeWidgetsMixin
| streamlit.elements.toast.ToastMixin
| streamlit.elements.write.WriteMixin
| streamlit.elements.arrow.ArrowMixin
| streamlit.elements.vega_charts.VegaChartsMixin
| streamlit.elements.widgets.data_editor.DataEditorMixin
| streamlit.components.v2.bidi_component.main.BidiComponentMixin
| builtins.object
|
| Methods defined here:
|
| __deepcopy__(self, _memo: 'Any') -> 'DeltaGenerator'
|
| __enter__(self) -> 'None'
|
| __exit__(self, typ: 'type[BaseException] | None', exc: 'BaseException | None', tb: 'TracebackType | None') -> 'Literal[False]'
|
| __getattr__(self, name: 'str') -> 'Callable[..., NoReturn]'
|
| __init__(self, root_container: 'int | None' = 0, cursor: 'Cursor | None' = None, parent: 'DeltaGenerator | None' = None, block_type: 'str | None' = None) -> 'None'
| Inserts or updates elements in Streamlit apps.
|
| As a user, you should never initialize this object by hand. Instead,
| DeltaGenerator objects are initialized for you in two places:
|
| 1) When you call `dg = st.foo()` for some method "foo", sometimes `dg`
| is a DeltaGenerator object. You can call methods on the `dg` object to
| update the element `foo` that appears in the Streamlit app.
|
| 2) This is an internal detail, but `st.sidebar` itself is a
| DeltaGenerator. That's why you can call `st.sidebar.foo()` to place
| an element `foo` inside the sidebar.
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.alert.AlertMixin:
|
| error(self, body: 'SupportsStr', *, icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', title: 'SupportsStr | None' = None) -> 'DeltaGenerator' from AlertMixin
| Display error message.
|
| Parameters
| ----------
| body : str
| The text to display as GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| If ``icon`` is ``None``, and ``body`` begins with an emoji or
| Material icon shortcode, Streamlit will extract it and display it
| slightly enlarged, as if it were passed to ``icon``. If ``body``
| contains multiple icons, or you want to override this behavior,
| you can insert a null Markdown directive like ``:red[]`` before
| your leading icon.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| icon : str or None
| An optional emoji or icon to display next to the alert. If ``icon``
| is ``None`` (default), Streamlit attempts to extract a leading
| emoji or Material icon shortcode from ``body``. If found, the icon
| is displayed and removed from the body text. If no leading icon is
| found, no icon is displayed. If ``icon`` is a string, it takes
| precedence over any icon in the body, and the following options
| are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| width : "stretch" or int
| The width of the alert element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| title : str or None
| An optional title to display above the body text. If ``None``
| (default), no title is displayed. The title is rendered with bold
| styling and can optionally contain GitHub-flavored Markdown of the
| following types: Italics, Strikethroughs, Inline Code, Links, and
| Images. Images display like icons, with a max height equal to the
| font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Display elements are not supported.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.error('This is an error', icon="🚨")
|
| info(self, body: 'SupportsStr', *, icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', title: 'SupportsStr | None' = None) -> 'DeltaGenerator' from AlertMixin
| Display an informational message.
|
| Parameters
| ----------
| body : str
| The text to display as GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| If ``icon`` is ``None``, and ``body`` begins with an emoji or
| Material icon shortcode, Streamlit will extract it and display it
| slightly enlarged, as if it were passed to ``icon``. If ``body``
| contains multiple icons, or you want to override this behavior,
| you can insert a null Markdown directive like ``:red[]`` before
| your leading icon.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| icon : str or None
| An optional emoji or icon to display next to the alert. If ``icon``
| is ``None`` (default), Streamlit attempts to extract a leading
| emoji or Material icon shortcode from ``body``. If found, the icon
| is displayed and removed from the body text. If no leading icon is
| found, no icon is displayed. If ``icon`` is a string, it takes
| precedence over any icon in the body, and the following options
| are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| width : "stretch" or int
| The width of the info element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| title : str or None
| An optional title to display above the body text. If ``None``
| (default), no title is displayed. The title is rendered with bold
| styling and can optionally contain GitHub-flavored Markdown of the
| following types: Italics, Strikethroughs, Inline Code, Links, and
| Images. Images display like icons, with a max height equal to the
| font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Display elements are not supported.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.info('This is a purely informational message', icon="ℹ️")
|
| success(self, body: 'SupportsStr', *, icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', title: 'SupportsStr | None' = None) -> 'DeltaGenerator' from AlertMixin
| Display a success message.
|
| Parameters
| ----------
| body : str
| The text to display as GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| If ``icon`` is ``None``, and ``body`` begins with an emoji or
| Material icon shortcode, Streamlit will extract it and display it
| slightly enlarged, as if it were passed to ``icon``. If ``body``
| contains multiple icons, or you want to override this behavior,
| you can insert a null Markdown directive like ``:red[]`` before
| your leading icon.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| icon : str or None
| An optional emoji or icon to display next to the alert. If ``icon``
| is ``None`` (default), Streamlit attempts to extract a leading
| emoji or Material icon shortcode from ``body``. If found, the icon
| is displayed and removed from the body text. If no leading icon is
| found, no icon is displayed. If ``icon`` is a string, it takes
| precedence over any icon in the body, and the following options
| are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| width : "stretch" or int
| The width of the success element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| title : str or None
| An optional title to display above the body text. If ``None``
| (default), no title is displayed. The title is rendered with bold
| styling and can optionally contain GitHub-flavored Markdown of the
| following types: Italics, Strikethroughs, Inline Code, Links, and
| Images. Images display like icons, with a max height equal to the
| font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Display elements are not supported.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.success('This is a success message!', icon="✅")
|
| warning(self, body: 'SupportsStr', *, icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', title: 'SupportsStr | None' = None) -> 'DeltaGenerator' from AlertMixin
| Display warning message.
|
| Parameters
| ----------
| body : str
| The text to display as GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| If ``icon`` is ``None``, and ``body`` begins with an emoji or
| Material icon shortcode, Streamlit will extract it and display it
| slightly enlarged, as if it were passed to ``icon``. If ``body``
| contains multiple icons, or you want to override this behavior,
| you can insert a null Markdown directive like ``:red[]`` before
| your leading icon.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| icon : str or None
| An optional emoji or icon to display next to the alert. If ``icon``
| is ``None`` (default), Streamlit attempts to extract a leading
| emoji or Material icon shortcode from ``body``. If found, the icon
| is displayed and removed from the body text. If no leading icon is
| found, no icon is displayed. If ``icon`` is a string, it takes
| precedence over any icon in the body, and the following options
| are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| width : "stretch" or int
| The width of the warning element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| title : str or None
| An optional title to display above the body text. If ``None``
| (default), no title is displayed. The title is rendered with bold
| styling and can optionally contain GitHub-flavored Markdown of the
| following types: Italics, Strikethroughs, Inline Code, Links, and
| Images. Images display like icons, with a max height equal to the
| font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Display elements are not supported.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.warning('This is a warning', icon="⚠️")
|
| ----------------------------------------------------------------------
| Readonly properties inherited from streamlit.elements.alert.AlertMixin:
|
| dg
| Get our DeltaGenerator.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from streamlit.elements.alert.AlertMixin:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.audio_input.AudioInputMixin:
|
| audio_input(self, label: 'str', *, sample_rate: 'int | None' = 16000, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch') -> 'UploadedFile | None' from AudioInputMixin
| Display a widget that returns an audio recording from the user's microphone.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this widget is used for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| sample_rate : int or None
| The target sample rate for the audio recording in Hz. This
| defaults to ``16000``, which is optimal for speech recognition.
|
| The following values are supported: ``8000`` (telephone quality),
| ``11025``, ``16000`` (speech-recognition quality), ``22050``,
| ``24000``, ``32000``, ``44100``, ``48000`` (high-quality), or
| ``None``. If this is ``None``, the widget uses the browser's
| default sample rate (typically 44100 or 48000 Hz).
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you access the widget's value via
| ``st.session_state[key]`` (read-only). For more details, see
| `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this audio input's value
| changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the audio input if set to
| ``True``. Default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "stretch" or int
| The width of the audio input widget. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| Returns
| -------
| None or UploadedFile
| The ``UploadedFile`` class is a subclass of ``BytesIO``, and
| therefore is "file-like". This means you can pass an instance of it
| anywhere a file is expected. The MIME type for the audio data is
| ``audio/wav``.
|
| .. Note::
| The resulting ``UploadedFile`` is subject to the size
| limitation configured in ``server.maxUploadSize``. If you
| expect large sound files, update the configuration option
| appropriately.
|
| Examples
| --------
| *Example 1:* Record a voice message and play it back.*
|
| The default sample rate of 16000 Hz is optimal for speech recognition.
|
| >>> import streamlit as st
| >>>
| >>> audio_value = st.audio_input("Record a voice message")
| >>>
| >>> if audio_value:
| ... st.audio(audio_value)
|
| .. output::
| https://doc-audio-input.streamlit.app/
| height: 260px
|
| *Example 2:* Record high-fidelity audio and play it back.*
|
| Higher sample rates can create higher-quality, larger audio files. This
| might require a nicer microphone to fully appreciate the difference.
|
| >>> import streamlit as st
| >>>
| >>> audio_value = st.audio_input("Record high quality audio", sample_rate=48000)
| >>>
| >>> if audio_value:
| ... st.audio(audio_value)
|
| .. output::
| https://doc-audio-input-high-rate.streamlit.app/
| height: 260px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.balloons.BalloonsMixin:
|
| balloons(self) -> 'DeltaGenerator' from BalloonsMixin
| Draw celebratory balloons.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.balloons()
|
| ...then watch your app and get ready for a celebration!
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.bokeh_chart.BokehMixin:
|
| bokeh_chart(self, figure: 'object', use_container_width: 'bool' = True) -> 'DeltaGenerator' from BokehMixin
| Display an interactive Bokeh chart.
|
| Bokeh is a charting library for Python. You can find
| more about Bokeh at https://bokeh.pydata.org.
|
| .. Important::
| This command has been deprecated and removed. Please use our custom
| component, |streamlit-bokeh|_, instead. Calling st.bokeh_chart will
| do nothing.
|
| .. |streamlit-bokeh| replace:: ``streamlit-bokeh``
| .. _streamlit-bokeh: https://github.com/streamlit/streamlit-bokeh
|
| Parameters
| ----------
| figure : bokeh.plotting.figure.Figure
| A Bokeh figure to plot.
|
| use_container_width : bool
| Whether to override the figure's native width with the width of
| the parent container. If ``use_container_width`` is ``True`` (default),
| Streamlit sets the width of the figure to match the width of the parent
| container. If ``use_container_width`` is ``False``, Streamlit sets the
| width of the chart to fit its contents according to the plotting library,
| up to the width of the parent container.
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.button.ButtonMixin:
|
| button(self, label: 'str', key: 'Key | None' = None, help: 'str | None' = None, on_click: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', icon: 'str | None' = None, icon_position: 'IconPosition' = 'left', disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', shortcut: 'str | None' = None) -> 'bool' from ButtonMixin
| Display a button widget.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this button is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you access the widget's value via
| ``st.session_state[key]`` (read-only). For more details, see
| `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed when the button is hovered over. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_click : callable
| An optional callback invoked when this button is clicked.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| type : "primary", "secondary", or "tertiary"
| An optional string that specifies the button type. This can be one
| of the following:
|
| - ``"primary"``: The button's background is the app's primary color
| for additional emphasis.
| - ``"secondary"`` (default): The button's background coordinates
| with the app's background color for normal emphasis.
| - ``"tertiary"``: The button is plain text without a border or
| background for subtlety.
|
| icon : str or None
| An optional emoji or icon to display next to the button label. If ``icon``
| is ``None`` (default), no icon is displayed. If ``icon`` is a
| string, the following options are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols \
| <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| icon_position : "left" or "right"
| The position of the icon relative to the button label. This
| defaults to ``"left"``.
|
| disabled : bool
| An optional boolean that disables the button if set to ``True``.
| The default is ``False``.
|
| use_container_width : bool
| Whether to expand the button's width to fill its parent container.
| If ``use_container_width`` is ``False`` (default), Streamlit sizes
| the button to fit its contents. If ``use_container_width`` is
| ``True``, the width of the button matches its parent container.
|
| In both cases, if the contents of the button are wider than the
| parent container, the contents will line wrap.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``. For ``use_container_width=False``, use
| ``width="content"``.
|
| width : "content", "stretch", or int
| The width of the button. This can be one of the following:
|
| - ``"content"`` (default): The width of the button matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the button matches the width of the
| parent container.
| - An integer specifying the width in pixels: The button has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the button matches the width
| of the parent container.
|
| shortcut : str or None
| An optional keyboard shortcut that triggers the button. This can be
| one of the following strings:
|
| - A single alphanumeric key like ``"K"`` or ``"4"``.
| - A function key like ``"F11"``.
| - A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
| - Any of the above combined with modifiers. For example, you can use
| ``"Ctrl+K"`` or ``"Cmd+Shift+O"``.
|
| .. important::
| The keys ``"C"`` and ``"R"`` are reserved and can't be used,
| even with modifiers. Punctuation keys like ``"."`` and ``","``
| aren't currently supported.
|
| The following special keys are supported: Backspace, Delete, Down,
| End, Enter, Esc, Home, Left, PageDown, PageUp, Right, Space, Tab,
| and Up.
|
| The following modifiers are supported: Alt, Ctrl, Cmd, Meta, Mod,
| Option, Shift.
|
| - Ctrl, Cmd, Meta, and Mod are interchangeable and will display to
| the user to match their platform.
| - Option and Alt are interchangeable and will display to the user
| to match their platform.
|
| Returns
| -------
| bool
| True if the button was clicked on the last run of the app,
| False otherwise.
|
| Examples
| --------
| **Example 1: Customize your button type**
|
| >>> import streamlit as st
| >>>
| >>> st.button("Reset", type="primary")
| >>> if st.button("Say hello"):
| ... st.write("Why hello there")
| ... else:
| ... st.write("Goodbye")
| >>>
| >>> if st.button("Aloha", type="tertiary"):
| ... st.write("Ciao")
|
| .. output::
| https://doc-buton.streamlit.app/
| height: 300px
|
| **Example 2: Add icons to your button**
|
| Although you can add icons to your buttons through Markdown, the
| ``icon`` parameter is a convenient and consistent alternative.
|
| >>> import streamlit as st
| >>>
| >>> left, middle, right = st.columns(3)
| >>> if left.button("Plain button", width="stretch"):
| ... left.markdown("You clicked the plain button.")
| >>> if middle.button("Emoji button", icon="😃", width="stretch"):
| ... middle.markdown("You clicked the emoji button.")
| >>> if right.button("Material button", icon=":material/mood:", width="stretch"):
| ... right.markdown("You clicked the Material button.")
|
| .. output::
| https://doc-button-icons.streamlit.app/
| height: 220px
|
| **Example 3: Use keyboard shortcuts**
|
| The following example shows how to use keyboard shortcuts to trigger a
| button. If you use any of the platform-dependent modifiers (Ctrl, Cmd,
| or Mod), they are interpreted interchangeably and always displayed to
| the user to match their platform.
|
| >>> import streamlit as st
| >>>
| >>> with st.container(horizontal=True, horizontal_alignment="distribute"):
| >>> "`A`" if st.button("A", shortcut="A") else "` `"
| >>> "`S`" if st.button("S", shortcut="Ctrl+S") else "` `"
| >>> "`D`" if st.button("D", shortcut="Cmd+Shift+D") else "` `"
| >>> "`F`" if st.button("F", shortcut="Mod+Alt+Shift+F") else "` `"
|
| .. output::
| https://doc-button-shortcuts.streamlit.app/
| height: 220px
|
| download_button(self, label: 'str', data: 'DownloadButtonDataType', file_name: 'str | None' = None, mime: 'str | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_click: "WidgetCallback | Literal['rerun', 'ignore'] | None" = 'rerun', args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', icon: 'str | None' = None, icon_position: 'IconPosition' = 'left', disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', shortcut: 'str | None' = None) -> 'bool' from ButtonMixin
| Display a download button widget.
|
| This is useful when you would like to provide a way for your users
| to download a file directly from your app.
|
| If you pass the data directly to the ``data`` parameter, then the data
| is stored in-memory while the user is connected. It's a good idea to
| keep file sizes under a couple hundred megabytes to conserve memory or
| use deferred data generation by passing a callable to the ``data``
| parameter.
|
| If you want to prevent your app from rerunning when a user clicks the
| download button, wrap the download button in a `fragment
| <https://docs.streamlit.io/develop/concepts/architecture/fragments>`_.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this button is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| data : str, bytes, file-like, or callable
| The contents of the file to be downloaded or a callable that
| returns the contents of the file.
|
| File contents can be a string, bytes, or file-like object.
| File-like objects include ``io.BytesIO``, ``io.StringIO``, or any
| class that implements the abstract base class ``io.RawIOBase``.
|
| If a callable is passed, it is executed when the user clicks
| the download button and runs on a separate thread from the
| resulting script rerun. This deferred generation is helpful for
| large files to avoid blocking the page script. The callable can't
| accept any arguments. If any Streamlit commands are executed inside
| the callable, they will be ignored.
|
| To prevent unnecessary recomputation, use caching when converting
| your data for download. For more information, see the Example 1
| below.
|
| file_name: str
| An optional string to use as the name of the file to be downloaded,
| such as ``"my_file.csv"``. If not specified, the name will be
| automatically generated.
|
| mime : str or None
| The MIME type of the data. If this is ``None`` (default), Streamlit
| sets the MIME type depending on the value of ``data`` as follows:
|
| - If ``data`` is a string or textual file (i.e. ``str`` or
| ``io.TextIOWrapper`` object), Streamlit uses the "text/plain"
| MIME type.
| - If ``data`` is a binary file or bytes (i.e. ``bytes``,
| ``io.BytesIO``, ``io.BufferedReader``, or ``io.RawIOBase``
| object), Streamlit uses the "application/octet-stream" MIME type.
|
| For more information about MIME types, see
| https://www.iana.org/assignments/media-types/media-types.xhtml.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you access the widget's value via
| ``st.session_state[key]`` (read-only). For more details, see
| `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed when the button is hovered over. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_click : callable, "rerun", "ignore", or None
| How the button should respond to user interaction. This controls
| whether or not the button triggers a rerun and if a callback
| function is called. This can be one of the following values:
|
| - ``"rerun"`` (default): The user downloads the file and the app
| reruns. No callback function is called.
| - ``"ignore"``: The user downloads the file and the app doesn't
| rerun. No callback function is called.
| - A ``callable``: The user downloads the file and app reruns. The
| callable is called before the rest of the app.
| - ``None``: This is same as ``on_click="rerun"``. This value exists
| for backwards compatibility and shouldn't be used.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| type : "primary", "secondary", or "tertiary"
| An optional string that specifies the button type. This can be one
| of the following:
|
| - ``"primary"``: The button's background is the app's primary color
| for additional emphasis.
| - ``"secondary"`` (default): The button's background coordinates
| with the app's background color for normal emphasis.
| - ``"tertiary"``: The button is plain text without a border or
| background for subtlety.
|
| icon : str or None
| An optional emoji or icon to display next to the button label. If ``icon``
| is ``None`` (default), no icon is displayed. If ``icon`` is a
| string, the following options are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols \
| <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| icon_position : "left" or "right"
| The position of the icon relative to the button label. This
| defaults to ``"left"``.
|
| disabled : bool
| An optional boolean that disables the download button if set to
| ``True``. The default is ``False``.
|
| use_container_width : bool
| Whether to expand the button's width to fill its parent container.
| If ``use_container_width`` is ``False`` (default), Streamlit sizes
| the button to fit its contents. If ``use_container_width`` is
| ``True``, the width of the button matches its parent container.
|
| In both cases, if the contents of the button are wider than the
| parent container, the contents will line wrap.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``. For ``use_container_width=False``, use
| ``width="content"``.
|
| width : "content", "stretch", or int
| The width of the download button. This can be one of the following:
|
| - ``"content"`` (default): The width of the button matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the button matches the width of the
| parent container.
| - An integer specifying the width in pixels: The button has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the button matches the width
| of the parent container.
|
| shortcut : str or None
| An optional keyboard shortcut that triggers the button. This can be
| one of the following strings:
|
| - A single alphanumeric key like ``"K"`` or ``"4"``.
| - A function key like ``"F11"``.
| - A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
| - Any of the above combined with modifiers. For example, you can use
| ``"Ctrl+K"`` or ``"Cmd+Shift+O"``.
|
| .. important::
| The keys ``"C"`` and ``"R"`` are reserved and can't be used,
| even with modifiers. Punctuation keys like ``"."`` and ``","``
| aren't currently supported.
|
| For a list of supported keys and modifiers, see the documentation
| for |st.button|_.
|
| .. |st.button| replace:: ``st.button``
| .. _st.button: https://docs.streamlit.io/develop/api-reference/widgets/st.button
|
| Returns
| -------
| bool
| True if the button was clicked on the last run of the app,
| False otherwise.
|
| Examples
| --------
| **Example 1: Download a dataframe as a CSV file**
|
| When working with a large dataframe, it's recommended to fetch your
| data with a cached function. When working with a download button, it's
| similarly recommended to convert your data into a downloadable format
| with a cached function. Caching ensures that the app reruns
| efficiently.
|
| >>> import streamlit as st
| >>> import pandas as pd
| >>> import numpy as np
| >>>
| >>> @st.cache_data
| >>> def get_data():
| >>> df = pd.DataFrame(
| ... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
| ... )
| >>> return df
| >>>
| >>> @st.cache_data
| >>> def convert_for_download(df):
| >>> return df.to_csv().encode("utf-8")
| >>>
| >>> df = get_data()
| >>> csv = convert_for_download(df)
| >>>
| >>> st.download_button(
| ... label="Download CSV",
| ... data=csv,
| ... file_name="data.csv",
| ... mime="text/csv",
| ... icon=":material/download:",
| ... )
|
| .. output::
| https://doc-download-button-csv.streamlit.app/
| height: 200px
|
| **Example 2: Download a string as a text file**
|
| If you pass a string to the ``data`` argument, Streamlit will
| automatically use the "text/plain" MIME type.
|
| When you have a widget (like a text area) affecting the value of your
| download, it's recommended to use another button to prepare the
| download. In this case, use ``on_click="ignore"`` in your download
| button to prevent the download button from rerunning your app. This
| turns the download button into a frontend-only element that can be
| nested in another button.
|
| Without a preparation button, a user can type something into the text
| area and immediately click the download button. Because a download is
| initiated concurrently with the app rerun, this can create a race-like
| condition where the user doesn't see the updated data in their
| download.
|
| .. important::
| Even when you prevent your download button from triggering a rerun,
| another widget with a pending change can still trigger a rerun. For
| example, if a text area has a pending change when a user clicks a
| download button, the text area will trigger a rerun.
|
| >>> import streamlit as st
| >>>
| >>> message = st.text_area("Message", value="Lorem ipsum.\nStreamlit is cool.")
| >>>
| >>> if st.button("Prepare download"):
| >>> st.download_button(
| ... label="Download text",
| ... data=message,
| ... file_name="message.txt",
| ... on_click="ignore",
| ... type="primary",
| ... icon=":material/download:",
| ... )
|
| .. output::
| https://doc-download-button-text.streamlit.app/
| height: 250px
|
| **Example 3: Download a file**
|
| Use a context manager to open and read a local file on your Streamlit
| server. Pass the ``io.BufferedReader`` object directly to ``data``.
| Remember to specify the MIME type if you don't want the default
| type of ``"application/octet-stream"`` for generic binary data. In the
| example below, the MIME type is set to ``"image/png"`` for a PNG file.
|
| >>> import streamlit as st
| >>>
| >>> with open("flower.png", "rb") as file:
| ... st.download_button(
| ... label="Download image",
| ... data=file,
| ... file_name="flower.png",
| ... mime="image/png",
| ... )
|
| .. output::
| https://doc-download-button-file.streamlit.app/
| height: 200px
|
| **Example 4: Generate the data on-click with a callable**
|
| Pass a callable to ``data`` to generate the bytes lazily when the user
| clicks the button. Streamlit commands inside this callable are ignored.
| The callable can't accept any arguments and must return a file-like
| object.
|
| >>> import streamlit as st
| >>> import time
| >>>
| >>> def make_report():
| >>> time.sleep(1)
| >>> return "col1,col2\n1,2\n3,4".encode("utf-8")
| >>>
| >>> st.download_button(
| ... label="Download report",
| ... data=make_report,
| ... file_name="report.csv",
| ... mime="text/csv",
| ... )
|
| .. output::
| https://doc-download-button-deferred.streamlit.app/
| height: 200px
|
| link_button(self, label: 'str', url: 'str', *, key: 'Key | None' = None, on_click: "WidgetCallback | Literal['rerun', 'ignore']" = 'ignore', args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, help: 'str | None' = None, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', icon: 'str | None' = None, icon_position: 'IconPosition' = 'left', disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', shortcut: 'str | None' = None) -> 'bool | DeltaGenerator' from ButtonMixin
| Display a link button element.
|
| When clicked, a new tab will be opened to the specified URL. This will
| create a new session for the user if directed within the app.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this button is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| url : str
| The URL to open on user click.
|
| key : str, int, or None
| An optional string to use for giving this element a stable
| identity. If this is ``None`` (default), the element's identity
| will be determined based on the values of the other parameters.
|
| If ``on_click`` enables widget behavior and ``key`` is provided,
| Streamlit will register the key in Session State to store the button state.
| The button state is read-only. For more details, see `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| on_click : callable, "rerun", or "ignore"
| How the button should respond to user interaction. This controls
| whether or not the button behaves like an input widget. This can
| be one of the following values:
|
| - ``"ignore"`` (default): Streamlit opens the link in a new tab
| and doesn't rerun the app. The button won't behave like an
| input widget.
| - ``"rerun"``: Streamlit opens the link in a new tab and reruns
| the app. In this case, ``st.link_button`` returns a Boolean value
| like ``st.button``.
| - A ``callable``: Streamlit opens the link in a new tab, reruns
| the app, and executes the callable at the beginning of the rerun.
| In this case, ``st.link_button`` returns a Boolean value.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback when
| ``on_click`` is a callable. If ``on_click`` isn't a callable,
| this is ignored.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback when
| ``on_click`` is a callable. If ``on_click`` isn't a callable,
| this is ignored.
|
| help : str or None
| A tooltip that gets displayed when the button is hovered over. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| type : "primary", "secondary", or "tertiary"
| An optional string that specifies the button type. This can be one
| of the following:
|
| - ``"primary"``: The button's background is the app's primary color
| for additional emphasis.
| - ``"secondary"`` (default): The button's background coordinates
| with the app's background color for normal emphasis.
| - ``"tertiary"``: The button is plain text without a border or
| background for subtlety.
|
| icon : str or None
| An optional emoji or icon to display next to the button label. If ``icon``
| is ``None`` (default), no icon is displayed. If ``icon`` is a
| string, the following options are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols \
| <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| icon_position : "left" or "right"
| The position of the icon relative to the button label. This
| defaults to ``"left"``.
|
| disabled : bool
| An optional boolean that disables the link button if set to
| ``True``. The default is ``False``.
|
| use_container_width : bool
| Whether to expand the button's width to fill its parent container.
| If ``use_container_width`` is ``False`` (default), Streamlit sizes
| the button to fit its contents. If ``use_container_width`` is
| ``True``, the width of the button matches its parent container.
|
| In both cases, if the contents of the button are wider than the
| parent container, the contents will line wrap.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``. For ``use_container_width=False``, use
| ``width="content"``.
|
| width : "content", "stretch", or int
| The width of the link button. This can be one of the following:
|
| - ``"content"`` (default): The width of the button matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the button matches the width of the
| parent container.
| - An integer specifying the width in pixels: The button has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the button matches the width
| of the parent container.
|
| shortcut : str or None
| An optional keyboard shortcut that triggers the button. This can be
| one of the following strings:
|
| - A single alphanumeric key like ``"K"`` or ``"4"``.
| - A function key like ``"F11"``.
| - A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
| - Any of the above combined with modifiers. For example, you can use
| ``"Ctrl+K"`` or ``"Cmd+Shift+O"``.
|
| .. important::
| The keys ``"C"`` and ``"R"`` are reserved and can't be used,
| even with modifiers. Punctuation keys like ``"."`` and ``","``
| aren't currently supported.
|
| For a list of supported keys and modifiers, see the documentation
| for |st.button|_.
|
| .. |st.button| replace:: ``st.button``
| .. _st.button: https://docs.streamlit.io/develop/api-reference/widgets/st.button
|
| Returns
| -------
| element or bool
| If ``on_click`` is ``"ignore"`` (default), this command returns an internal
| placeholder for the button element. Otherwise, this command returns a Boolean
| value in the same manner as ``st.button``: ``True`` if the button was clicked
| on the last rerun and ``False`` if it wasn't.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.link_button("Go to gallery", "https://streamlit.io/gallery")
|
| .. output::
| https://doc-link-button.streamlit.app/
| height: 200px
|
| page_link(self, page: 'str | Path | StreamlitPage', *, label: 'str | None' = None, icon: 'str | None' = None, icon_position: 'IconPosition' = 'left', help: 'str | None' = None, disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', query_params: 'QueryParamsInput | None' = None) -> 'DeltaGenerator' from ButtonMixin
| Display a link to another page in a multipage app or to an external page.
|
| If another page in a multipage app is specified, clicking ``st.page_link``
| stops the current page execution and runs the specified page as if the
| user clicked on it in the sidebar navigation.
|
| If an external page is specified, clicking ``st.page_link`` opens a new
| tab to the specified page. The current script run will continue if not
| complete.
|
| Parameters
| ----------
| page : str, Path, or StreamlitPage
| The page to switch to on user click. This can be one of the
| following values:
|
| - Path to a Python file: The path can be a string or
| ``pathlib.Path`` object. It can be absolute or relative to the
| entrypoint file. The Python file must be the source of a page in
| ``st.navigation``.
|
| If you are using the ``pages/`` directory instead of
| ``st.navigation``, the Python file must be your entrypoint file
| or a file in the ``pages/`` directory.
|
| - ``StreamlitPage``: The source of the ``StreamlitPage`` and its
| ``url_path`` must match a page defined in ``st.navigation``.
| Use ``st.Page`` to create a ``StreamlitPage`` object.
|
| - URL: The URL must contain an HTTP or HTTPS scheme, like
| ``"https://docs.streamlit.io"``. When a user clicks a
| URL-defined page link, the URL opens in a new tab and the app
| doesn't rerun. If the page link is defined by a URL, then the
| ``label`` parameter is required.
|
| To link to a page defined by a ``callable``, you must use a
| ``StreamlitPage`` object.
|
| label : str
| The label for the page link. Labels are required for external pages.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| icon : str or None
| An optional emoji or icon to display next to the link label. If
| ``icon`` is ``None`` (default), the icon is inferred from the
| ``StreamlitPage`` object or no icon is displayed. If ``icon`` is a
| string, the following options are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols \
| <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| icon_position : "left" or "right"
| The position of the icon relative to the link label. This
| defaults to ``"left"``.
|
| help : str or None
| A tooltip that gets displayed when the link is hovered over. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| disabled : bool
| An optional boolean that disables the page link if set to ``True``.
| The default is ``False``.
|
| use_container_width : bool
| Whether to expand the link's width to fill its parent container.
| The default is ``True`` for page links in the sidebar and ``False``
| for those in the main app.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``. For ``use_container_width=False``, use
| ``width="content"``.
|
| width : "content", "stretch", or int
| The width of the page-link button. This can be one of the following:
|
| - ``"content"`` (default): The width of the button matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the button matches the width of the
| parent container.
| - An integer specifying the width in pixels: The button has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the button matches the width
| of the parent container.
|
| query_params : dict, list of tuples, or None
| Query parameters to apply when navigating to the target page.
| This can be a dictionary or an iterable of key-value tuples. Values can
| be strings or iterables of strings (for repeated keys). When this is
| ``None`` (default), all non-embed query parameters are cleared during
| navigation.
|
| Examples
| --------
| **Example 1: Basic usage**
|
| The following example shows how to create page links in a multipage app
| that uses the ``pages/`` directory:
|
| .. code-block:: text
|
| your-repository/
| ├── pages/
| │ ├── page_1.py
| │ └── page_2.py
| └── your_app.py
|
| >>> import streamlit as st
| >>>
| >>> st.page_link("your_app.py", label="Home", icon="🏠")
| >>> st.page_link("pages/page_1.py", label="Page 1", icon="1️⃣")
| >>> st.page_link("pages/page_2.py", label="Page 2", icon="2️⃣", disabled=True)
| >>> st.page_link("http://www.google.com", label="Google", icon="🌎")
|
| The default navigation is shown here for comparison, but you can hide
| the default navigation using the |client.showSidebarNavigation|_
| configuration option. This allows you to create custom, dynamic
| navigation menus for your apps!
|
| .. |client.showSidebarNavigation| replace:: ``client.showSidebarNavigation``
| .. _client.showSidebarNavigation: https://docs.streamlit.io/develop/api-reference/configuration/config.toml#client
|
| .. output::
| https://doc-page-link.streamlit.app/
| height: 350px
|
| **Example 2: Passing query parameters**
|
| The following example shows how to pass query parameters when creating a
| page link in a multipage app:
|
| .. code-block:: text
|
| your-repository/
| ├── page_2.py
| └── your_app.py
|
| >>> import streamlit as st
| >>>
| >>> def page_1():
| >>> st.title("Page 1")
| >>> st.page_link("page_2.py", query_params={"utm_source": "page_1"})
| >>>
| >>> pg = st.navigation([page_1, "page_2.py"])
| >>> pg.run()
|
| .. output::
| https://doc-page-link-query-params.streamlit.app/
| height: 350px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.button_group.ButtonGroupMixin:
|
| pills(self, label: 'str', options: 'OptionSequence[V]', *, selection_mode: "Literal['single', 'multi']" = 'single', default: 'Sequence[V] | V | None' = None, required: 'bool' = False, format_func: 'Callable[[Any], str] | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'list[V] | V | None' from ButtonGroupMixin
| Display a pills widget.
|
| A pills widget is similar to a ``st.selectbox`` or ``st.multiselect``
| where the ``options`` are displayed as pill-buttons instead of a
| drop-down list.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this widget is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| options : Iterable of V
| Labels for the select options in an ``Iterable``. This can be a
| ``list``, ``set``, or anything supported by ``st.dataframe``. If
| ``options`` is dataframe-like, the first column will be used. Each
| label will be cast to ``str`` internally by default and can
| optionally contain GitHub-flavored Markdown, including the Markdown
| directives described in the ``body`` parameter of ``st.markdown``.
|
| selection_mode : "single" or "multi"
| The selection mode for the widget. If this is ``"single"``
| (default), only one option can be selected. If this is ``"multi"``,
| multiple options can be selected.
|
| default : Iterable of V, V, or None
| The value of the widget when it first renders. If the
| ``selection_mode`` is ``multi``, this can be a list of values, a
| single value, or ``None``. If the ``selection_mode`` is
| ``"single"``, this can be a single value or ``None``.
|
| required : bool
| Whether a selection is required. If this is ``True`` and
| ``selection_mode="single"``, users cannot deselect an option once
| one is selected. Clicking an already-selected option does nothing.
| The default is ``False``.
|
| If ``required=True`` is used with ``selection_mode="multi"``, an
| exception is raised.
|
| format_func : function
| Function to modify the display of the options. It receives
| the raw option as an argument and should output the label to be
| shown for that option. This has no impact on the return value of
| the command. The output can optionally contain GitHub-flavored
| Markdown, including the Markdown directives described in the
| ``body`` parameter of ``st.markdown``.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``selection_mode`` resets the widget even when a
| key is provided.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this widget's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the widget if set to ``True``.
| The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "content", "stretch", or int
| The width of the pills widget. This can be one of the following:
|
| - ``"content"`` (default): The width of the widget matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the widget matches the width of the
| parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| An empty query parameter (e.g., ``?tags=``) clears the
| widget. Invalid query parameter values are ignored and removed from
| the URL. For ``selection_mode="multi"``, multiple selections use
| repeated parameters (e.g., ``?tags=Red&tags=Blue``) and duplicates
| are deduplicated.
|
| Returns
| -------
| list of V, V, or None
| If the ``selection_mode`` is ``multi``, this is a list of selected
| options or an empty list. If the ``selection_mode`` is
| ``"single"``, this is a selected option or ``None``.
|
| This contains copies of the selected options, not the originals.
|
| Examples
| --------
| **Example 1: Multi-select pills**
|
| Display a multi-select pills widget, and show the selection:
|
| >>> import streamlit as st
| >>>
| >>> options = ["North", "East", "South", "West"]
| >>> selection = st.pills("Directions", options, selection_mode="multi")
| >>> st.markdown(f"Your selected options: {selection}.")
|
| .. output::
| https://doc-pills-multi.streamlit.app/
| height: 200px
|
| **Example 2: Single-select pills with icons**
|
| Display a single-select pills widget with icons:
|
| >>> import streamlit as st
| >>>
| >>> option_map = {
| ... 0: ":material/add:",
| ... 1: ":material/zoom_in:",
| ... 2: ":material/zoom_out:",
| ... 3: ":material/zoom_out_map:",
| ... }
| >>> selection = st.pills(
| ... "Tool",
| ... options=option_map.keys(),
| ... format_func=lambda option: option_map[option],
| ... selection_mode="single",
| ... )
| >>> st.write(
| ... "Your selected option: "
| ... f"{None if selection is None else option_map[selection]}"
| ... )
|
| .. output::
| https://doc-pills-single.streamlit.app/
| height: 200px
|
| segmented_control(self, label: 'str', options: 'OptionSequence[V]', *, selection_mode: "Literal['single', 'multi']" = 'single', default: 'Sequence[V] | V | None' = None, required: 'bool' = False, format_func: 'Callable[[Any], str] | None' = None, key: 'str | int | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'list[V] | V | None' from ButtonGroupMixin
| Display a segmented control widget.
|
| A segmented control widget is a linear set of segments where each of
| the passed ``options`` functions like a toggle button.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this widget is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| options : Iterable of V
| Labels for the select options in an ``Iterable``. This can be a
| ``list``, ``set``, or anything supported by ``st.dataframe``. If
| ``options`` is dataframe-like, the first column will be used. Each
| label will be cast to ``str`` internally by default and can
| optionally contain GitHub-flavored Markdown, including the Markdown
| directives described in the ``body`` parameter of ``st.markdown``.
|
| selection_mode : "single" or "multi"
| The selection mode for the widget. If this is ``"single"``
| (default), only one option can be selected. If this is ``"multi"``,
| multiple options can be selected.
|
| default : Iterable of V, V, or None
| The value of the widget when it first renders. If the
| ``selection_mode`` is ``multi``, this can be a list of values, a
| single value, or ``None``. If the ``selection_mode`` is
| ``"single"``, this can be a single value or ``None``.
|
| required : bool
| Whether a selection is required. If this is ``True`` and
| ``selection_mode="single"``, users cannot deselect an option once
| one is selected. Clicking an already-selected option does nothing.
| The default is ``False``.
|
| If ``required=True`` is used with ``selection_mode="multi"``, an
| exception is raised.
|
| format_func : function
| Function to modify the display of the options. It receives
| the raw option as an argument and should output the label to be
| shown for that option. This has no impact on the return value of
| the command. The output can optionally contain GitHub-flavored
| Markdown, including the Markdown directives described in the
| ``body`` parameter of ``st.markdown``.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``selection_mode`` resets the widget even when a
| key is provided.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this widget's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the widget if set to ``True``.
| The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "content", "stretch", or int
| The width of the segmented control widget. This can be one of the
| following:
|
| - ``"content"`` (default): The width of the widget matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the widget matches the width of the
| parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| An empty query parameter (e.g., ``?tags=``) clears the
| widget. Invalid query parameter values are ignored and removed from
| the URL. For ``selection_mode="multi"``, multiple selections use
| repeated parameters (e.g., ``?tags=Red&tags=Blue``) and duplicates
| are deduplicated.
|
| Returns
| -------
| list of V, V, or None
| If the ``selection_mode`` is ``multi``, this is a list of selected
| options or an empty list. If the ``selection_mode`` is
| ``"single"``, this is a selected option or ``None``.
|
| This contains copies of the selected options, not the originals.
|
| Examples
| --------
| **Example 1: Multi-select segmented control**
|
| Display a multi-select segmented control widget, and show the
| selection:
|
| >>> import streamlit as st
| >>>
| >>> options = ["North", "East", "South", "West"]
| >>> selection = st.segmented_control(
| ... "Directions", options, selection_mode="multi"
| ... )
| >>> st.markdown(f"Your selected options: {selection}.")
|
| .. output::
| https://doc-segmented-control-multi.streamlit.app/
| height: 200px
|
| **Example 2: Single-select segmented control with icons**
|
| Display a single-select segmented control widget with icons:
|
| >>> import streamlit as st
| >>>
| >>> option_map = {
| ... 0: ":material/add:",
| ... 1: ":material/zoom_in:",
| ... 2: ":material/zoom_out:",
| ... 3: ":material/zoom_out_map:",
| ... }
| >>> selection = st.segmented_control(
| ... "Tool",
| ... options=option_map.keys(),
| ... format_func=lambda option: option_map[option],
| ... selection_mode="single",
| ... )
| >>> st.write(
| ... "Your selected option: "
| ... f"{None if selection is None else option_map[selection]}"
| ... )
|
| .. output::
| https://doc-segmented-control-single.streamlit.app/
| height: 200px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.camera_input.CameraInputMixin:
|
| camera_input(self, label: 'str', key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch') -> 'UploadedFile | None' from CameraInputMixin
| Display a widget that returns pictures from the user's webcam.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this widget is used for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you access the widget's value via
| ``st.session_state[key]`` (read-only). For more details, see
| `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this camera_input's value
| changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the camera input if set to
| ``True``. Default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "stretch" or int
| The width of the camera input widget. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| Returns
| -------
| None or UploadedFile
| The UploadedFile class is a subclass of BytesIO, and therefore is
| "file-like". This means you can pass an instance of it anywhere a
| file is expected.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> enable = st.checkbox("Enable camera")
| >>> picture = st.camera_input("Take a picture", disabled=not enable)
| >>>
| >>> if picture:
| ... st.image(picture)
|
| .. output::
| https://doc-camera-input.streamlit.app/
| height: 600px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.chat.ChatMixin:
|
| chat_input(self, placeholder: 'str' = 'Your message', *, key: 'Key | None' = None, max_chars: 'int | None' = None, max_upload_size: 'int | None' = None, accept_file: "bool | Literal['multiple', 'directory']" = False, file_type: 'str | Sequence[str] | None' = None, accept_audio: 'bool' = False, audio_sample_rate: 'int | None' = 16000, disabled: 'bool' = False, on_submit: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, width: 'WidthWithoutContent' = 'stretch', height: 'Height' = 'content') -> 'str | ChatInputValue | None' from ChatMixin
| Display a chat input widget.
|
| Parameters
| ----------
| placeholder : str
| A placeholder text shown when the chat input is empty. This
| defaults to ``"Your message"``. For accessibility reasons, you
| should not use an empty string.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``accept_file``, ``file_type``, ``max_chars``,
| or ``max_upload_size`` resets the widget even when a key
| is provided.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| max_chars : int or None
| The maximum number of characters that can be entered. If this is
| ``None`` (default), there will be no maximum.
|
| max_upload_size : int or None
| The maximum allowed size of each uploaded file in megabytes.
|
| If this is ``None`` (default), the maximum file size is set by the
| ``server.maxUploadSize`` configuration option in your
| ``config.toml`` file. If this is an integer, it must be positive
| and will override the ``server.maxUploadSize`` configuration option.
|
| accept_file : bool, "multiple", or "directory"
| Whether the chat input should accept files. This can be one of the
| following values:
|
| - ``False`` (default): No files are accepted and the user can only
| submit a message.
| - ``True``: The user can add a single file to their submission.
| - ``"multiple"``: The user can add multiple files to their
| submission.
| - ``"directory"``: The user can add multiple files to their
| submission by selecting a directory. If ``file_type`` is set,
| only files matching those type(s) will be uploaded.
|
| By default, uploaded files are limited to 200 MB each. You can
| configure this using the ``server.maxUploadSize`` config option.
| For more information on how to set config options, see
| |config.toml|_.
|
| .. |config.toml| replace:: ``config.toml``
| .. _config.toml: https://docs.streamlit.io/develop/api-reference/configuration/config.toml
|
| file_type : str, Sequence[str], or None
| The allowed file types for uploaded files. This can be one of the
| following values:
|
| - ``None`` (default): All file extensions are allowed.
| - A file extension: Only one file extension is allowed. For example,
| to only accept CSV files, use ``"csv"`` or ``".csv"``.
| - A MIME type: Only one MIME type is allowed. For example,
| to accept JPEG images, use ``"image/jpeg"``.
| - A MIME wildcard: All types within a MIME media type are allowed.
| For example, to accept all images, use ``"image/*"``.
| - A MIME media type: This is a shortcut that is equivalent to a
| MIME wildcard. If you use ``"image"``, ``"audio"``, ``"video"``, or
| ``"text"``, Streamlit will internally append ``/*`` to create
| a MIME wildcard.
| - A sequence of strings: Use a combination of the previously listed
| strings to accept multiple file types.
|
| For more information about MIME types, see
| https://www.iana.org/assignments/media-types/media-types.xhtml.
|
| .. note::
| This is a best-effort check, but doesn't provide a
| security guarantee against users uploading files of other types
| or type extensions. The correct handling of uploaded files is
| part of the app developer's responsibility.
|
| accept_audio : bool
| Whether to show an audio recording button in the chat input. This
| defaults to ``False``. If this is ``True``, users can record and
| submit audio messages. Recorded audio is available as an
| ``UploadedFile`` object with MIME type ``audio/wav``.
|
| audio_sample_rate : int or None
| The target sample rate for audio recording in Hz when
| ``accept_audio`` is ``True``. This defaults to ``16000``, which is
| optimal for speech recognition.
|
| The following values are supported: ``8000`` (telephone quality),
| ``11025``, ``16000`` (speech-recognition quality), ``22050``,
| ``24000``, ``32000``, ``44100``, ``48000`` (high-quality), or
| ``None``. If this is ``None``, the widget uses the browser's
| default sample rate (typically 44100 or 48000 Hz).
|
| disabled : bool
| Whether the chat input should be disabled. This defaults to
| ``False``.
|
| on_submit : callable
| An optional callback invoked when the chat input's value is submitted.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| width : "stretch" or int
| The width of the chat input widget. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| height : "content", "stretch", or int
| The minimum height of the chat input widget. This can be one of
| the following:
|
| - ``"content"`` (default): The widget uses the default single-line
| height and automatically expands based on the text content.
| - ``"stretch"``: The height of the widget stretches to fill the
| available height of the parent container. The parent container
| must have a defined height for this to work properly.
| - An integer specifying the minimum height in pixels: The widget
| has a fixed minimum height but still auto-expands based on text
| content. The minimum recommended height is 68 pixels, which fits
| a single line of text.
|
| Returns
| -------
| None, str, or dict-like
| The user's submission. This is one of the following types:
|
| - ``None``: If the user didn't submit a message, file, or audio
| recording in the last rerun, the widget returns ``None``.
| - A string: When the widget isn't configured to accept files or
| audio recordings, and the user submitted a message in the last
| rerun, the widget returns the user's message as a string.
| - A dict-like object: When the widget is configured to accept files
| or audio recordings, and the user submitted any content in the
| last rerun, the widget returns a dict-like object.
| The object always includes the ``text`` attribute, and
| optionally includes ``files`` and/or ``audio`` attributes depending
| on the ``accept_file`` and ``accept_audio`` parameters.
|
| When the widget is configured to accept files or audio recordings,
| and the user submitted content in the last rerun, you can access
| the user's submission with key or attribute notation from the
| dict-like object. This is shown in Example 3 below.
|
| - The ``text`` attribute holds a string that is the user's message.
| This is an empty string if the user only submitted one or more
| files or audio recordings.
| - The ``files`` attribute is only present when ``accept_file``
| isn't ``False``. When present, it holds a list of
| ``UploadedFile`` objects. The list is empty if the user only
| submitted a message or audio recording. Unlike
| ``st.file_uploader``, this attribute always returns a list, even
| when the widget is configured to accept only one file at a time.
| - The ``audio`` attribute is only present when ``accept_audio`` is
| ``True``. When present, it holds an ``UploadedFile`` object if
| audio was recorded or ``None`` if no audio was recorded.
|
| The ``UploadedFile`` class is a subclass of ``BytesIO`` and
| therefore is "file-like". This means you can pass an instance of it
| anywhere a file is expected.
|
| Examples
| --------
| **Example 1: Pin the chat input widget to the bottom of your app**
|
| When ``st.chat_input`` is used in the main body of an app, it will be
| pinned to the bottom of the page.
|
| >>> import streamlit as st
| >>>
| >>> prompt = st.chat_input("Say something")
| >>> if prompt:
| ... st.write(f"User has sent the following prompt: {prompt}")
|
| .. output::
| https://doc-chat-input.streamlit.app/
| height: 350px
|
| **Example 2: Use the chat input widget inline**
|
| The chat input can also be used inline by nesting it inside any layout
| container (container, columns, tabs, sidebar, etc) or fragment. Create
| chat interfaces embedded next to other content, or have multiple
| chatbots!
|
| >>> import streamlit as st
| >>>
| >>> with st.sidebar:
| >>> messages = st.container(height=200)
| >>> if prompt := st.chat_input("Say something"):
| >>> messages.chat_message("user").write(prompt)
| >>> messages.chat_message("assistant").write(f"Echo: {prompt}")
|
| .. output::
| https://doc-chat-input-inline.streamlit.app/
| height: 350px
|
| **Example 3: Let users upload files**
|
| When you configure your chat input widget to allow file attachments, it
| will return a dict-like object when the user sends a submission. You
| can access the user's message through the ``text`` attribute of this
| dictionary. You can access a list of the user's submitted file(s)
| through the ``files`` attribute. Similar to ``st.session_state``, you
| can use key or attribute notation.
|
| >>> import streamlit as st
| >>>
| >>> prompt = st.chat_input(
| >>> "Say something and/or attach an image",
| >>> accept_file=True,
| >>> file_type=["jpg", "jpeg", "png"],
| >>> )
| >>> if prompt and prompt.text:
| >>> st.markdown(prompt.text)
| >>> if prompt and prompt["files"]:
| >>> st.image(prompt["files"][0])
|
| .. output::
| https://doc-chat-input-file-uploader.streamlit.app/
| height: 350px
|
| **Example 4: Programmatically set the text via session state**
|
| You can use ``st.session_state`` to set the text of the chat input widget.
| Because ``st.chat_input`` is a trigger widget, the value in Session State
| is cleared after the widget is populated. This prevents the widget from
| returning the value until the user submits it.
|
| >>> import streamlit as st
| >>>
| >>> if st.button("Set Value"):
| >>> st.session_state.chat_input = "Hello, world!"
| >>> st.chat_input(key="chat_input")
| >>> st.write("Chat input value:", st.session_state.chat_input)
|
| .. output::
| https://doc-chat-input-session-state.streamlit.app/
| height: 350px
|
| **Example 5: Enable audio recording**
|
| You can enable audio recording by setting ``accept_audio=True``.
| The ``accept_audio`` parameter works independently of ``accept_file``,
| allowing you to enable audio recording with or without file uploads.
|
| >>> import streamlit as st
| >>>
| >>> prompt = st.chat_input(
| >>> "Say or record something",
| >>> accept_audio=True,
| >>> )
| >>> if prompt and prompt.text:
| >>> st.write("Text:", prompt.text)
| >>> if prompt and prompt.audio:
| >>> st.audio(prompt.audio)
| >>> st.write("Audio file:", prompt.audio.name)
|
| .. output::
| https://doc-chat-input-audio.streamlit.app/
| height: 350px
|
| chat_message(self, name: "Literal['user', 'assistant', 'ai', 'human'] | str", *, avatar: "Literal['user', 'assistant'] | str | AtomicImage | None" = None, width: 'Width' = 'stretch') -> 'DeltaGenerator' from ChatMixin
| Insert a chat message container.
|
| To add elements to the returned container, you can use ``with`` notation
| (preferred) or just call methods directly on the returned object. See the
| examples below.
|
| .. note::
| To follow best design practices and maintain a good appearance on
| all screen sizes, don't nest chat message containers.
|
| Parameters
| ----------
| name : "user", "assistant", "ai", "human", or str
| The name of the message author. Can be "human"/"user" or
| "ai"/"assistant" to enable preset styling and avatars.
|
| Currently, the name is not shown in the UI but is only set as an
| accessibility label. For accessibility reasons, you should not use
| an empty string.
|
| avatar : Anything supported by st.image (except list), str, or None
| The avatar shown next to the message.
|
| If ``avatar`` is ``None`` (default), the icon will be determined
| from ``name`` as follows:
|
| - If ``name`` is ``"user"`` or ``"human"``, the message will have a
| default user icon.
|
| - If ``name`` is ``"ai"`` or ``"assistant"``, the message will have
| a default bot icon.
|
| - For all other values of ``name``, the message will show the first
| letter of the name.
|
| In addition to the types supported by |st.image|_ (except list),
| the following strings are valid:
|
| - A single-character emoji. For example, you can set ``avatar="🧑💻"``
| or ``avatar="🦖"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| .. |st.image| replace:: ``st.image``
| .. _st.image: https://docs.streamlit.io/develop/api-reference/media/st.image
|
| width : "stretch", "content", or int
| The width of the chat message container. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the container matches the
| width of the parent container.
| - ``"content"``: The width of the container matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The container has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the container matches the width
| of the parent container.
|
| Returns
| -------
| Container
| A single container that can hold multiple elements.
|
| Examples
| --------
| You can use ``with`` notation to insert any element into an expander
|
| >>> import streamlit as st
| >>> import numpy as np
| >>>
| >>> with st.chat_message("user"):
| ... st.write("Hello 👋")
| ... st.line_chart(np.random.randn(30, 3))
|
| .. output::
| https://doc-chat-message-user.streamlit.app/
| height: 450px
|
| Or you can just call methods directly in the returned objects:
|
| >>> import streamlit as st
| >>> import numpy as np
| >>>
| >>> message = st.chat_message("assistant")
| >>> message.write("Hello human")
| >>> message.bar_chart(np.random.randn(30, 3))
|
| .. output::
| https://doc-chat-message-user1.streamlit.app/
| height: 450px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.checkbox.CheckboxMixin:
|
| checkbox(self, label: 'str', value: 'bool' = False, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'bool' from CheckboxMixin
| Display a checkbox widget.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this checkbox is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| value : bool
| Preselect the checkbox when it first renders. This will be
| cast to bool internally.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this checkbox's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the checkbox if set to ``True``.
| The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "content", "stretch", or int
| The width of the checkbox widget. This can be one of the following:
|
| - ``"content"`` (default): The width of the widget matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the widget matches the width of the
| parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Returns
| -------
| bool
| Whether or not the checkbox is checked.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> agree = st.checkbox("I agree")
| >>>
| >>> if agree:
| ... st.write("Great!")
|
| .. output::
| https://doc-checkbox.streamlit.app/
| height: 220px
|
| toggle(self, label: 'str', value: 'bool' = False, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'bool' from CheckboxMixin
| Display a toggle widget.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this toggle is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| value : bool
| Preselect the toggle when it first renders. This will be
| cast to bool internally.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this toggle's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the toggle if set to ``True``.
| The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "content", "stretch", or int
| The width of the toggle widget. This can be one of the following:
|
| - ``"content"`` (default): The width of the widget matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the widget matches the width of the
| parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Returns
| -------
| bool
| Whether or not the toggle is checked.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> on = st.toggle("Activate feature")
| >>>
| >>> if on:
| ... st.write("Feature activated!")
|
| .. output::
| https://doc-toggle.streamlit.app/
| height: 220px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.code.CodeMixin:
|
| code(self, body: 'SupportsStr', language: 'str | None' = 'python', *, line_numbers: 'bool' = False, wrap_lines: 'bool' = False, height: 'Height | None' = 'content', width: 'Width' = 'stretch') -> 'DeltaGenerator' from CodeMixin
| Display a code block with optional syntax highlighting.
|
| Parameters
| ----------
| body : str
| The string to display as code or monospace text.
|
| language : str or None
| The language that the code is written in, for syntax highlighting.
| This defaults to ``"python"``. If this is ``None``, the code will
| be plain, monospace text.
|
| For a list of available ``language`` values, see
| `react-syntax-highlighter
| <https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/AVAILABLE_LANGUAGES_PRISM.MD>`_
| on GitHub.
|
| line_numbers : bool
| An optional boolean indicating whether to show line numbers to the
| left of the code block. This defaults to ``False``.
|
| wrap_lines : bool
| An optional boolean indicating whether to wrap lines. This defaults
| to ``False``.
|
| height : "content", "stretch", or int
| The height of the code block element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| .. note::
| Use scrolling containers sparingly. If you use scrolling
| containers, avoid heights that exceed 500 pixels. Otherwise,
| the scroll surface of the container might cover the majority of
| the screen on mobile devices, which makes it hard to scroll the
| rest of the app.
|
| width : "stretch", "content", or int
| The width of the code block element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> code = '''def hello():
| ... print("Hello, Streamlit!")'''
| >>> st.code(code, language="python")
|
| .. output::
| https://doc-code.streamlit.app/
| height: 220px
|
| >>> import streamlit as st
| >>> code = '''Is it a crown or boat?
| ... ii
| ... iiiiii
| ... WWw .iiiiiiii. ...:
| ... WWWWWWw .iiiiiiiiiiii. ........
| ... WWWWWWWWWWw iiiiiiiiiiiiiiii ...........
| ... WWWWWWWWWWWWWWwiiiiiiiiiiiiiiiii............
| ... WWWWWWWWWWWWWWWWWWwiiiiiiiiiiiiii.........
| ... WWWWWWWWWWWWWWWWWWWWWWwiiiiiiiiii.......
| ... WWWWWWWWWWWWWWWWWWWWWWWWWWwiiiiiii....
| ... WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWwiiii.
| ... -MMMWWWWWWWWWWWWWWWWWWWWWWMMM-
| ... '''
| >>> st.code(code, language=None)
|
| .. output::
| https://doc-code-ascii.streamlit.app/
| height: 380px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.color_picker.ColorPickerMixin:
|
| color_picker(self, label: 'str', value: 'str | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'str' from ColorPickerMixin
| Display a color picker widget.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this input is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| value : str
| The hex value of this widget when it first renders. If None,
| defaults to black.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this color_picker's value
| changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the color picker if set to
| ``True``. The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "content", "stretch", or int
| The width of the color picker widget. This can be one of the
| following:
|
| - ``"content"`` (default): The width of the widget matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the widget matches the width of the
| parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Returns
| -------
| str
| The selected color as a hex string.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> color = st.color_picker("Pick A Color", "#00f900")
| >>> st.write("The current color is", color)
|
| .. output::
| https://doc-color-picker.streamlit.app/
| height: 335px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.empty.EmptyMixin:
|
| empty(self) -> 'DeltaGenerator' from EmptyMixin
| Insert a single-element container.
|
| Inserts a container into your app that can be used to hold a single element.
| This allows you to, for example, remove elements at any point, or replace
| several elements at once (using a child multi-element container).
|
| To insert/replace/clear an element on the returned container, you can
| use ``with`` notation or just call methods directly on the returned object.
| See examples below.
|
| Examples
| --------
| Inside a ``with st.empty():`` block, each displayed element will
| replace the previous one.
|
| >>> import streamlit as st
| >>> import time
| >>>
| >>> with st.empty():
| ... for seconds in range(10):
| ... st.write(f"⏳ {seconds} seconds have passed")
| ... time.sleep(1)
| ... st.write(":material/check: 10 seconds over!")
| ... st.button("Rerun")
|
| .. output::
| https://doc-empty.streamlit.app/
| height: 220px
|
| You can use an ``st.empty`` to replace multiple elements in
| succession. Use ``st.container`` inside ``st.empty`` to display (and
| later replace) a group of elements.
|
| >>> import streamlit as st
| >>> import time
| >>>
| >>> st.button("Start over")
| >>>
| >>> placeholder = st.empty()
| >>> placeholder.markdown("Hello")
| >>> time.sleep(1)
| >>>
| >>> placeholder.progress(0, "Wait for it...")
| >>> time.sleep(1)
| >>> placeholder.progress(50, "Wait for it...")
| >>> time.sleep(1)
| >>> placeholder.progress(100, "Wait for it...")
| >>> time.sleep(1)
| >>>
| >>> with placeholder.container():
| ... st.line_chart({"data": [1, 5, 2, 6]})
| ... time.sleep(1)
| ... st.markdown("3...")
| ... time.sleep(1)
| ... st.markdown("2...")
| ... time.sleep(1)
| ... st.markdown("1...")
| ... time.sleep(1)
| >>>
| >>> placeholder.markdown("Poof!")
| >>> time.sleep(1)
| >>>
| >>> placeholder.empty()
|
| .. output::
| https://doc-empty-placeholder.streamlit.app/
| height: 600px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.exception.ExceptionMixin:
|
| exception(self, exception: 'BaseException', width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' from ExceptionMixin
| Display an exception.
|
| When accessing the app through ``localhost``, in the lower-right corner
| of the exception, Streamlit displays links to Google and ChatGPT that
| are prefilled with the contents of the exception message.
|
| Parameters
| ----------
| exception : Exception
| The exception to display.
| width : "stretch" or int
| The width of the exception element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> e = RuntimeError("This is an exception of type RuntimeError")
| >>> st.exception(e)
|
| .. output::
| https://doc-status-exception.streamlit.app/
| height: 220px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.feedback.FeedbackMixin:
|
| feedback(self, options: "Literal['thumbs', 'faces', 'stars']" = 'thumbs', *, key: 'Key | None' = None, default: 'int | None' = None, disabled: 'bool' = False, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, width: 'Width' = 'content') -> 'int | None' from FeedbackMixin
| Display a feedback widget.
|
| A feedback widget is an icon-based button group available in three
| styles, as described in ``options``. It is commonly used in chat and AI
| apps to allow users to rate responses.
|
| Parameters
| ----------
| options : "thumbs", "faces", or "stars"
| The feedback options displayed to the user. ``options`` can be one
| of the following:
|
| - ``"thumbs"`` (default): Streamlit displays a thumb-up and
| thumb-down button group.
| - ``"faces"``: Streamlit displays a row of five buttons with
| facial expressions depicting increasing satisfaction from left to
| right.
| - ``"stars"``: Streamlit displays a row of star icons, allowing the
| user to select a rating from one to five stars.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``options`` resets the widget even when a key is
| provided.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| default : int or None
| Default feedback value. This must be consistent with the feedback
| type in ``options``:
|
| - 0 or 1 if ``options="thumbs"``.
| - Between 0 and 4, inclusive, if ``options="faces"`` or
| ``options="stars"``.
|
| disabled : bool
| An optional boolean that disables the feedback widget if set
| to ``True``. The default is ``False``.
|
| on_change : callable
| An optional callback invoked when this feedback widget's value
| changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| width : "content", "stretch", or int
| The width of the feedback widget. This can be one of the following:
|
| - ``"content"`` (default): The width of the widget matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the widget matches the width of the
| parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| Returns
| -------
| int or None
| An integer indicating the user's selection, where ``0`` is the
| lowest feedback. Higher values indicate more positive feedback.
| If no option was selected, the widget returns ``None``.
|
| - For ``options="thumbs"``, a return value of ``0`` indicates
| thumbs-down, and ``1`` indicates thumbs-up.
| - For ``options="faces"`` and ``options="stars"``, return values
| range from ``0`` (least satisfied) to ``4`` (most satisfied).
|
| Examples
| --------
| Display a feedback widget with stars, and show the selected sentiment:
|
| >>> import streamlit as st
| >>>
| >>> sentiment_mapping = ["one", "two", "three", "four", "five"]
| >>> selected = st.feedback("stars")
| >>> if selected is not None:
| >>> st.markdown(f"You selected {sentiment_mapping[selected]} star(s).")
|
| .. output::
| https://doc-feedback-stars.streamlit.app/
| height: 200px
|
| Display a feedback widget with thumbs, and show the selected sentiment:
|
| >>> import streamlit as st
| >>>
| >>> sentiment_mapping = [":material/thumb_down:", ":material/thumb_up:"]
| >>> selected = st.feedback("thumbs")
| >>> if selected is not None:
| >>> st.markdown(f"You selected: {sentiment_mapping[selected]}")
|
| .. output::
| https://doc-feedback-thumbs.streamlit.app/
| height: 200px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.file_uploader.FileUploaderMixin:
|
| file_uploader(self, label: 'str', type: 'str | Sequence[str] | None' = None, accept_multiple_files: 'AcceptMultipleFiles' = False, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, max_upload_size: 'int | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch') -> 'UploadedFile | list[UploadedFile] | None' from FileUploaderMixin
| Display a file uploader widget.
|
| By default, uploaded files are limited to 200 MB each. You can
| configure this globally using the ``server.maxUploadSize`` configuration
| option. For more information on how to set configuration options, see
| |config.toml|_. Additionally, you can set a per-widget limit using the
| ``max_upload_size`` parameter.
|
| .. |config.toml| replace:: ``config.toml``
| .. _config.toml: https://docs.streamlit.io/develop/api-reference/configuration/config.toml
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this file uploader is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| type : str, list of str, or None
| The allowed file types for uploaded files. This can be one of the
| following values:
|
| - ``None`` (default): All file extensions are allowed.
| - A file extension: Only one file extension is allowed. For example,
| to only accept CSV files, use ``"csv"`` or ``".csv"``.
| - A MIME type: Only one MIME type is allowed. For example,
| to accept JPEG images, use ``"image/jpeg"``.
| - A MIME wildcard: All types within a MIME media type are allowed.
| For example, to accept all images, use ``"image/*"``.
| - A MIME media type: This is a shortcut that is equivalent to a
| MIME wildcard. If you use ``"image"``, ``"audio"``, ``"video"``, or
| ``"text"``, Streamlit will internally append ``/*`` to create
| a MIME wildcard.
| - A sequence of strings: Use a combination of the previously listed
| strings to accept multiple file types.
|
| For more information about MIME types, see
| https://www.iana.org/assignments/media-types/media-types.xhtml.
|
| .. note::
| This is a best-effort check, but doesn't provide a
| security guarantee against users uploading files of other types
| or type extensions. The correct handling of uploaded files is
| part of the app developer's responsibility.
|
| max_upload_size : int or None
| The maximum allowed size of each uploaded file in megabytes.
|
| If this is ``None`` (default), the maximum file size is set by the
| ``server.maxUploadSize`` configuration option in your
| ``config.toml`` file. If this is an integer, it must be positive
| and will override the ``server.maxUploadSize`` configuration option.
|
| accept_multiple_files : bool or "directory"
| Whether to accept more than one file in a submission. This can be one
| of the following values:
|
| - ``False`` (default): The user can only submit one file at a time.
| - ``True``: The user can upload multiple files at the same time.
| - ``"directory"``: The user can select a directory to upload all
| files in the directory and its subdirectories. If ``type`` is
| set, only files matching those type(s) will be uploaded.
|
| When this is ``True`` or ``"directory"``, the return value will be
| a list and a user can additively select files if they click the
| browse button on the widget multiple times.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``type``, ``accept_multiple_files``, or
| ``max_upload_size`` resets the widget even when a key is
| provided.
|
| A key lets you access the widget's value via
| ``st.session_state[key]`` (read-only). For more details, see
| `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this file_uploader's value
| changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the file uploader if set to
| ``True``. The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "stretch" or int
| The width of the file uploader widget. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| Returns
| -------
| None, UploadedFile, or list of UploadedFile
| - If accept_multiple_files is ``False``, returns either ``None`` or
| an ``UploadedFile`` object.
| - If accept_multiple_files is ``True`` or ``"directory"``, returns
| a list with the uploaded files as ``UploadedFile`` objects. If no
| files were uploaded, returns an empty list.
|
| The ``UploadedFile`` class is a subclass of ``BytesIO``, and
| therefore is "file-like". This means you can pass an instance of it
| anywhere a file is expected.
|
| Examples
| --------
| **Example 1: Accept a single file at a time**
|
| >>> import streamlit as st
| >>> import pandas as pd
| >>> from io import StringIO
| >>>
| >>> uploaded_file = st.file_uploader("Choose a file")
| >>> if uploaded_file is not None:
| ... # To read file as bytes:
| ... bytes_data = uploaded_file.getvalue()
| ... st.write(bytes_data)
| >>>
| ... # To convert to a string based IO:
| ... stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
| ... st.write(stringio)
| >>>
| ... # To read file as string:
| ... string_data = stringio.read()
| ... st.write(string_data)
| >>>
| ... # Can be used wherever a "file-like" object is accepted:
| ... dataframe = pd.read_csv(uploaded_file)
| ... st.write(dataframe)
|
| **Example 2: Accept multiple files at a time**
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>>
| >>> uploaded_files = st.file_uploader(
| ... "Upload data", accept_multiple_files=True, type="csv"
| ... )
| >>> for uploaded_file in uploaded_files:
| ... df = pd.read_csv(uploaded_file)
| ... st.write(df)
|
| .. output::
| https://doc-file-uploader.streamlit.app/
| height: 375px
|
| **Example 3: Accept an entire directory**
|
| >>> import streamlit as st
| >>>
| >>> uploaded_files = st.file_uploader(
| ... "Upload images", accept_multiple_files="directory", type=["jpg", "png"]
| ... )
| >>> for uploaded_file in uploaded_files:
| ... st.image(uploaded_file)
|
| .. output::
| https://doc-file-uploader-directory.streamlit.app/
| height: 375px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.form.FormMixin:
|
| form(self, key: 'str', clear_on_submit: 'bool' = False, *, enter_to_submit: 'bool' = True, border: 'bool' = True, width: 'Width' = 'stretch', height: 'Height' = 'content') -> 'DeltaGenerator' from FormMixin
| Create a form that batches elements together with a "Submit" button.
|
| A form is a container that visually groups other elements and
| widgets together, and contains a Submit button. When the form's
| Submit button is pressed, all widget values inside the form will be
| sent to Streamlit in a batch.
|
| To add elements to a form object, you can use ``with`` notation
| (preferred) or just call methods directly on the form. See
| examples below.
|
| Forms have a few constraints:
|
| - Every form must contain a ``st.form_submit_button``.
| - ``st.button`` and ``st.download_button`` cannot be added to a form.
| - Forms can appear anywhere in your app (sidebar, columns, etc),
| but they cannot be embedded inside other forms.
| - Within a form, the only widget that can have a callback function is
| ``st.form_submit_button``.
|
| Parameters
| ----------
| key : str
| A string that identifies the form. Each form must have its own
| key. (This key is not displayed to the user in the interface.)
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| clear_on_submit : bool
| If True, all widgets inside the form will be reset to their default
| values after the user presses the Submit button. Defaults to False.
| (Note that Custom Components are unaffected by this flag, and
| will not be reset to their defaults on form submission.)
| enter_to_submit : bool
| Whether to submit the form when a user presses Enter while
| interacting with a widget inside the form.
|
| If this is ``True`` (default), pressing Enter while interacting
| with a form widget is equivalent to clicking the first
| ``st.form_submit_button`` in the form.
|
| If this is ``False``, the user must click an
| ``st.form_submit_button`` to submit the form.
|
| If the first ``st.form_submit_button`` in the form is disabled,
| the form will override submission behavior with
| ``enter_to_submit=False``.
|
| border : bool
| Whether to show a border around the form. Defaults to True.
|
| .. note::
| Not showing a border can be confusing to viewers since interacting with a
| widget in the form will do nothing. You should only remove the border if
| there's another border (e.g. because of an expander) or the form is small
| (e.g. just a text input and a submit button).
|
| width : "stretch", "content", or int
| The width of the form container. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the container matches the
| width of the parent container.
| - ``"content"``: The width of the container matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The container has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the container matches the width
| of the parent container.
|
| height : "content", "stretch", or int
| The height of the form container. This can be one of the following:
|
| - ``"content"`` (default): The height of the container matches the
| height of its content.
| - ``"stretch"``: The height of the container matches the height of
| its content or the height of the parent container, whichever is
| larger. If the container is not in a parent container, the height
| of the container matches the height of its content.
| - An integer specifying the height in pixels: The container has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| .. note::
| Use scrolling containers sparingly. If you use scrolling
| containers, avoid heights that exceed 500 pixels. Otherwise,
| the scroll surface of the container might cover the majority of
| the screen on mobile devices, which makes it hard to scroll the
| rest of the app.
|
| Examples
| --------
| Inserting elements using ``with`` notation:
|
| >>> import streamlit as st
| >>>
| >>> with st.form("my_form"):
| ... st.write("Inside the form")
| ... slider_val = st.slider("Form slider")
| ... checkbox_val = st.checkbox("Form checkbox")
| ...
| ... # Every form must have a submit button.
| ... submitted = st.form_submit_button("Submit")
| ... if submitted:
| ... st.write("slider", slider_val, "checkbox", checkbox_val)
| >>> st.write("Outside the form")
|
| .. output::
| https://doc-form1.streamlit.app/
| height: 425px
|
| Inserting elements out of order:
|
| >>> import streamlit as st
| >>>
| >>> form = st.form("my_form")
| >>> form.slider("Inside the form")
| >>> st.slider("Outside the form")
| >>>
| >>> # Now add a submit button to the form:
| >>> form.form_submit_button("Submit")
|
| .. output::
| https://doc-form2.streamlit.app/
| height: 375px
|
| form_submit_button(self, label: 'str' = 'Submit', help: 'str | None' = None, on_click: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, key: 'Key | None' = None, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', icon: 'str | None' = None, icon_position: 'IconPosition' = 'left', disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', shortcut: 'str | None' = None) -> 'bool' from FormMixin
| Display a form submit button.
|
| When this button is clicked, all widget values inside the form will be
| sent from the user's browser to your Streamlit server in a batch.
|
| Every form must have at least one ``st.form_submit_button``. An
| ``st.form_submit_button`` cannot exist outside of a form.
|
| For more information about forms, check out our `docs
| <https://docs.streamlit.io/develop/concepts/architecture/forms>`_.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this button is for. This
| defaults to ``"Submit"``. The label can optionally contain
| GitHub-flavored Markdown of the following types: Bold, Italics,
| Strikethroughs, Inline Code, Links, and Images. Images display like
| icons, with a max height equal to the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| help : str or None
| A tooltip that gets displayed when the button is hovered over. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_click : callable
| An optional callback invoked when this button is clicked.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you access the widget's value via
| ``st.session_state[key]`` (read-only). For more details, see
| `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| type : "primary", "secondary", or "tertiary"
| An optional string that specifies the button type. This can be one
| of the following:
|
| - ``"primary"``: The button's background is the app's primary color
| for additional emphasis.
| - ``"secondary"`` (default): The button's background coordinates
| with the app's background color for normal emphasis.
| - ``"tertiary"``: The button is plain text without a border or
| background for subtlety.
|
| icon : str or None
| An optional emoji or icon to display next to the button label. If ``icon``
| is ``None`` (default), no icon is displayed. If ``icon`` is a
| string, the following options are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols
| <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| icon_position : "left" or "right"
| The position of the icon relative to the button label. This
| defaults to ``"left"``.
|
| disabled : bool
| Whether to disable the button. If this is ``False`` (default), the
| user can interact with the button. If this is ``True``, the button
| is grayed-out and can't be clicked.
|
| If the first ``st.form_submit_button`` in the form is disabled,
| the form will override submission behavior with
| ``enter_to_submit=False``.
|
| use_container_width : bool
| Whether to expand the button's width to fill its parent container.
| If ``use_container_width`` is ``False`` (default), Streamlit sizes
| the button to fit its contents. If ``use_container_width`` is
| ``True``, the width of the button matches its parent container.
|
| In both cases, if the contents of the button are wider than the
| parent container, the contents will line wrap.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``. For ``use_container_width=False``, use
| ``width="content"``.
|
| width : "content", "stretch", or int
| The width of the button. This can be one of the following:
|
| - ``"content"`` (default): The width of the button matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the button matches the width of the
| parent container.
| - An integer specifying the width in pixels: The button has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the button matches the width
| of the parent container.
|
| shortcut : str or None
| An optional keyboard shortcut that triggers the button. This can be
| one of the following strings:
|
| - A single alphanumeric key like ``"K"`` or ``"4"``.
| - A function key like ``"F11"``.
| - A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
| - Any of the above combined with modifiers. For example, you can use
| ``"Ctrl+K"`` or ``"Cmd+Shift+O"``.
|
| .. important::
| The keys ``"C"`` and ``"R"`` are reserved and can't be used,
| even with modifiers. Punctuation keys like ``"."`` and ``","``
| aren't currently supported.
|
| For a list of supported keys and modifiers, see the documentation
| for |st.button|_.
|
| .. |st.button| replace:: ``st.button``
| .. _st.button: https://docs.streamlit.io/develop/api-reference/widgets/st.button
|
| Returns
| -------
| bool
| True if the button was clicked.
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.graphviz_chart.GraphvizMixin:
|
| graphviz_chart(self, figure_or_dot: 'FigureOrDot', use_container_width: 'bool | None' = None, *, width: 'Width' = 'content', height: 'Height' = 'content') -> 'DeltaGenerator' from GraphvizMixin
| Display a graph using the dagre-d3 library.
|
| .. Important::
| You must install ``graphviz>=0.19.0`` to use this command. You can
| install all charting dependencies (except Bokeh) as an extra with
| Streamlit:
|
| .. code-block:: shell
|
| pip install streamlit[charts]
|
| Parameters
| ----------
| figure_or_dot : graphviz.dot.Graph, graphviz.dot.Digraph, graphviz.sources.Source, str
| The Graphlib graph object or dot string to display
|
| use_container_width : bool
| Whether to override the figure's native width with the width of
| the parent container. If ``use_container_width`` is ``False``
| (default), Streamlit sets the width of the chart to fit its contents
| according to the plotting library, up to the width of the parent
| container. If ``use_container_width`` is ``True``, Streamlit sets
| the width of the figure to match the width of the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``. For ``use_container_width=False``, use
| ``width="content"``.
|
| width : "content", "stretch", or int
| The width of the chart element. This can be one of the following:
|
| - ``"content"`` (default): The width of the element matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the element matches the width of the
| parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| height : "content", "stretch", or int
| The height of the chart element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| Examples
| --------
| >>> import streamlit as st
| >>> import graphviz
| >>>
| >>> # Create a graphlib graph object
| >>> graph = graphviz.Digraph()
| >>> graph.edge("run", "intr")
| >>> graph.edge("intr", "runbl")
| >>> graph.edge("runbl", "run")
| >>> graph.edge("run", "kernel")
| >>> graph.edge("kernel", "zombie")
| >>> graph.edge("kernel", "sleep")
| >>> graph.edge("kernel", "runmem")
| >>> graph.edge("sleep", "swap")
| >>> graph.edge("swap", "runswap")
| >>> graph.edge("runswap", "new")
| >>> graph.edge("runswap", "runmem")
| >>> graph.edge("new", "runmem")
| >>> graph.edge("sleep", "runmem")
| >>>
| >>> st.graphviz_chart(graph)
|
| Or you can render the chart from the graph using GraphViz's Dot
| language:
|
| >>> st.graphviz_chart('''
| digraph {
| run -> intr
| intr -> runbl
| runbl -> run
| run -> kernel
| kernel -> zombie
| kernel -> sleep
| kernel -> runmem
| sleep -> swap
| swap -> runswap
| runswap -> new
| runswap -> runmem
| new -> runmem
| sleep -> runmem
| }
| ''')
|
| .. output::
| https://doc-graphviz-chart.streamlit.app/
| height: 600px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.heading.HeadingMixin:
|
| header(self, body: 'SupportsStr', anchor: 'Anchor' = None, *, help: 'str | None' = None, divider: 'Divider' = False, width: 'Width' = 'stretch', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' from HeadingMixin
| Display text in header formatting.
|
| Parameters
| ----------
| body : str
| The text to display as GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| anchor : str or False
| The anchor name of the header that can be accessed with #anchor
| in the URL. If omitted, it generates an anchor using the body.
| If False, the anchor is not shown in the UI.
|
| help : str or None
| A tooltip that gets displayed next to the header. If this is
| ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| divider : bool, "blue", "green", "orange", "red", "violet", "yellow", "gray"/"grey", or "rainbow"
| Shows a colored divider below the header. If this is ``True``,
| successive headers will cycle through divider colors, except gray
| and rainbow. That is, the first header will have a blue line, the
| second header will have a green line, and so on. If this is a
| string, the color can be set to one of the following: blue, green,
| orange, red, violet, yellow, gray/grey, or rainbow.
|
| width : "stretch", "content", or int
| The width of the header element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| text_alignment : "left", "center", "right", or "justify"
| The horizontal alignment of the text within the element. This can
| be one of the following:
|
| - ``"left"`` (default): Text is aligned to the left edge.
| - ``"center"``: Text is centered.
| - ``"right"``: Text is aligned to the right edge.
| - ``"justify"``: Text is justified (stretched to fill the available
| width with the last line left-aligned).
|
| .. note::
| For text alignment to have a visible effect, the element's
| width must be wider than its content. If you use
| ``width="content"`` with short text, the alignment may not be
| noticeable.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.header("_Streamlit_ is :blue[cool] :sunglasses:")
| >>> st.header("This is a header with a divider", divider="gray")
| >>> st.header("These headers have rotating dividers", divider=True)
| >>> st.header("One", divider=True)
| >>> st.header("Two", divider=True)
| >>> st.header("Three", divider=True)
| >>> st.header("Four", divider=True)
|
| .. output::
| https://doc-header.streamlit.app/
| height: 600px
|
| subheader(self, body: 'SupportsStr', anchor: 'Anchor' = None, *, help: 'str | None' = None, divider: 'Divider' = False, width: 'Width' = 'stretch', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' from HeadingMixin
| Display text in subheader formatting.
|
| Parameters
| ----------
| body : str
| The text to display as GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| anchor : str or False
| The anchor name of the header that can be accessed with #anchor
| in the URL. If omitted, it generates an anchor using the body.
| If False, the anchor is not shown in the UI.
|
| help : str or None
| A tooltip that gets displayed next to the subheader. If this is
| ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| divider : bool, "blue", "green", "orange", "red", "violet", "yellow", "gray"/"grey", or "rainbow"
| Shows a colored divider below the header. If this is ``True``,
| successive headers will cycle through divider colors, except gray
| and rainbow. That is, the first header will have a blue line, the
| second header will have a green line, and so on. If this is a
| string, the color can be set to one of the following: blue, green,
| orange, red, violet, yellow, gray/grey, or rainbow.
|
| width : "stretch", "content", or int
| The width of the subheader element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| text_alignment : "left", "center", "right", or "justify"
| The horizontal alignment of the text within the element. This can
| be one of the following:
|
| - ``"left"`` (default): Text is aligned to the left edge.
| - ``"center"``: Text is centered.
| - ``"right"``: Text is aligned to the right edge.
| - ``"justify"``: Text is justified (stretched to fill the available
| width with the last line left-aligned).
|
| .. note::
| For text alignment to have a visible effect, the element's
| width must be wider than its content. If you use
| ``width="content"`` with short text, the alignment may not be
| noticeable.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.subheader("_Streamlit_ is :blue[cool] :sunglasses:")
| >>> st.subheader("This is a subheader with a divider", divider="gray")
| >>> st.subheader("These subheaders have rotating dividers", divider=True)
| >>> st.subheader("One", divider=True)
| >>> st.subheader("Two", divider=True)
| >>> st.subheader("Three", divider=True)
| >>> st.subheader("Four", divider=True)
|
| .. output::
| https://doc-subheader.streamlit.app/
| height: 500px
|
| title(self, body: 'SupportsStr', anchor: 'Anchor' = None, *, help: 'str | None' = None, width: 'Width' = 'stretch', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' from HeadingMixin
| Display text in title formatting.
|
| Each document should have a single `st.title()`, although this is not
| enforced.
|
| Parameters
| ----------
| body : str
| The text to display as GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| anchor : str or False
| The anchor name of the header that can be accessed with #anchor
| in the URL. If omitted, it generates an anchor using the body.
| If False, the anchor is not shown in the UI.
|
| help : str or None
| A tooltip that gets displayed next to the title. If this is
| ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| width : "stretch", "content", or int
| The width of the title element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| text_alignment : "left", "center", "right", or "justify"
| The horizontal alignment of the text within the element. This can
| be one of the following:
|
| - ``"left"`` (default): Text is aligned to the left edge.
| - ``"center"``: Text is centered.
| - ``"right"``: Text is aligned to the right edge.
| - ``"justify"``: Text is justified (stretched to fill the available
| width with the last line left-aligned).
|
| .. note::
| For text alignment to have a visible effect, the element's
| width must be wider than its content. If you use
| ``width="content"`` with short text, the alignment may not be
| noticeable.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.title("This is a title")
| >>> st.title("_Streamlit_ is :blue[cool] :sunglasses:")
|
| .. output::
| https://doc-title.streamlit.app/
| height: 220px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.help.HelpMixin:
|
| help(self, obj: 'Any' = <module 'streamlit' from 'C:\\Users\\Youse\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\streamlit\\__init__.py'>, *, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' from HelpMixin
| Display help and other information for a given object.
|
| Depending on the type of object that is passed in, this displays the
| object's name, type, value, signature, docstring, and member variables,
| methods — as well as the values/docstring of members and methods.
|
| Parameters
| ----------
| obj : any
| The object whose information should be displayed. If left
| unspecified, this call will display help for Streamlit itself.
| width : "stretch" or int
| The width of the help element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Examples
| --------
| Don't remember how to initialize a dataframe? Try this:
|
| >>> import streamlit as st
| >>> import pandas
| >>>
| >>> st.help(pandas.DataFrame)
|
| .. output::
| https://doc-string.streamlit.app/
| height: 700px
|
| Want to quickly check what data type is output by a certain function?
| Try:
|
| >>> import streamlit as st
| >>>
| >>> x = my_poorly_documented_function()
| >>> st.help(x)
|
| Want to quickly inspect an object? No sweat:
|
| >>> class Dog:
| >>> '''A typical dog.'''
| >>>
| >>> def __init__(self, breed, color):
| >>> self.breed = breed
| >>> self.color = color
| >>>
| >>> def bark(self):
| >>> return 'Woof!'
| >>>
| >>>
| >>> fido = Dog("poodle", "white")
| >>>
| >>> st.help(fido)
|
| .. output::
| https://doc-string1.streamlit.app/
| height: 300px
|
| And if you're using Magic, you can get help for functions, classes,
| and modules without even typing ``st.help``:
|
| >>> import streamlit as st
| >>> import pandas
| >>>
| >>> # Get help for Pandas read_csv:
| >>> pandas.read_csv
| >>>
| >>> # Get help for Streamlit itself:
| >>> st
|
| .. output::
| https://doc-string2.streamlit.app/
| height: 700px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.html.HtmlMixin:
|
| html(self, body: 'str | Path | SupportsStr | SupportsReprHtml', *, width: 'Width' = 'stretch', unsafe_allow_javascript: 'bool' = False) -> 'DeltaGenerator' from HtmlMixin
| Insert HTML into your app.
|
| Adding custom HTML to your app impacts safety, styling, and
| maintainability. We sanitize HTML with `DOMPurify
| <https://github.com/cure53/DOMPurify>`_, but inserting HTML remains a
| developer risk. Passing untrusted code to ``st.html`` or dynamically
| loading external code can increase the risk of vulnerabilities in your
| app.
|
| ``st.html`` content is **not** iframed. By default, JavaScript is
| ignored. To execute JavaScript contained in your HTML, set
| ``unsafe_allow_javascript=True``. Use this with caution and never pass
| untrusted input.
|
| Parameters
| ----------
| body : any
| The HTML code to insert. This can be one of the following:
|
| - A string of HTML code.
| - A path to a local file with HTML code. The path can be a ``str``
| or ``Path`` object. Paths can be absolute or relative to the
| working directory (where you execute ``streamlit run``).
| - Any object. If ``body`` is not a string or path, Streamlit will
| convert the object to a string. ``body._repr_html_()`` takes
| precedence over ``str(body)`` when available.
|
| If the resulting HTML content is empty, Streamlit will raise an
| error.
|
| If ``body`` is a path to a CSS file, Streamlit will wrap the CSS
| content in ``<style>`` tags automatically. When the resulting HTML
| content only contains style tags, Streamlit will send the content
| to the event container instead of the main container to avoid
| taking up space in the app.
|
| width : "stretch", "content", or int
| The width of the HTML element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| unsafe_allow_javascript : bool
| Whether to execute JavaScript contained in your HTML. If this is
| ``False`` (default), JavaScript is ignored. If this is ``True``,
| JavaScript is executed. Use this with caution and never pass
| untrusted input.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.html(
| ... "<p><span style='text-decoration: line-through double red;'>Oops</span>!</p>"
| ... )
|
| .. output::
| https://doc-html.streamlit.app/
| height: 300px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.iframe.IframeMixin:
|
| iframe(self, src: 'str | Path', *, width: "int | Literal['stretch', 'content']" = 'stretch', height: "int | Literal['stretch', 'content']" = 'content', tab_index: 'int | None' = None) -> 'DeltaGenerator' from IframeMixin
| Embed content in an iframe.
|
| ``st.iframe`` embeds external URLs, HTML content, or local files in an
| iframe. It auto-detects the input type and handles it appropriately.
|
| Parameters
| ----------
| src : str or Path
| The content to embed. This can be one of the following:
|
| - **Absolute URL**: A URL starting with ``http://``, ``https://``,
| or ``data:``. The URL is loaded directly in the iframe.
| - **Relative URL**: A path starting with ``/``, such as
| ``/app/static/report.html``. Useful for referencing files served
| via Streamlit's `static file serving
| <https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_.
| - **Local file path**: A path to a local file, either as a string
| or ``Path`` object. HTML files (``.html``, ``.htm``, ``.xhtml``)
| are read and embedded directly. Other files (PDF, images, SVG,
| etc.) are uploaded to Streamlit's media storage and rendered
| using the browser's native viewer.
| - **HTML string**: If ``src`` doesn't match any of the above
| patterns, it's treated as raw HTML and embedded directly in the
| iframe.
|
| width : int, "stretch", or "content"
| The width of the iframe. This can be one of the following:
|
| - ``"stretch"`` (default): The iframe fills the width of its
| container.
| - ``"content"``: The iframe matches the width of its content.
| - An ``int``: A fixed width in CSS pixels.
|
| height : int, "stretch", or "content"
| The height of the iframe. This can be one of the following:
|
| - ``"content"`` (default): The iframe automatically sizes to match
| its content height. For HTML strings and local HTML files,
| Streamlit measures the content height. For external URLs and
| non-HTML files, this falls back to 400px due to cross-origin
| restrictions.
| - ``"stretch"``: The iframe fills the available vertical space.
| Works best inside containers with defined heights.
| - An ``int``: A fixed height in CSS pixels.
|
| tab_index : int or None
| Controls keyboard navigation focus. This can be one of the
| following:
|
| - ``None`` (default): Browser default behavior.
| - ``-1``: Removes from tab order but allows programmatic focus.
| - ``0``: Adds to tab order in document position.
| - Positive ``int``: Adds to tab order at specified priority.
|
| For more information, see the `tabindex
| <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex>`_
| documentation on MDN.
|
| Examples
| --------
| Embed an external website:
|
| >>> import streamlit as st
| >>> st.iframe("https://docs.streamlit.io", height=600)
|
| Embed HTML content directly:
|
| >>> import streamlit as st
| >>> st.iframe(
| ... '''
| ... <style>body { font-family: sans-serif; padding: 1rem; }</style>
| ... <p>This is <strong>embedded HTML</strong>.</p>
| ... ''',
| ... height=100,
| ... )
|
| Embed a local HTML file:
|
| >>> import streamlit as st
| >>> from pathlib import Path
| >>> st.iframe(Path("reports/dashboard.html"), height=800)
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.image.ImageMixin:
|
| image(self, image: 'ImageOrImageList', caption: 'str | list[str] | None' = None, width: 'Width' = 'content', use_column_width: 'UseColumnWith' = None, clamp: 'bool' = False, channels: 'Channels' = 'RGB', output_format: 'ImageFormatOrAuto' = 'auto', *, use_container_width: 'bool | None' = None, link: 'str | None' = None) -> 'DeltaGenerator' from ImageMixin
| Display an image or list of images.
|
| Parameters
| ----------
| image : numpy.ndarray, BytesIO, str, Path, or list of these
| The image to display. This can be one of the following:
|
| - A URL (string) for a hosted image. Also supports
| ``/app/static/<asset>`` URLs for files served via
| `static file serving <https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_.
| - A path to a local image file. The path can be a ``str``
| or ``Path`` object. Paths can be absolute or relative to the
| working directory (where you execute ``streamlit run``).
| - An SVG string like ``<svg xmlns=...</svg>``.
| - A byte array defining an image. This includes monochrome images of
| shape (w,h) or (w,h,1), color images of shape (w,h,3), or RGBA
| images of shape (w,h,4), where w and h are the image width and
| height, respectively.
| - A list of any of the above. Streamlit displays the list as a
| row of images that overflow to additional rows as needed.
| caption : str or list of str
| Image caption(s). If this is ``None`` (default), no caption is
| displayed. If ``image`` is a list of multiple images, ``caption``
| must be a list of captions (one caption for each image) or
| ``None``.
|
| Captions can optionally contain GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
| width : "content", "stretch", or int
| The width of the image element. This can be one of the following:
|
| - ``"content"`` (default): The width of the element matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the element matches the width of the
| parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| When using an SVG image without a default width, use ``"stretch"``
| or an integer.
| use_column_width : "auto", "always", "never", or bool
| If "auto", set the image's width to its natural size,
| but do not exceed the width of the column.
| If "always" or True, set the image's width to the column width.
| If "never" or False, set the image's width to its natural size.
| Note: if set, `use_column_width` takes precedence over the `width` parameter.
|
| .. deprecated::
| ``use_column_width`` is deprecated and will be removed in a future
| release. Please use the ``width`` parameter instead.
|
| clamp : bool
| Whether to clamp image pixel values to a valid range (0-255 per
| channel). This is only used for byte array images; the parameter is
| ignored for image URLs and files. If this is ``False`` (default)
| and an image has an out-of-range value, a ``RuntimeError`` will be
| raised.
| channels : "RGB" or "BGR"
| The color format when ``image`` is an ``nd.array``. This is ignored
| for other image types. If this is ``"RGB"`` (default),
| ``image[:, :, 0]`` is the red channel, ``image[:, :, 1]`` is the
| green channel, and ``image[:, :, 2]`` is the blue channel. For
| images coming from libraries like OpenCV, you should set this to
| ``"BGR"`` instead.
| output_format : "JPEG", "PNG", or "auto"
| The output format to use when transferring the image data. If this
| is ``"auto"`` (default), Streamlit identifies the compression type
| based on the type and format of the image. Photos should use the
| ``"JPEG"`` format for lossy compression while diagrams should use
| the ``"PNG"`` format for lossless compression.
|
| use_container_width : bool
| Whether to override ``width`` with the width of the parent
| container. If ``use_container_width`` is ``False`` (default),
| Streamlit sets the image's width according to ``width``. If
| ``use_container_width`` is ``True``, Streamlit sets the width of
| the image to match the width of the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``. For ``use_container_width=False``, use
| ``width="content"``.
|
| link : str or None
| The URL to open when a user clicks on the image. This can be an
| external URL like ``"https://streamlit.io"`` or a relative path
| like ``"/my_page"``. If ``link`` is ``None`` (default), the
| image will not include a hyperlink.
|
| This parameter is only supported when displaying a single image.
|
| Examples
| --------
| >>> import streamlit as st
| >>> st.image("sunrise.jpg", caption="Sunrise by the mountains")
|
| .. output::
| https://doc-image.streamlit.app/
| height: 710px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.layouts.LayoutsMixin:
|
| columns(self, spec: 'SpecType', *, gap: 'Gap | None' = 'small', vertical_alignment: "Literal['top', 'center', 'bottom']" = 'top', border: 'bool' = False, width: 'WidthWithoutContent' = 'stretch') -> 'list[DeltaGenerator]' from LayoutsMixin
| Insert containers laid out as side-by-side columns.
|
| Inserts a number of multi-element containers laid out side-by-side and
| returns a list of container objects.
|
| To add elements to the returned containers, you can use the ``with`` notation
| (preferred) or just call methods directly on the returned object. See
| examples below.
|
| .. note::
| To follow best design practices and maintain a good appearance on
| all screen sizes, don't nest columns more than once.
|
| Parameters
| ----------
| spec : int or Iterable of numbers
| Controls the number and width of columns to insert. Can be one of:
|
| - An integer that specifies the number of columns. All columns have equal
| width in this case.
| - An Iterable of numbers (int or float) that specify the relative width of
| each column. E.g. ``[0.7, 0.3]`` creates two columns where the first
| one takes up 70% of the available with and the second one takes up 30%.
| Or ``[1, 2, 3]`` creates three columns where the second one is two times
| the width of the first one, and the third one is three times that width.
|
| gap : "xxsmall", "xsmall", "small", "medium", "large", "xlarge", "xxlarge", or None
| The size of the gap between the columns. This can be one of the
| following:
|
| - ``"xxsmall"``: 0.25rem gap between the columns.
| - ``"xsmall"``: 0.5rem gap between the columns.
| - ``"small"`` (default): 1rem gap between the columns.
| - ``"medium"``: 2rem gap between the columns.
| - ``"large"``: 4rem gap between the columns.
| - ``"xlarge"``: 6rem gap between the columns.
| - ``"xxlarge"``: 8rem gap between the columns.
| - ``None``: No gap between the columns.
|
| The rem unit is relative to the ``theme.baseFontSize``
| configuration option.
|
| vertical_alignment : "top", "center", or "bottom"
| The vertical alignment of the content inside the columns. The
| default is ``"top"``.
|
| border : bool
| Whether to show a border around the column containers. If this is
| ``False`` (default), no border is shown. If this is ``True``, a
| border is shown around each column.
|
| width : "stretch" or int
| The width of the column group. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the column group matches the
| width of the parent container.
| - An integer specifying the width in pixels: The column group has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the column group matches the
| width of the parent container.
|
| Returns
| -------
| list of containers
| A list of container objects.
|
| Examples
| --------
| **Example 1: Use context management**
|
| You can use the ``with`` statement to insert any element into a column:
|
| >>> import streamlit as st
| >>>
| >>> col1, col2, col3 = st.columns(3)
| >>>
| >>> with col1:
| ... st.header("A cat")
| ... st.image("https://static.streamlit.io/examples/cat.jpg")
| >>>
| >>> with col2:
| ... st.header("A dog")
| ... st.image("https://static.streamlit.io/examples/dog.jpg")
| >>>
| >>> with col3:
| ... st.header("An owl")
| ... st.image("https://static.streamlit.io/examples/owl.jpg")
|
| .. output::
| https://doc-columns1.streamlit.app/
| height: 620px
|
|
| **Example 2: Use commands as container methods**
|
| You can just call methods directly on the returned objects:
|
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = rng(0).standard_normal((10, 1))
| >>> col1, col2 = st.columns([3, 1])
| >>>
| >>> col1.subheader("A wide column with a chart")
| >>> col1.line_chart(df)
| >>>
| >>> col2.subheader("A narrow column with the data")
| >>> col2.write(df)
|
| .. output::
| https://doc-columns2.streamlit.app/
| height: 550px
|
| **Example 3: Align widgets**
|
| Use ``vertical_alignment="bottom"`` to align widgets.
|
| >>> import streamlit as st
| >>>
| >>> left, middle, right = st.columns(3, vertical_alignment="bottom")
| >>>
| >>> left.text_input("Write something")
| >>> middle.button("Click me", use_container_width=True)
| >>> right.checkbox("Check me")
|
| .. output::
| https://doc-columns-bottom-widgets.streamlit.app/
| height: 200px
|
| **Example 4: Use vertical alignment to create grids**
|
| Adjust vertical alignment to customize your grid layouts.
|
| >>> import streamlit as st
| >>>
| >>> vertical_alignment = st.selectbox(
| >>> "Vertical alignment", ["top", "center", "bottom"], index=2
| >>> )
| >>>
| >>> left, middle, right = st.columns(3, vertical_alignment=vertical_alignment)
| >>> left.image("https://static.streamlit.io/examples/cat.jpg")
| >>> middle.image("https://static.streamlit.io/examples/dog.jpg")
| >>> right.image("https://static.streamlit.io/examples/owl.jpg")
|
| .. output::
| https://doc-columns-vertical-alignment.streamlit.app/
| height: 600px
|
| **Example 5: Add borders**
|
| Add borders to your columns instead of nested containers for consistent
| heights.
|
| >>> import streamlit as st
| >>>
| >>> left, middle, right = st.columns(3, border=True)
| >>>
| >>> left.markdown("Lorem ipsum " * 10)
| >>> middle.markdown("Lorem ipsum " * 5)
| >>> right.markdown("Lorem ipsum ")
|
| .. output::
| https://doc-columns-borders.streamlit.app/
| height: 250px
|
| container(self, *, border: 'bool | None' = None, key: 'Key | None' = None, width: 'Width' = 'stretch', height: 'Height' = 'content', horizontal: 'bool' = False, horizontal_alignment: 'HorizontalAlignment' = 'left', vertical_alignment: 'VerticalAlignment' = 'top', gap: 'Gap | None' = 'small', autoscroll: 'bool | None' = None) -> 'DeltaGenerator' from LayoutsMixin
| Insert a multi-element container.
|
| Inserts an invisible container into your app that can be used to hold
| multiple elements. This allows you to, for example, insert multiple
| elements into your app out of order.
|
| To add elements to the returned container, you can use the ``with``
| notation (preferred) or just call commands directly on the returned
| object. See examples below.
|
| Parameters
| ----------
| border : bool or None
| Whether to show a border around the container. If ``None`` (default), a
| border is shown if the container is set to a fixed height and not
| shown otherwise.
|
| key : str or None
| An optional string to give this element a stable identity. If
| this is ``None`` (default), the element's identity will be
| determined based on the values of the other parameters.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| width : "stretch", "content", or int
| The width of the container. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the container matches the
| width of the parent container.
| - ``"content"``: The width of the container matches the width of
| its content.
| - An integer specifying the width in pixels: The container has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the container matches the width
| of the parent container.
|
| height : "content", "stretch", or int
| The height of the container. This can be one of the following:
|
| - ``"content"`` (default): The height of the container matches the
| height of its content.
| - ``"stretch"``: The height of the container matches the height of
| its content or the height of the parent container, whichever is
| larger. If the container is not in a parent container, the height
| of the container matches the height of its content.
| - An integer specifying the height in pixels: The container has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| .. note::
| Use scrolling containers sparingly. If you use scrolling
| containers, avoid heights that exceed 500 pixels. Otherwise,
| the scroll surface of the container might cover the majority of
| the screen on mobile devices, which makes it hard to scroll the
| rest of the app.
|
| horizontal : bool
| Whether to use horizontal flexbox layout. If this is ``False``
| (default), the container's elements are laid out vertically. If
| this is ``True``, the container's elements are laid out
| horizontally and will overflow to the next line if they don't fit
| within the container's width.
|
| horizontal_alignment : "left", "center", "right", or "distribute"
| The horizontal alignment of the elements inside the container. This
| can be one of the following:
|
| - ``"left"`` (default): Elements are aligned to the left side of
| the container.
| - ``"center"``: Elements are horizontally centered inside the
| container.
| - ``"right"``: Elements are aligned to the right side of the
| container.
| - ``"distribute"``: Elements are distributed evenly in the
| container. This increases the horizontal gap between elements to
| fill the width of the container. A standalone element is aligned
| to the left.
|
| When ``horizontal`` is ``False``, ``"distribute"`` aligns the
| elements the same as ``"left"``.
|
| vertical_alignment : "top", "center", "bottom", or "distribute"
| The vertical alignment of the elements inside the container. This
| can be one of the following:
|
| - ``"top"`` (default): Elements are aligned to the top of the
| container.
| - ``"center"``: Elements are vertically centered inside the
| container.
| - ``"bottom"``: Elements are aligned to the bottom of the
| container.
| - ``"distribute"``: Elements are distributed evenly in the
| container. This increases the vertical gap between elements to
| fill the height of the container. A standalone element is aligned
| to the top.
|
| When ``horizontal`` is ``True``, ``"distribute"`` aligns the
| elements the same as ``"top"``.
|
| gap : "xxsmall", "xsmall", "small", "medium", "large", "xlarge", "xxlarge", or None
| The minimum gap size between the elements inside the container.
| This can be one of the following:
|
| - ``"xxsmall"``: 0.25rem gap between the elements.
| - ``"xsmall"``: 0.5rem gap between the elements.
| - ``"small"`` (default): 1rem gap between the elements.
| - ``"medium"``: 2rem gap between the elements.
| - ``"large"``: 4rem gap between the elements.
| - ``"xlarge"``: 6rem gap between the elements.
| - ``"xxlarge"``: 8rem gap between the elements.
| - ``None``: No gap between the elements.
|
| The rem unit is relative to the ``theme.baseFontSize``
| configuration option.
|
| The minimum gap applies to both the vertical and horizontal gaps
| between the elements. Elements may have larger gaps in one
| direction if you use a distributed horizontal alignment or fixed
| height.
|
| autoscroll : bool or None
| Whether to automatically scroll to the bottom when new content is
| added. This only has an effect when the container has a fixed
| height (scrolling enabled). If this is ``None`` (default),
| auto-scroll is enabled when the container has a fixed height and
| contains |st.chat_message|_ elements. If this is ``True``,
| auto-scroll is always enabled for containers with fixed height.
| If this is ``False``, auto-scroll is always disabled.
|
| .. |st.chat_message| replace:: ``st.chat_message``
| .. _st.chat_message: https://docs.streamlit.io/develop/api-reference/chat/st.chat_message
|
| Examples
| --------
| **Example 1: Inserting elements using ``with`` notation**
|
| You can use the ``with`` statement to insert any element into a
| container.
|
| >>> import streamlit as st
| >>>
| >>> with st.container():
| ... st.write("This is inside the container")
| ...
| ... # You can call any Streamlit command, including custom components:
| ... st.bar_chart(np.random.randn(50, 3))
| >>>
| >>> st.write("This is outside the container")
|
| .. output::
| https://doc-container1.streamlit.app/
| height: 520px
|
| **Example 2: Inserting elements out of order**
|
| When you create a container, its position in the app remains fixed and
| you can add elements to it at any time. This allows you to insert
| elements out of order in your app. You can also write to the container
| by calling commands directly on the container object.
|
| >>> import streamlit as st
| >>>
| >>> container = st.container(border=True)
| >>> container.write("This is inside the container")
| >>> st.write("This is outside the container")
| >>>
| >>> container.write("This is inside too")
|
| .. output::
| https://doc-container2.streamlit.app/
| height: 300px
|
| **Example 3: Grid layout with columns and containers**
|
| You can create a grid with a fixed number of elements per row by using
| columns and containers.
|
| >>> import streamlit as st
| >>>
| >>> row1 = st.columns(3)
| >>> row2 = st.columns(3)
| >>>
| >>> for col in row1 + row2:
| >>> tile = col.container(height=120)
| >>> tile.title(":balloon:")
|
| .. output::
| https://doc-container3.streamlit.app/
| height: 350px
|
| **Example 4: Vertically scrolling container**
|
| You can create a vertically scrolling container by setting a fixed
| height.
|
| >>> import streamlit as st
| >>>
| >>> long_text = "Lorem ipsum. " * 1000
| >>>
| >>> with st.container(height=300):
| >>> st.markdown(long_text)
|
| .. output::
| https://doc-container4.streamlit.app/
| height: 400px
|
| **Example 5: Horizontal container**
|
| You can create a row of widgets using a horizontal container. Use
| ``horizontal_alignment`` to specify the alignment of the elements.
|
| >>> import streamlit as st
| >>>
| >>> flex = st.container(horizontal=True, horizontal_alignment="right")
| >>>
| >>> for card in range(3):
| >>> flex.button(f"Button {card + 1}")
|
| .. output::
| https://doc-container5.streamlit.app/
| height: 250px
|
| expander(self, label: 'str', expanded: 'bool' = False, *, key: 'Key | None' = None, icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', on_change: "Literal['ignore', 'rerun'] | WidgetCallback" = 'ignore', args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None) -> 'ExpanderContainer' from LayoutsMixin
| Insert a multi-element container that can be expanded/collapsed.
|
| Inserts a container into your app that can be used to hold multiple elements
| and can be expanded or collapsed by the user. When collapsed, all that is
| visible is the provided label.
|
| To add elements to the returned container, you can use the ``with`` notation
| (preferred) or just call methods directly on the returned object. See
| examples below.
|
| By default, all content within the expander is computed and sent to the
| frontend, even if the expander is closed. To enable lazy execution
| where content only runs when the expander is open, use
| ``on_change="rerun"`` or pass a callable to ``on_change``. The ``.open``
| property indicates whether the expander is currently open, letting you
| conditionally render expensive content.
|
| .. note::
|
| To follow best design practices and maintain a good appearance on
| all screen sizes, don't nest expanders.
|
| Parameters
| ----------
| label : str
| A string to use as the header for the expander. The label can optionally
| contain GitHub-flavored Markdown of the following types: Bold, Italics,
| Strikethroughs, Inline Code, Links, and Images. Images display like
| icons, with a max height equal to the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| expanded : bool
| If True, initializes the expander in "expanded" state. Defaults to
| False (collapsed).
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key.
|
| When ``on_change`` is set to ``"rerun"`` or a callable, setting a
| key lets you read or update the expanded state via
| ``st.session_state[key]``. For more details, see `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| icon : str, None
| An optional emoji or icon to display next to the expander label. If ``icon``
| is ``None`` (default), no icon is displayed. If ``icon`` is a
| string, the following options are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols \
| <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| width : "stretch" or int
| The width of the expander container. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the container matches the
| width of the parent container.
| - An integer specifying the width in pixels: The container has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the container matches the width
| of the parent container.
|
| on_change : "ignore", "rerun", or callable
| How the expander should respond when the user expands or
| collapses it. This controls whether the expander tracks state
| and triggers reruns. ``on_change`` can be one of the following:
|
| - ``"ignore"`` (default): The expander doesn't track state. All
| expander content runs regardless of whether the expander is open
| or closed. The ``.open`` attribute of the expander container
| returns ``None``.
|
| - ``"rerun"``: The expander tracks state. Streamlit reruns the app
| when the user expands or collapses the expander. The ``.open``
| attribute of the expander container returns the current state,
| which is ``True`` if the expander is open and ``False`` if it's
| closed. This lets you skip expensive work when the expander is
| closed.
|
| - A callable: The expander tracks state. Streamlit executes the
| callable as a callback function and reruns the app when the user
| expands or collapses the expander. The ``.open`` attribute of the
| expander container returns its state like when
| ``on_change="rerun"``. If you need to access the current state
| inside your callback, fetch it through Session State.
|
| When the expander tracks state, it can't be used inside Streamlit
| cache-decorated functions.
|
| args : list or tuple or None
| An optional list or tuple of args to pass to the ``on_change``
| callback.
|
| kwargs : dict or None
| An optional dict of kwargs to pass to the ``on_change``
| callback.
|
| Returns
| -------
| ExpanderContainer
| An ``ExpanderContainer`` object with an ``.open`` property to return
| the current state of the expander if the expander tracks state.
|
| Examples
| --------
| **Example 1: Use context management**
| You can use the ``with`` notation to insert any element into an expander
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| st.bar_chart({"data": [1, 5, 2, 6, 2, 1]})
|
| with st.expander("See explanation"):
| st.write('''
| The chart above shows some numbers I picked for you.
| I rolled actual dice for these, so they're *guaranteed* to
| be random.
| ''')
| st.image("https://static.streamlit.io/examples/dice.jpg")
|
| .. output::
| https://doc-expander.streamlit.app/
| height: 750px
|
| **Example 2: Call methods directly**
|
| You can call methods directly on the returned object:
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| st.bar_chart({"data": [1, 5, 2, 6, 2, 1]})
|
| expander = st.expander("See explanation")
| expander.write('''
| The chart above shows some numbers I picked for you.
| I rolled actual dice for these, so they're *guaranteed* to
| be random.
| ''')
| expander.image("https://static.streamlit.io/examples/dice.jpg")
|
| .. output::
| https://doc-expander.streamlit.app/
| height: 750px
|
| **Example 3: Programmatically control the expander state**
|
| You can use a key to programmatically control the expander state or
| access the state in callbacks. You must set the ``on_change`` parameter
| for the expander to track state.
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
|
| def toggle_expander():
| st.session_state.summary = not st.session_state.summary
|
| def on_expander_change():
| if st.session_state.summary:
| st.toast("You opened the expander.")
| else:
| st.toast("You closed the expander.")
|
|
| with st.expander("Open expander", on_change=on_expander_change, key="summary"):
| st.write("This is the expander")
|
| st.button("Toggle expander", on_click=toggle_expander)
|
| .. output::
| https://doc-expander-callback.streamlit.app/
| height: 300px
|
| popover(self, label: 'str', *, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', help: 'str | None' = None, icon: 'str | None' = None, disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', key: 'Key | None' = None, on_change: "Literal['ignore', 'rerun'] | WidgetCallback" = 'ignore', args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None) -> 'PopoverContainer' from LayoutsMixin
| Insert a popover container.
|
| Inserts a multi-element container as a popover. It consists of a button-like
| element and a container that opens when the button is clicked.
|
| To add elements to the returned container, you can use the "with"
| notation (preferred) or just call methods directly on the returned object.
| See examples below.
|
| Interacting with widgets inside of an open popover will rerun the app
| while keeping the popover open. Clicking outside of the popover will
| close it.
|
| By default, all content within the popover is computed and sent to the
| frontend, and the app doesn't rerun when the popover is opened or
| closed. To enable lazy execution where content only runs when the
| popover is open, use ``on_change="rerun"`` or pass a callable to
| ``on_change``. The ``.open`` property indicates whether the popover is
| currently open, letting you conditionally render expensive content.
|
| .. note::
| To follow best design practices, don't nest popovers.
|
| Parameters
| ----------
| label : str
| The label of the button that opens the popover container.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| help : str or None
| A tooltip that gets displayed when the popover button is hovered
| over. If this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| type : "primary", "secondary", or "tertiary"
| An optional string that specifies the button type. This can be one
| of the following:
|
| - ``"primary"``: The button's background is the app's primary color
| for additional emphasis.
| - ``"secondary"`` (default): The button's background coordinates
| with the app's background color for normal emphasis.
| - ``"tertiary"``: The button is plain text without a border or
| background for subtlety.
|
| icon : str
| An optional emoji or icon to display next to the button label. If ``icon``
| is ``None`` (default), no icon is displayed. If ``icon`` is a
| string, the following options are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols \
| <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| disabled : bool
| An optional boolean that disables the popover button if set to
| ``True``. The default is ``False``.
|
| use_container_width : bool
| Whether to expand the button's width to fill its parent container.
| If ``use_container_width`` is ``False`` (default), Streamlit sizes
| the button to fit its content. If ``use_container_width`` is
| ``True``, the width of the button matches its parent container.
|
| In both cases, if the content of the button is wider than the
| parent container, the content will line wrap.
|
| The popover container's minimum width matches the width of its
| button. The popover container may be wider than its button to fit
| the container's content.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``. For ``use_container_width=False``, use
| ``width="content"``.
|
| width : int, "stretch", or "content"
| The width of the button. This can be one of the following:
|
| - ``"content"`` (default): The width of the button matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the button matches the width of the
| parent container.
| - An integer specifying the width in pixels: The button has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the button matches the width
| of the parent container.
|
| The popover container's minimum width matches the width of its
| button. The popover container may be wider than its button to fit
| the container's contents.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key.
|
| When ``on_change`` is set to ``"rerun"`` or a callable, setting a
| key lets you read or update the open/closed state via
| ``st.session_state[key]``. For more details, see `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| on_change : "ignore", "rerun", or callable
| How the popover should respond when the user opens or closes it.
| This controls whether the popover tracks state and triggers
| reruns. ``on_change`` can be one of the following values:
|
| - ``"ignore"`` (default): The popover doesn't track state. All
| popover content runs regardless of whether the popover is open or
| closed. The ``.open`` attribute of the popover container returns
| ``None``.
|
| - ``"rerun"``: The popover tracks state. Streamlit reruns the app
| when the user opens or closes the popover. The ``.open``
| attribute of the popover container returns the current state,
| which is ``True`` if the popover is open and ``False`` if it's
| closed. This lets you skip expensive work when the popover is
| closed.
|
| - A callable: The popover tracks state. Streamlit executes the
| callable as a callback function and reruns the app when the user
| opens or closes the popover. The ``.open`` attribute of the
| popover container returns its state like when
| ``on_change="rerun"``. If you need to access the current state
| inside your callback, fetch it through Session State.
|
| When the popover tracks state, it can't be used inside Streamlit
| cache-decorated functions.
|
| args : list or tuple or None
| An optional list or tuple of args to pass to the ``on_change``
| callback.
|
| kwargs : dict or None
| An optional dict of kwargs to pass to the ``on_change`` callback.
|
| Returns
| -------
| PopoverContainer
| A ``PopoverContainer`` object with an ``.open`` property to return
| the current state of the popover if the popover tracks state.
|
| Examples
| --------
| **Example 1: Use context management**
| You can use the ``with`` notation to insert any element into a popover:
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| with st.popover("Open popover"):
| st.markdown("Hello World 👋")
| name = st.text_input("What's your name?")
|
| st.write("Your name:", name)
|
| .. output::
| https://doc-popover.streamlit.app/
| height: 400px
|
| **Example 2: Call methods directly**
|
| You can call methods directly on the returned object:
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| popover = st.popover("Filter items")
| red = popover.checkbox("Show red items.", True)
| blue = popover.checkbox("Show blue items.", True)
|
| if red:
| st.write(":red[This is a red item.]")
| if blue:
| st.write(":blue[This is a blue item.]")
|
| .. output::
| https://doc-popover2.streamlit.app/
| height: 400px
|
| **Example 3: Programmatically control the popover state**
|
| You can use a key to programmatically control the popover state or
| access the state in callbacks. You must set the ``on_change`` parameter
| for the popover to track state.
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
|
| def toggle_popover():
| st.session_state.drawer = not st.session_state.drawer
|
| def on_popover_change():
| if st.session_state.drawer:
| st.toast("You opened the popover.")
| else:
| st.toast("You closed the popover.")
|
|
| with st.popover("Open popover", on_change=on_popover_change, key="drawer"):
| st.write("This is the popover")
| st.button("Close popover", on_click=toggle_popover)
|
| st.button("Open popover", on_click=toggle_popover)
|
| .. output::
| https://doc-popover-callback.streamlit.app/
| height: 300px
|
| status(self, label: 'str', *, expanded: 'bool' = False, state: "Literal['running', 'complete', 'error']" = 'running', width: 'WidthWithoutContent' = 'stretch') -> 'StatusContainer' from LayoutsMixin
| Insert a status container to display output from long-running tasks.
|
| Inserts a container into your app that is typically used to show the status and
| details of a process or task. The container can hold multiple elements and can
| be expanded or collapsed by the user similar to ``st.expander``.
| When collapsed, all that is visible is the status icon and label.
|
| The label, state, and expanded state can all be updated by calling ``.update()``
| on the returned object. To add elements to the returned container, you can
| use ``with`` notation (preferred) or just call methods directly on the returned
| object.
|
| By default, ``st.status()`` initializes in the "running" state. When called using
| ``with`` notation, it automatically updates to the "complete" state at the end
| of the "with" block. See examples below for more details.
|
| .. note::
| All content within the status container is computed and sent to the
| frontend, even if the status container is closed.
|
| To follow best design practices and maintain a good appearance on
| all screen sizes, don't nest status containers.
|
| Parameters
| ----------
| label : str
| The initial label of the status container. The label can optionally
| contain GitHub-flavored Markdown of the following types: Bold, Italics,
| Strikethroughs, Inline Code, Links, and Images. Images display like
| icons, with a max height equal to the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| expanded : bool
| If True, initializes the status container in "expanded" state. Defaults to
| False (collapsed).
|
| state : "running", "complete", or "error"
| The initial state of the status container which determines which icon is
| shown:
|
| - ``running`` (default): A spinner icon is shown.
| - ``complete``: A checkmark icon is shown.
| - ``error``: An error icon is shown.
|
| width : "stretch" or int
| The width of the status container. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the container matches the
| width of the parent container.
| - An integer specifying the width in pixels: The container has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the container matches the width
| of the parent container.
|
| Returns
| -------
| StatusContainer
| A mutable status container that can hold multiple elements. The label, state,
| and expanded state can be updated after creation via ``.update()``.
|
| Examples
| --------
| You can use the ``with`` notation to insert any element into an status container:
|
| >>> import time
| >>> import streamlit as st
| >>>
| >>> with st.status("Downloading data..."):
| ... st.write("Searching for data...")
| ... time.sleep(2)
| ... st.write("Found URL.")
| ... time.sleep(1)
| ... st.write("Downloading data...")
| ... time.sleep(1)
| >>>
| >>> st.button("Rerun")
|
| .. output::
| https://doc-status.streamlit.app/
| height: 300px
|
| You can also use ``.update()`` on the container to change the label, state,
| or expanded state:
|
| >>> import time
| >>> import streamlit as st
| >>>
| >>> with st.status("Downloading data...", expanded=True) as status:
| ... st.write("Searching for data...")
| ... time.sleep(2)
| ... st.write("Found URL.")
| ... time.sleep(1)
| ... st.write("Downloading data...")
| ... time.sleep(1)
| ... status.update(
| ... label="Download complete!", state="complete", expanded=False
| ... )
| >>>
| >>> st.button("Rerun")
|
| .. output::
| https://doc-status-update.streamlit.app/
| height: 300px
|
| tabs(self, tabs: 'Sequence[str]', *, width: 'WidthWithoutContent' = 'stretch', default: 'str | None' = None, key: 'Key | None' = None, on_change: "Literal['ignore', 'rerun'] | WidgetCallback" = 'ignore', args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None) -> 'Sequence[TabContainer]' from LayoutsMixin
| Insert containers separated into tabs.
|
| Inserts a number of multi-element containers as tabs.
| Tabs are a navigational element that allows users to easily
| move between groups of related content.
|
| To add elements to the returned containers, you can use the ``with`` notation
| (preferred) or just call methods directly on the returned object. See
| the examples below.
|
| By default, all tab content is computed and sent to the frontend
| regardless of which tab is selected. To enable lazy execution where
| only the selected tab's content runs, use ``on_change="rerun"`` or
| pass a callable to ``on_change``. Each tab's ``.open`` property
| indicates whether it is the currently selected tab, letting you
| conditionally render expensive content.
|
| Parameters
| ----------
| tabs : list of str
| Creates a tab for each string in the list. The first tab is selected
| by default. The string is used as the name of the tab and can
| optionally contain GitHub-flavored Markdown of the following types:
| Bold, Italics, Strikethroughs, Inline Code, Links, and Images.
| Images display like icons, with a max height equal to the font
| height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| width : "stretch" or int
| The width of the tab container. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the container matches the
| width of the parent container.
| - An integer specifying the width in pixels: The container has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the container matches the width
| of the parent container.
|
| default : str or None
| The default tab to select. If this is ``None`` (default), the first
| tab is selected. If this is a string, it must be one of the tab
| labels. If two tabs have the same label as ``default``, the first
| one is selected.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key.
|
| When ``on_change`` is set to ``"rerun"`` or a callable, setting a
| key lets you read or update the active tab label via
| ``st.session_state[key]``. For more details, see `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| on_change : "ignore", "rerun", callable, or None
| How the tabs should respond when the user switches tabs. This
| controls whether tabs track state and trigger reruns. ``on_change``
| can be one of the following values:
|
| - ``"ignore"`` (default): The tabs don't track state. All tab content
| runs regardless of which tab is selected. The ``.open`` attribute
| of each tab container returns ``None`` for all tabs.
|
| - ``"rerun"``: The tabs track state. Streamlit reruns the app when
| the user switches tabs. The ``.open`` attribute of each tab
| container returns its current state, which is ``True`` if it is
| selected and ``False`` if it isn't selected. This lets you skip
| expensive work in hidden tabs.
|
| - A callable: The tabs track state. Streamlit executes the callable
| as a callback function and reruns the app when the user switches
| tabs. The ``.open`` attribute of each tab container returns its
| state like when ``on_change="rerun"``. If you need to access
| label of the current tab inside your callback, fetch it through
| Session State.
|
| When the tabs track state, they can't be used inside
| Streamlit cache-decorated functions.
|
| args : list or tuple or None
| An optional list or tuple of args to pass to the ``on_change``
| callback.
|
| kwargs : dict or None
| An optional dict of kwargs to pass to the ``on_change`` callback.
|
| Returns
| -------
| Sequence of TabContainers
| A sequence of ``TabContainer`` objects with ``.open`` properties to
| return the current state of the tabs if the tabs track state.
|
| Examples
| --------
| *Example 1: Use context management*
|
| You can use ``with`` notation to insert any element into a tab:
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| tab1, tab2, tab3 = st.tabs(["Cat", "Dog", "Owl"])
|
| with tab1:
| st.header("A cat")
| st.image("https://static.streamlit.io/examples/cat.jpg", width=200)
| with tab2:
| st.header("A dog")
| st.image("https://static.streamlit.io/examples/dog.jpg", width=200)
| with tab3:
| st.header("An owl")
| st.image("https://static.streamlit.io/examples/owl.jpg", width=200)
|
| .. output::
| https://doc-tabs1.streamlit.app/
| height: 620px
|
| *Example 2: Call methods directly*
|
| You can call methods directly on the returned objects:
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
| from numpy.random import default_rng as rng
|
| df = rng(0).standard_normal((10, 1))
|
| tab1, tab2 = st.tabs(["📈 Chart", "🗃 Data"])
|
| tab1.subheader("A tab with a chart")
| tab1.line_chart(df)
|
| tab2.subheader("A tab with the data")
| tab2.write(df)
|
| .. output::
| https://doc-tabs2.streamlit.app/
| height: 700px
|
| *Example 3: Set the default tab and style the tab labels*
|
| Use the ``default`` parameter to set the default tab. You can also use
| Markdown in the tab labels.
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| tab1, tab2, tab3 = st.tabs(
| [":cat: Cat", ":dog: Dog", ":rainbow[Owl]"], default=":rainbow[Owl]"
| )
|
| with tab1:
| st.header("A cat")
| st.image("https://static.streamlit.io/examples/cat.jpg", width=200)
| with tab2:
| st.header("A dog")
| st.image("https://static.streamlit.io/examples/dog.jpg", width=200)
| with tab3:
| st.header("An owl")
| st.image("https://static.streamlit.io/examples/owl.jpg", width=200)
|
| .. output::
| https://doc-tabs3.streamlit.app/
| height: 620px
|
| **Example 4: Programmatically control the tab state**
|
| You can use a key to programmatically control the tab state or access
| the state in callbacks. You must set the ``on_change`` parameter for
| the tabs to track state.
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
|
| def switch_tab(tab):
| st.session_state.animal = tab
|
|
| def on_tab_change():
| st.toast(f"You opened the {st.session_state.animal} tab.")
|
|
| cat, dog, owl = st.tabs(
| ["Cat", "Dog", "Owl"], on_change=on_tab_change, key="animal"
| )
|
| if cat.open:
| with cat:
| st.write("This is the cat")
| if dog.open:
| with dog:
| st.write("This is the dog")
| if owl.open:
| with owl:
| st.write("This is the owl")
|
| with st.container(horizontal=True):
| st.button("Cat", on_click=switch_tab, args=("Cat",))
| st.button("Dog", on_click=switch_tab, args=("Dog",))
| st.button("Owl", on_click=switch_tab, args=("Owl",))
|
| .. output::
| https://doc-tabs-callback.streamlit.app/
| height: 300px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.markdown.MarkdownMixin:
|
| badge(self, label: 'str', *, icon: 'str | None' = None, color: "Literal['red', 'orange', 'yellow', 'blue', 'green', 'violet', 'gray', 'grey', 'primary']" = 'blue', width: 'Width' = 'content', help: 'str | None' = None) -> 'DeltaGenerator' from MarkdownMixin
| Display a colored badge with an icon and label.
|
| This is a thin wrapper around the color-badge Markdown directive.
| The following are equivalent:
|
| - ``st.markdown(":blue-badge[Home]")``
| - ``st.badge("Home", color="blue")``
|
| .. note::
| You can insert badges everywhere Streamlit supports Markdown by
| using the color-badge Markdown directive. See ``st.markdown`` for
| more information.
|
| Parameters
| ----------
| label : str
| The label to display in the badge. The label can optionally contain
| GitHub-flavored Markdown of the following types: Bold, Italics,
| Strikethroughs, Inline Code.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives. Because this command escapes square
| brackets (``[ ]``) in this parameter, any directive requiring
| square brackets is not supported.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| icon : str or None
| An optional emoji or icon to display next to the badge label. If
| ``icon`` is ``None`` (default), no icon is displayed. If ``icon``
| is a string, the following options are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| color : str
| The color to use for the badge. This defaults to ``"blue"``.
|
| This can be one of the following supported colors: red, orange,
| yellow, blue, green, violet, gray/grey, or primary. If you use
| ``"primary"``, Streamlit will use the default primary accent color
| unless you set the ``theme.primaryColor`` configuration option.
|
| width : "content", "stretch", or int
| The width of the badge element. This can be one of the following:
|
| - ``"content"`` (default): The width of the element matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the element matches the width of the
| parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| help : str or None
| A tooltip to display when hovering over the badge. If this is
| ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| Examples
| --------
| Create standalone badges with ``st.badge`` (with or without icons). If
| you want to have multiple, side-by-side badges, you can use the
| Markdown directive in ``st.markdown``.
|
| >>> import streamlit as st
| >>>
| >>> st.badge("New")
| >>> st.badge("Success", icon=":material/check:", color="green")
| >>>
| >>> st.markdown(
| >>> ":violet-badge[:material/star: Favorite] :orange-badge[⚠️ Needs review] :gray-badge[Deprecated]"
| >>> )
|
| .. output::
| https://doc-badge.streamlit.app/
| height: 220px
|
| caption(self, body: 'SupportsStr', unsafe_allow_html: 'bool' = False, *, help: 'str | None' = None, width: 'Width' = 'stretch', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' from MarkdownMixin
| Display text in small font.
|
| This should be used for captions, asides, footnotes, sidenotes, and
| other explanatory text.
|
| Parameters
| ----------
| body : str
| The text to display as GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| unsafe_allow_html : bool
| Whether to render HTML within ``body``. If this is ``False``
| (default), any HTML tags found in ``body`` will be escaped and
| therefore treated as raw text. If this is ``True``, any HTML
| expressions within ``body`` will be rendered.
|
| Adding custom HTML to your app impacts safety, styling, and
| maintainability.
|
| .. note::
| If you only want to insert HTML or CSS without Markdown text,
| we recommend using ``st.html`` instead.
|
| help : str or None
| A tooltip that gets displayed next to the caption. If this is
| ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| width : "stretch", "content", or int
| The width of the caption element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| text_alignment : "left", "center", "right", or "justify"
| The horizontal alignment of the text within the element. This can
| be one of the following:
|
| - ``"left"`` (default): Text is aligned to the left edge.
| - ``"center"``: Text is centered.
| - ``"right"``: Text is aligned to the right edge.
| - ``"justify"``: Text is justified (stretched to fill the available
| width with the last line left-aligned).
|
| .. note::
| For text alignment to have a visible effect, the element's
| width must be wider than its content. If you use
| ``width="content"`` with short text, the alignment may not be
| noticeable.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.caption("This is a string that explains something above.")
| >>> st.caption("A caption with _italics_ :blue[colors] and emojis :sunglasses:")
|
| divider(self, *, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' from MarkdownMixin
| Display a horizontal rule.
|
| .. note::
| You can achieve the same effect with st.write("---") or
| even just "---" in your script (via magic).
|
| Parameters
| ----------
| width : "stretch" or int
| The width of the divider element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.divider()
|
| latex(self, body: 'SupportsStr | sympy.Expr', *, help: 'str | None' = None, width: 'Width' = 'stretch') -> 'DeltaGenerator' from MarkdownMixin
| Display mathematical expressions formatted as LaTeX.
|
| Supported LaTeX functions are listed at
| https://katex.org/docs/supported.html.
|
| Parameters
| ----------
| body : str or SymPy expression
| The string or SymPy expression to display as LaTeX. If str, it's
| a good idea to use raw Python strings since LaTeX uses backslashes
| a lot.
|
| help : str or None
| A tooltip that gets displayed next to the LaTeX expression. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| width : "stretch", "content", or int
| The width of the LaTeX element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.latex(r'''
| ... a + ar + a r^2 + a r^3 + \cdots + a r^{n-1} =
| ... \sum_{k=0}^{n-1} ar^k =
| ... a \left(\frac{1-r^{n}}{1-r}\right)
| ... ''')
|
| markdown(self, body: 'SupportsStr', unsafe_allow_html: 'bool' = False, *, help: 'str | None' = None, width: "Width | Literal['auto']" = 'auto', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' from MarkdownMixin
| Display string formatted as Markdown.
|
| Parameters
| ----------
| body : any
| The text to display as GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
| If anything other than a string is passed, it will be converted
| into a string behind the scenes using ``str(body)``.
|
| This also supports:
|
| - Emoji shortcodes, such as ``:+1:`` and ``:sunglasses:``.
| For a list of all supported codes,
| see https://share.streamlit.io/streamlit/emoji-shortcodes.
|
| - Streamlit logo shortcode. Use ``:streamlit:`` to add a little
| Streamlit flair to your text.
|
| - A limited set of typographical symbols. ``"<- -> <-> -- >= <= ~="``
| becomes "← → ↔ — ≥ ≤ ≈" when parsed as Markdown.
|
| - Google Material Symbols (rounded style), using the syntax
| ``:material/icon_name:``, where "icon_name" is the name of the
| icon in snake case. For a complete list of icons, see Google's
| `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
| must be on their own lines). Supported LaTeX functions are listed
| at https://katex.org/docs/supported.html.
|
| - Colored text and background colors for text. There are two ways
| to apply colors:
|
| - Streamlit color palette: Use the syntax
| ``:color[your text]`` and
| ``:color-background[your text]``, where ``color`` is one of: red,
| orange, yellow, green, blue, violet, gray, grey, rainbow, or
| primary. For example, ``:orange[your text]`` or
| ``:blue-background[your text]``. If you use "primary", Streamlit
| will use the default primary accent color unless you set the
| ``theme.primaryColor`` configuration option.
|
| - Custom CSS colors: Use the syntax
| ``:color[your text]{foreground="..." background="..."}`` with a
| valid CSS color value. Both ``foreground`` and ``background`` are
| optional. Supported formats include named CSS colors, HEX, RGB(A),
| and HSL(A). For example,
| ``:color[warning]{foreground="#d50000"}`` or
| ``:color[note]{foreground="rgb(0,100,200)" background="hsl(60,100%,90%)"}``.
|
| .. note::
| When using ``:color[...]{}`` with custom CSS colors, a named
| color like ``"red"`` refers to the standard CSS named color,
| not the Streamlit palette color. RGB and HSL values must use
| comma-separated syntax; the modern space-separated syntax
| isn't supported. Colors are parsed by `color2k
| <https://color2k.com>`_.
|
| - Colored badges, using the syntax ``:color-badge[text in the badge]``.
| ``color`` must be replaced with any of the following supported
| colors: red, orange, yellow, green, blue, violet, gray/grey, or primary.
| For example, you can use ``:orange-badge[your text here]`` or
| ``:blue-badge[your text here]``.
|
| - Shimmer effect for loading or in-progress text, using the syntax
| ``:shimmer[text to shimmer]``. The text fades in and out to indicate
| ongoing activity. This respects the user's reduced motion preferences.
|
| - Small text, using the syntax ``:small[text to show small]``.
|
|
| unsafe_allow_html : bool
| Whether to render HTML within ``body``. If this is ``False``
| (default), any HTML tags found in ``body`` will be escaped and
| therefore treated as raw text. If this is ``True``, any HTML
| expressions within ``body`` will be rendered.
|
| Adding custom HTML to your app impacts safety, styling, and
| maintainability.
|
| .. note::
| If you only want to insert HTML or CSS without Markdown text,
| we recommend using ``st.html`` instead.
|
| help : str or None
| A tooltip that gets displayed next to the Markdown. If this is
| ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| width : "auto", "stretch", "content", or int
| The width of the Markdown element. This can be one of the following:
|
| - ``"auto"`` (default): The width of the element adapts based on
| the container flex layout. In vertical containers, the element
| uses ``"stretch"`` width. In horizontal containers, the element
| uses ``"content"`` width.
| - ``"stretch"``: The width of the element matches the width of
| the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| text_alignment : "left", "center", "right", or "justify"
| The horizontal alignment of the text within the element. This can
| be one of the following:
|
| - ``"left"`` (default): Text is aligned to the left edge.
| - ``"center"``: Text is centered.
| - ``"right"``: Text is aligned to the right edge.
| - ``"justify"``: Text is justified (stretched to fill the available
| width with the last line left-aligned).
|
| .. note::
| For text alignment to have a visible effect, the element's
| width must be wider than its content. If you use
| ``width="content"`` with short text, the alignment may not be
| noticeable.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.markdown("*Streamlit* is **really** ***cool***.")
| >>> st.markdown('''
| ... :red[Streamlit] :orange[can] :green[write] :blue[text] :violet[in]
| ... :gray[pretty] :rainbow[colors] and :blue-background[highlight] text.''')
| >>> st.markdown("Here's a bouquet —\
| ... :tulip::cherry_blossom::rose::hibiscus::sunflower::blossom:")
| >>>
| >>> multi = '''If you end a line with two spaces,
| ... a soft return is used for the next line.
| ...
| ... Two (or more) newline characters in a row will result in a hard return.
| ... '''
| >>> st.markdown(multi)
|
| .. output::
| https://doc-markdown.streamlit.app/
| height: 350px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.map.MapMixin:
|
| map(self, data: 'Data' = None, *, latitude: 'str | None' = None, longitude: 'str | None' = None, color: 'str | Color | None' = None, size: 'str | float | None' = None, zoom: 'int | None' = None, width: 'WidthWithoutContent' = 'stretch', height: 'HeightWithoutContent' = 500, use_container_width: 'bool | None' = None) -> 'DeltaGenerator' from MapMixin
| Display a map with a scatterplot overlaid onto it.
|
| This is a wrapper around ``st.pydeck_chart`` to quickly create
| scatterplot charts on top of a map, with auto-centering and auto-zoom.
|
| When using this command, a service called Carto_ provides the map tiles to render
| map content. If you're using advanced PyDeck features you may need to obtain
| an API key from Carto first. You can do that as
| ``pydeck.Deck(api_keys={"carto": YOUR_KEY})`` or by setting the CARTO_API_KEY
| environment variable. See `PyDeck's documentation`_ for more information.
|
| Another common provider for map tiles is Mapbox_. If you prefer to use that,
| you'll need to create an account at https://mapbox.com and specify your Mapbox
| key when creating the ``pydeck.Deck`` object. You can do that as
| ``pydeck.Deck(api_keys={"mapbox": YOUR_KEY})`` or by setting the MAPBOX_API_KEY
| environment variable.
|
| .. _Carto: https://carto.com
| .. _Mapbox: https://mapbox.com
| .. _PyDeck's documentation: https://deckgl.readthedocs.io/en/latest/deck.html
|
| Carto and Mapbox are third-party products and Streamlit accepts no responsibility
| or liability of any kind for Carto or Mapbox, or for any content or information
| made available by Carto or Mapbox. The use of Carto or Mapbox is governed by
| their respective Terms of Use.
|
| Parameters
| ----------
| data : Anything supported by st.dataframe
| The data to be plotted.
|
| latitude : str or None
| The name of the column containing the latitude coordinates of
| the datapoints in the chart.
|
| If None, the latitude data will come from any column named 'lat',
| 'latitude', 'LAT', or 'LATITUDE'.
|
| longitude : str or None
| The name of the column containing the longitude coordinates of
| the datapoints in the chart.
|
| If None, the longitude data will come from any column named 'lon',
| 'longitude', 'LON', or 'LONGITUDE'.
|
| color : str or tuple or None
| The color of the circles representing each datapoint.
|
| Can be:
|
| - None, to use the default color.
| - A hex string like "#ffaa00" or "#ffaa0088".
| - An RGB or RGBA tuple with the red, green, blue, and alpha
| components specified as ints from 0 to 255 or floats from 0.0 to
| 1.0.
| - The name of the column to use for the color. Cells in this column
| should contain colors represented as a hex string or color tuple,
| as described above.
|
| size : str or float or None
| The size of the circles representing each point, in meters.
|
| This can be:
|
| - None, to use the default size.
| - A number like 100, to specify a single size to use for all
| datapoints.
| - The name of the column to use for the size. This allows each
| datapoint to be represented by a circle of a different size.
|
| zoom : int
| Zoom level as specified in
| https://wiki.openstreetmap.org/wiki/Zoom_levels.
|
| width : "stretch" or int
| The width of the chart element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| height : "stretch" or int
| The height of the chart element. This can be one of the following:
|
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled. This is ``500`` by default.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
|
| use_container_width : bool or None
| Whether to override the map's native width with the width of
| the parent container. This can be one of the following:
|
| - ``None`` (default): Streamlit will use the map's default behavior.
| - ``True``: Streamlit sets the width of the map to match the
| width of the parent container.
| - ``False``: Streamlit sets the width of the map to fit its
| contents according to the plotting library, up to the width of
| the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| Examples
| --------
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| >>> rng(0).standard_normal((1000, 2)) / [50, 50] + [37.76, -122.4],
| >>> columns=["lat", "lon"],
| >>> )
| >>>
| >>> st.map(df)
|
| .. output::
| https://doc-map.streamlit.app/
| height: 600px
|
| You can also customize the size and color of the datapoints:
|
| >>> st.map(df, size=20, color="#0044ff")
|
| And finally, you can choose different columns to use for the latitude
| and longitude components, as well as set size and color of each
| datapoint dynamically based on other columns:
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... {
| ... "col1": rng(0).standard_normal(1000) / 50 + 37.76,
| ... "col2": rng(1).standard_normal(1000) / 50 + -122.4,
| ... "col3": rng(2).standard_normal(1000) * 100,
| ... "col4": rng(3).standard_normal((1000, 4)).tolist(),
| ... }
| ... )
| >>>
| >>> st.map(df, latitude="col1", longitude="col2", size="col3", color="col4")
|
| .. output::
| https://doc-map-color.streamlit.app/
| height: 600px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.media.MediaMixin:
|
| audio(self, data: 'MediaData', format: 'str' = 'audio/wav', start_time: 'MediaTime' = 0, *, sample_rate: 'int | None' = None, end_time: 'MediaTime | None' = None, loop: 'bool' = False, autoplay: 'bool' = False, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' from MediaMixin
| Display an audio player.
|
| Parameters
| ----------
| data : str, Path, bytes, BytesIO, numpy.ndarray, or file
| The audio to play. This can be one of the following:
|
| - A URL (string) for a hosted audio file. Also supports
| ``/app/static/<asset>`` URLs for files served via
| `static file serving <https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_.
| - A path to a local audio file. The path can be a ``str``
| or ``Path`` object. Paths can be absolute or relative to the
| working directory (where you execute ``streamlit run``).
| - Raw audio data. Raw data formats must include all necessary file
| headers to match the file format specified via ``format``.
|
| If ``data`` is a NumPy array, it must either be a 1D array of the
| waveform or a 2D array of shape (C, S) where C is the number of
| channels and S is the number of samples. See the default channel
| order at
| http://msdn.microsoft.com/en-us/library/windows/hardware/dn653308(v=vs.85).aspx
|
| format : str
| The MIME type for the audio file. This defaults to ``"audio/wav"``.
| For more information about MIME types, see
| https://www.iana.org/assignments/media-types/media-types.xhtml.
|
| start_time : int, float, timedelta, str, or None
| The time from which the element should start playing. This can be
| one of the following:
|
| - ``None`` (default): The element plays from the beginning.
| - An ``int`` or ``float`` specifying the time in seconds. ``float``
| values are rounded down to whole seconds.
| - A string specifying the time in a format supported by `Pandas'
| Timedelta constructor <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_,
| e.g. ``"2 minute"``, ``"20s"``, or ``"1m14s"``.
| - A ``timedelta`` object from `Python's built-in datetime library
| <https://docs.python.org/3/library/datetime.html#timedelta-objects>`_,
| e.g. ``timedelta(seconds=70)``.
| sample_rate : int or None
| The sample rate of the audio data in samples per second. This is
| only required if ``data`` is a NumPy array.
| end_time : int, float, timedelta, str, or None
| The time at which the element should stop playing. This can be
| one of the following:
|
| - ``None`` (default): The element plays through to the end.
| - An ``int`` or ``float`` specifying the time in seconds. ``float``
| values are rounded down to whole seconds.
| - A string specifying the time in a format supported by `Pandas'
| Timedelta constructor <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_,
| e.g. ``"2 minute"``, ``"20s"``, or ``"1m14s"``.
| - A ``timedelta`` object from `Python's built-in datetime library
| <https://docs.python.org/3/library/datetime.html#timedelta-objects>`_,
| e.g. ``timedelta(seconds=70)``.
| loop : bool
| Whether the audio should loop playback.
| autoplay : bool
| Whether the audio file should start playing automatically. This is
| ``False`` by default. Browsers will not autoplay audio files if the
| user has not interacted with the page by clicking somewhere.
| width : "stretch" or int
| The width of the audio player element. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Examples
| --------
| To display an audio player for a local file, specify the file's string
| path and format.
|
| >>> import streamlit as st
| >>>
| >>> st.audio("cat-purr.mp3", format="audio/mpeg", loop=True)
|
| .. output::
| https://doc-audio-purr.streamlit.app/
| height: 250px
|
| You can also pass ``bytes`` or ``numpy.ndarray`` objects to ``st.audio``.
|
| >>> import streamlit as st
| >>> import numpy as np
| >>>
| >>> audio_file = open("myaudio.ogg", "rb")
| >>> audio_bytes = audio_file.read()
| >>>
| >>> st.audio(audio_bytes, format="audio/ogg")
| >>>
| >>> sample_rate = 44100 # 44100 samples per second
| >>> seconds = 2 # Note duration of 2 seconds
| >>> frequency_la = 440 # Our played note will be 440 Hz
| >>> # Generate array with seconds*sample_rate steps, ranging between 0 and seconds
| >>> t = np.linspace(0, seconds, seconds * sample_rate, False)
| >>> # Generate a 440 Hz sine wave
| >>> note_la = np.sin(frequency_la * t * 2 * np.pi)
| >>>
| >>> st.audio(note_la, sample_rate=sample_rate)
|
| .. output::
| https://doc-audio.streamlit.app/
| height: 865px
|
| video(self, data: 'MediaData', format: 'str' = 'video/mp4', start_time: 'MediaTime' = 0, *, subtitles: 'SubtitleData' = None, end_time: 'MediaTime | None' = None, loop: 'bool' = False, autoplay: 'bool' = False, muted: 'bool' = False, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' from MediaMixin
| Display a video player.
|
| Parameters
| ----------
| data : str, Path, bytes, io.BytesIO, numpy.ndarray, or file
| The video to play. This can be one of the following:
|
| - A URL (string) for a hosted video file, including YouTube URLs.
| Also supports ``/app/static/<asset>`` URLs for files served via
| `static file serving <https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_.
| - A path to a local video file. The path can be a ``str``
| or ``Path`` object. Paths can be absolute or relative to the
| working directory (where you execute ``streamlit run``).
| - Raw video data. Raw data formats must include all necessary file
| headers to match the file format specified via ``format``.
|
| format : str
| The MIME type for the video file. This defaults to ``"video/mp4"``.
| For more information about MIME types, see
| https://www.iana.org/assignments/media-types/media-types.xhtml.
|
| start_time : int, float, timedelta, str, or None
| The time from which the element should start playing. This can be
| one of the following:
|
| - ``None`` (default): The element plays from the beginning.
| - An ``int`` or ``float`` specifying the time in seconds. ``float``
| values are rounded down to whole seconds.
| - A string specifying the time in a format supported by `Pandas'
| Timedelta constructor <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_,
| e.g. ``"2 minute"``, ``"20s"``, or ``"1m14s"``.
| - A ``timedelta`` object from `Python's built-in datetime library
| <https://docs.python.org/3/library/datetime.html#timedelta-objects>`_,
| e.g. ``timedelta(seconds=70)``.
| subtitles : str, bytes, Path, io.BytesIO, or dict
| Optional subtitle data for the video, supporting several input types:
|
| - ``None`` (default): No subtitles.
|
| - A string, bytes, or Path: File path to a subtitle file in
| ``.vtt`` or ``.srt`` formats, or the raw content of subtitles
| conforming to these formats. Paths can be absolute or relative to
| the working directory (where you execute ``streamlit run``).
| If providing raw content, the string must adhere to the WebVTT or
| SRT format specifications.
|
| - io.BytesIO: A BytesIO stream that contains valid ``.vtt`` or ``.srt``
| formatted subtitle data.
|
| - A dictionary: Pairs of labels and file paths or raw subtitle content in
| ``.vtt`` or ``.srt`` formats to enable multiple subtitle tracks.
| The label will be shown in the video player. Example:
| ``{"English": "path/to/english.vtt", "French": "path/to/french.srt"}``
|
| When provided, subtitles are displayed by default. For multiple
| tracks, the first one is displayed by default. If you don't want any
| subtitles displayed by default, use an empty string for the value
| in a dictrionary's first pair: ``{"None": "", "English": "path/to/english.vtt"}``
|
| Not supported for YouTube videos.
| end_time : int, float, timedelta, str, or None
| The time at which the element should stop playing. This can be
| one of the following:
|
| - ``None`` (default): The element plays through to the end.
| - An ``int`` or ``float`` specifying the time in seconds. ``float``
| values are rounded down to whole seconds.
| - A string specifying the time in a format supported by `Pandas'
| Timedelta constructor <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_,
| e.g. ``"2 minute"``, ``"20s"``, or ``"1m14s"``.
| - A ``timedelta`` object from `Python's built-in datetime library
| <https://docs.python.org/3/library/datetime.html#timedelta-objects>`_,
| e.g. ``timedelta(seconds=70)``.
| loop : bool
| Whether the video should loop playback.
| autoplay : bool
| Whether the video should start playing automatically. This is
| ``False`` by default. Browsers will not autoplay unmuted videos
| if the user has not interacted with the page by clicking somewhere.
| To enable autoplay without user interaction, you must also set
| ``muted=True``.
| muted : bool
| Whether the video should play with the audio silenced. This is
| ``False`` by default. Use this in conjunction with ``autoplay=True``
| to enable autoplay without user interaction.
| width : "stretch" or int
| The width of the video player element. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> video_file = open("myvideo.mp4", "rb")
| >>> video_bytes = video_file.read()
| >>>
| >>> st.video(video_bytes)
|
| .. output::
| https://doc-video.streamlit.app/
| height: 700px
|
| When you include subtitles, they will be turned on by default. A viewer
| can turn off the subtitles (or captions) from the browser's default video
| control menu, usually located in the lower-right corner of the video.
|
| Here is a simple VTT file (``subtitles.vtt``):
|
| >>> WEBVTT
| >>>
| >>> 0:00:01.000 --> 0:00:02.000
| >>> Look!
| >>>
| >>> 0:00:03.000 --> 0:00:05.000
| >>> Look at the pretty stars!
|
| If the above VTT file lives in the same directory as your app, you can
| add subtitles like so:
|
| >>> import streamlit as st
| >>>
| >>> VIDEO_URL = "https://example.com/not-youtube.mp4"
| >>> st.video(VIDEO_URL, subtitles="subtitles.vtt")
|
| .. output::
| https://doc-video-subtitles.streamlit.app/
| height: 700px
|
| See additional examples of supported subtitle input types in our
| `video subtitles feature demo <https://doc-video-subtitle-inputs.streamlit.app/>`_.
|
| .. note::
| Some videos may not display if they are encoded using MP4V (which is an export option in OpenCV),
| as this codec is not widely supported by browsers. Converting your video to H.264 will allow
| the video to be displayed in Streamlit.
| See this `StackOverflow post <https://stackoverflow.com/a/49535220/2394542>`_ or this
| `Streamlit forum post <https://discuss.streamlit.io/t/st-video-doesnt-show-opencv-generated-mp4/3193/2>`_
| for more information.
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.metric.MetricMixin:
|
| metric(self, label: 'str', value: 'Value', delta: 'Delta' = None, delta_color: 'DeltaColor' = 'normal', *, help: 'str | None' = None, label_visibility: 'LabelVisibility' = 'visible', border: 'bool' = False, width: 'Width' = 'stretch', height: 'Height' = 'content', chart_data: 'OptionSequence[Any] | None' = None, chart_type: "Literal['line', 'bar', 'area']" = 'line', delta_arrow: 'DeltaArrow' = 'auto', format: 'str | NumberFormat | None' = None, delta_description: 'str | None' = None) -> 'DeltaGenerator' from MetricMixin
| Display a metric in big bold font, with an optional indicator of how the metric changed.
|
| Parameters
| ----------
| label : str
| The header or title for the metric. The label can optionally
| contain GitHub-flavored Markdown of the following types: Bold, Italics,
| Strikethroughs, Inline Code, Links, and Images. Images display like
| icons, with a max height equal to the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| value : int, float, decimal.Decimal, str, or None
| Value of the metric. ``None`` is rendered as a long dash.
|
| The value can optionally contain GitHub-flavored Markdown, subject
| to the same limitations described in the ``label`` parameter.
|
| delta : int, float, decimal.Decimal, str, or None
| Amount or indicator of change in the metric. An arrow is shown next
| to the delta, oriented according to its sign:
|
| - If the delta is ``None`` or an empty string, no arrow is shown.
| - If the delta is a negative number or starts with a minus sign,
| the arrow points down and the delta is red.
| - Otherwise, the arrow points up and the delta is green.
|
| You can modify the display, color, and orientation of the arrow
| using the ``delta_color`` and ``delta_arrow`` parameters.
|
| The delta can optionally contain GitHub-flavored Markdown, subject
| to the same limitations described in the ``label`` parameter.
|
| delta_color : str
| The color of the delta and chart. This can be one of the following:
|
| - ``"normal"`` (default): The color is red when the delta is
| negative and green otherwise.
| - ``"inverse"``: The color is green when the delta is negative and
| red otherwise. This is useful when a negative change is
| considered good, like a decrease in cost.
| - ``"off"``: The color is gray regardless of the delta.
| - A named color from the basic palette: The chart and delta are the
| specified color regardless of their value. This can be one of the
| following: ``"red"``, ``"orange"``, ``"yellow"``, ``"green"``,
| ``"blue"``, ``"violet"``, ``"gray"``/``"grey"``, or
| ``"primary"``.
|
| help : str or None
| A tooltip that gets displayed next to the metric label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| border : bool
| Whether to show a border around the metric container. If this is
| ``False`` (default), no border is shown. If this is ``True``, a
| border is shown.
|
| height : "content", "stretch", or int
| The height of the metric element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| width : "stretch", "content", or int
| The width of the metric element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| chart_data : Iterable or None
| A sequence of numeric values to display as a sparkline chart. If
| this is ``None`` (default), no chart is displayed. The sequence can
| be anything supported by ``st.dataframe``, including a ``list`` or
| ``set``. If the sequence is dataframe-like, the first column will
| be used. Each value will be cast to ``float`` internally by
| default.
|
| The chart uses the color of the delta indicator, which can be
| modified using the ``delta_color`` parameter.
|
| chart_type : "line", "bar", or "area"
| The type of sparkline chart to display. This can be one of the
| following:
|
| - ``"line"`` (default): A simple sparkline.
| - ``"area"``: A sparkline with area shading.
| - ``"bar"``: A bar chart.
|
| delta_arrow : "auto", "up", "down", or "off"
| Controls the direction of the delta indicator arrow. This can be
| one of the following strings:
|
| - ``"auto"`` (default): The arrow direction follows the sign of
| ``delta``.
| - ``"up"`` or ``"down"``: The arrow is forced to point in the
| specified direction.
| - ``"off"``: No arrow is shown, but the delta value remains
| visible.
|
| format : str or None
| A format string controlling how numbers are displayed for ``value``
| and ``delta``. The format is only applied if the value or delta is
| numeric. If the value or delta is a string with non-numeric
| characters, the format is ignored. The format can be one of the
| following values:
|
| - ``None`` (default): No formatting is applied.
| - ``"plain"``: Show the full number without any formatting (e.g. "1234.567").
| - ``"localized"``: Show the number in the default locale format (e.g. "1,234.567").
| - ``"percent"``: Show the number as a percentage (e.g. "123456.70%").
| - ``"dollar"``: Show the number as a dollar amount (e.g. "$1,234.57").
| - ``"euro"``: Show the number as a euro amount (e.g. "€1,234.57").
| - ``"yen"``: Show the number as a yen amount (e.g. "¥1,235").
| - ``"accounting"``: Show the number in an accounting format (e.g. "1,234.00").
| - ``"bytes"``: Show the number in a byte format (e.g. "1.2KB").
| - ``"compact"``: Show the number in a compact format (e.g. "1.2K").
| - ``"scientific"``: Show the number in scientific notation (e.g. "1.235E3").
| - ``"engineering"``: Show the number in engineering notation (e.g. "1.235E3").
| - printf-style format string: Format the number with a printf
| specifier, like ``"%d"`` to show a signed integer (e.g. "1234") or
| ``"%.2f"`` to show a float with 2 decimal places. Use ``,`` for
| thousand separators (e.g. ``"%,d"`` yields ``"1,234"``).
|
| delta_description : str or None
| A short description displayed next to the delta value, such as
| ``"month over month"`` or ``"vs. last quarter"``. If this is ``None``
| (default), no description is shown. The description is displayed
| in a smaller, muted font style similar to ``st.caption``.
|
| Examples
| --------
| **Example 1: Show a metric**
|
| >>> import streamlit as st
| >>>
| >>> st.metric(label="Temperature", value="70 °F", delta="1.2 °F")
|
| .. output::
| https://doc-metric-example1.streamlit.app/
| height: 210px
|
| **Example 2: Create a row of metrics**
|
| ``st.metric`` looks especially nice in combination with ``st.columns``.
|
| >>> import streamlit as st
| >>>
| >>> col1, col2, col3 = st.columns(3)
| >>> col1.metric("Temperature", "70 °F", "1.2 °F")
| >>> col2.metric("Wind", "9 mph", "-8%")
| >>> col3.metric("Humidity", "86%", "4%")
|
| .. output::
| https://doc-metric-example2.streamlit.app/
| height: 210px
|
| **Example 3: Modify the delta indicator**
|
| The delta indicator color can also be inverted or turned off.
|
| >>> import streamlit as st
| >>>
| >>> st.metric(
| ... label="Gas price", value=4, delta=-0.5, delta_color="inverse"
| ... )
| >>>
| >>> st.metric(
| ... label="Active developers",
| ... value=123,
| ... delta=123,
| ... delta_color="off",
| ... )
|
| .. output::
| https://doc-metric-example3.streamlit.app/
| height: 320px
|
| **Example 4: Create a grid of metric cards**
|
| Add borders to your metrics to create a dashboard look.
|
| >>> import streamlit as st
| >>>
| >>> a, b = st.columns(2)
| >>> c, d = st.columns(2)
| >>>
| >>> a.metric("Temperature", "30°F", "-9°F", border=True)
| >>> b.metric("Wind", "4 mph", "2 mph", border=True)
| >>>
| >>> c.metric("Humidity", "77%", "5%", border=True)
| >>> d.metric("Pressure", "30.34 inHg", "-2 inHg", border=True)
|
| .. output::
| https://doc-metric-example4.streamlit.app/
| height: 350px
|
| **Example 5: Show sparklines**
|
| To show trends over time, add sparklines.
|
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> changes = list(rng(4).standard_normal(20))
| >>> data = [sum(changes[:i]) for i in range(20)]
| >>> delta = round(data[-1], 2)
| >>>
| >>> row = st.container(horizontal=True)
| >>> with row:
| >>> st.metric(
| ... "Line", 10, delta, chart_data=data, chart_type="line", border=True
| ... )
| >>> st.metric(
| ... "Area", 10, delta, chart_data=data, chart_type="area", border=True
| ... )
| >>> st.metric(
| ... "Bar", 10, delta, chart_data=data, chart_type="bar", border=True
| ... )
|
| .. output::
| https://doc-metric-example5.streamlit.app/
| height: 300px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.menu_button.MenuButtonMixin:
|
| menu_button(self, label: 'str', options: 'OptionSequence[T]', *, key: 'Key | None' = None, help: 'str | None' = None, on_click: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', icon: 'str | None' = None, disabled: 'bool' = False, width: 'Width' = 'content', format_func: 'Callable[[Any], str]' = <class 'str'>) -> 'T | None' from MenuButtonMixin
| Display a dropdown menu button widget.
|
| A menu button displays a button which, when clicked, opens a dropdown
| menu with multiple options. Selecting an option triggers a rerun and
| returns the selected option value. If you open and close the dropdown
| menu without selecting an option, the app doesn't rerun.
|
| ``st.menu_button`` behaves like ``st.button`` except that it returns
| one of multiple options when triggered instead of only ``True``. Unlike
| ``st.selectbox``, the button label remains unchanged after a selection,
| and the return value reverts to ``None`` on the next rerun, until the
| menu button is triggered again.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this button is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Display unsupported elements as literal
| characters by backslash-escaping them. E.g.,
| ``"1\. Not an ordered list"``.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| options : Iterable
| Labels for the menu options in an ``Iterable``. This can be a
| ``list``, ``set``, or anything supported by ``st.dataframe``. If
| ``options`` is dataframe-like, the first column will be used. Each
| label will be cast to ``str`` internally by default.
|
| Labels can include markdown as described in the ``label`` parameter.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you access the widget's value via
| ``st.session_state[key]`` (read-only). For more details, see
| `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed when the button is hovered over. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_click : callable
| An optional callback invoked when an option is selected.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| type : "primary", "secondary", or "tertiary"
| An optional string that specifies the button type. This can be one
| of the following:
|
| - ``"primary"``: The button's background is the app's primary color
| for additional emphasis.
| - ``"secondary"`` (default): The button's background coordinates
| with the app's background color for normal emphasis.
| - ``"tertiary"``: The button is plain text without a border or
| background for subtlety.
|
| icon : str or None
| An optional emoji or icon to display next to the button label. If ``icon``
| is ``None`` (default), no icon is displayed. If ``icon`` is a
| string, the following options are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols \
| <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| disabled : bool
| An optional boolean that disables the button if set to ``True``.
| The default is ``False``.
|
| width : "content", "stretch", or int
| The width of the menu button. This can be one of the following:
|
| - ``"content"`` (default): The width of the button matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the button matches the width of the
| parent container.
| - An integer specifying the width in pixels: The button has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the button matches the width
| of the parent container.
|
| format_func : function
| Function to modify the display of the menu options. It receives
| the raw option as an argument and should output the label to be
| shown for that option. This has no impact on the return value of
| the menu button.
|
| Returns
| -------
| any or None
| The selected option value when an option is clicked, or ``None``
| if no option was clicked.
|
| This is a copy of the selected option, not the original.
|
| Examples
| --------
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| action = st.menu_button("Export", options=["CSV", "JSON", "PDF"])
| if action == "CSV":
| st.write("Exporting as CSV...")
| elif action == "JSON":
| st.write("Exporting as JSON...")
| elif action == "PDF":
| st.write("Exporting as PDF...")
|
| .. output::
| https://doc-menu-button.streamlit.app/
| height: 300px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.multiselect.MultiSelectMixin:
|
| multiselect(self, label: 'str', options: 'OptionSequence[T]', default: 'Any | None' = None, format_func: 'Callable[[Any], str]' = <class 'str'>, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, max_selections: 'int | None' = None, placeholder: 'str | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', accept_new_options: 'bool' = False, filter_mode: 'SelectWidgetFilterMode' = 'fuzzy', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'list[T] | list[T | str]' from MultiSelectMixin
| Display a multiselect widget.
| The multiselect widget starts as empty.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this select widget is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| options : Iterable
| Labels for the select options in an ``Iterable``. This can be a
| ``list``, ``set``, or anything supported by ``st.dataframe``. If
| ``options`` is dataframe-like, the first column will be used. Each
| label will be cast to ``str`` internally by default.
|
| default : Iterable of V, V, or None
| List of default values. Can also be a single value.
|
| format_func : function
| Function to modify the display of the options. It receives
| the raw option as an argument and should output the label to be
| shown for that option. This has no impact on the return value of
| the command.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``max_selections`` or ``accept_new_options``
| resets the widget even when a key is provided.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this widget's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| max_selections : int or None
| The max selections that can be selected at a time. If this is
| ``None`` (default), there is no limit on the number of selections.
| If this is an integer, it must be positive.
|
| placeholder : str or None
| A string to display when no options are selected.
| If this is ``None`` (default), the widget displays placeholder text
| based on the widget's configuration:
|
| - "Choose options" is displayed when options are available and
| ``accept_new_options=False``.
| - "Choose or add options" is displayed when options are available
| and ``accept_new_options=True``.
| - "Add options" is displayed when no options are available and
| ``accept_new_options=True``.
| - "No options to select" is displayed when no options are available
| and ``accept_new_options=False``. The widget is also disabled in
| this case.
|
| disabled : bool
| An optional boolean that disables the multiselect widget if set
| to ``True``. The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| accept_new_options : bool
| Whether the user can add selections that aren't included in ``options``.
| If this is ``False`` (default), the user can only select from the
| items in ``options``. If this is ``True``, the user can enter new
| items that don't exist in ``options``.
|
| When a user enters and selects a new item, it is included in the
| widget's returned list as a string. The new item is not added to
| the widget's drop-down menu. Streamlit will use a case-insensitive
| match from ``options`` before adding a new item, and a new item
| can't be added if a case-insensitive match is already selected. The
| ``max_selections`` argument is still enforced.
|
| filter_mode : "fuzzy", "contains", "prefix", or None
| The matching mode used to filter options while the user types.
| If this is ``"fuzzy"`` (default), options are matched by in-order
| subsequence and sorted by match score. If this is ``"contains"``,
| options are matched by case-insensitive substring. If this is
| ``"prefix"``, options are matched by case-insensitive prefix. If
| this is ``None``, typing is disabled and the options are not
| filtered.
|
| ``filter_mode=None`` is incompatible with
| ``accept_new_options=True``.
|
| width : "stretch" or int
| The width of the multiselect widget. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| An empty query parameter (e.g., ``?tags=``) clears the
| widget. Invalid query parameter values are ignored and
| removed from the URL. Multiple selections use repeated
| parameters (e.g., ``?tags=Red&tags=Blue``). Duplicates are
| deduplicated. If ``max_selections`` is set, excess values
| are truncated. When ``accept_new_options`` is ``True``, any
| value is accepted.
|
| Returns
| -------
| list
| A list of the selected options.
|
| The list contains copies of the selected options, not the originals.
|
| Examples
| --------
| **Example 1: Use a basic multiselect widget**
|
| You can declare one or more initial selections with the ``default``
| parameter.
|
| >>> import streamlit as st
| >>>
| >>> options = st.multiselect(
| ... "What are your favorite colors?",
| ... ["Green", "Yellow", "Red", "Blue"],
| ... default=["Yellow", "Red"],
| ... )
| >>>
| >>> st.write("You selected:", options)
|
| .. output::
| https://doc-multiselect.streamlit.app/
| height: 350px
|
| **Example 2: Let users to add new options**
|
| To allow users to enter and select new options that aren't included in
| the ``options`` list, use the ``accept_new_options`` parameter. To
| prevent users from adding an unbounded number of new options, use the
| ``max_selections`` parameter.
|
| >>> import streamlit as st
| >>>
| >>> options = st.multiselect(
| ... "What are your favorite cat names?",
| ... ["Jellybeans", "Fish Biscuit", "Madam President"],
| ... max_selections=5,
| ... accept_new_options=True,
| ... )
| >>>
| >>> st.write("You selected:", options)
|
| .. output::
| https://doc-multiselect-accept-new-options.streamlit.app/
| height: 350px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.number_input.NumberInputMixin:
|
| number_input(self, label: 'str', min_value: 'Number | None' = None, max_value: 'Number | None' = None, value: "Number | Literal['min'] | None" = 'min', step: 'Number | None' = None, format: 'str | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, placeholder: 'str | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'Number | None' from NumberInputMixin
| Display a numeric input widget.
|
| .. note::
| Integer values exceeding +/- ``(1<<53) - 1`` cannot be accurately
| stored or returned by the widget due to serialization constraints
| between the Python server and JavaScript client. You must handle
| such numbers as floats, leading to a loss in precision.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this input is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| min_value : int, float, or None
| The minimum permitted value.
| If this is ``None`` (default), there will be no minimum for float
| values and a minimum of ``- (1<<53) + 1`` for integer values.
|
| max_value : int, float, or None
| The maximum permitted value.
| If this is ``None`` (default), there will be no maximum for float
| values and a maximum of ``(1<<53) - 1`` for integer values.
|
| value : int, float, "min" or None
| The value of this widget when it first renders. If this is
| ``"min"`` (default), the initial value is ``min_value`` unless
| ``min_value`` is ``None``. If ``min_value`` is ``None``, the widget
| initializes with a value of ``0.0`` or ``0``.
|
| If ``value`` is ``None``, the widget will initialize with no value
| and return ``None`` until the user provides input.
|
| step : int, float, or None
| The stepping interval.
| Defaults to 1 if the value is an int, 0.01 otherwise.
| If the value is not specified, the format parameter will be used.
|
| format : str or None
| A printf-style format string controlling how the interface should
| display numbers. The output must be purely numeric. This does not
| impact the return value of the widget. For more information about
| the formatting specification, see `sprintf.js
| <https://github.com/alexei/sprintf.js?tab=readme-ov-file#format-specification>`_.
|
| For example, ``format="%0.1f"`` adjusts the displayed decimal
| precision to only show one digit after the decimal.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this number_input's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| placeholder : str or None
| An optional string displayed when the number input is empty.
| If None, no placeholder is displayed.
|
| disabled : bool
| An optional boolean that disables the number input if set to
| ``True``. The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| icon : str, None
| An optional emoji or icon to display within the input field to the
| left of the value. If ``icon`` is ``None`` (default), no icon is
| displayed. If ``icon`` is a string, the following options are
| valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols \
| <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| width : "stretch" or int
| The width of the number input widget. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Invalid query parameter values are ignored and removed
| from the URL. If ``value`` is ``None``, an empty query
| parameter (e.g., ``?my_key=``) clears the widget.
|
| Returns
| -------
| int or float or None
| The current value of the numeric input widget or ``None`` if the widget
| is empty. The return type will match the data type of the value parameter.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> number = st.number_input("Insert a number")
| >>> st.write("The current number is ", number)
|
| .. output::
| https://doc-number-input.streamlit.app/
| height: 260px
|
| To initialize an empty number input, use ``None`` as the value:
|
| >>> import streamlit as st
| >>>
| >>> number = st.number_input(
| ... "Insert a number", value=None, placeholder="Type a number..."
| ... )
| >>> st.write("The current number is ", number)
|
| .. output::
| https://doc-number-input-empty.streamlit.app/
| height: 260px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.pdf.PdfMixin:
|
| pdf(self, data: 'PdfData', *, height: 'HeightWithoutContent' = 500, key: 'str | None' = None) -> 'DeltaGenerator' from PdfMixin
| Display a PDF viewer.
|
| .. Important::
|
| You must install |streamlit-pdf|_ to use this command. You can
| install it as an extra with Streamlit:
|
| .. code-block:: shell
|
| pip install streamlit[pdf]
|
| .. |streamlit-pdf| replace:: ``streamlit-pdf``
| .. _streamlit-pdf: https://github.com/streamlit/streamlit-pdf
|
| Parameters
| ----------
| data : str, Path, BytesIO, or bytes
| The PDF file to show. This can be one of the following:
|
| - A URL (string) for a hosted PDF file.
| - A path to a local PDF file. If you use a relative path, it must
| be relative to the current working directory.
| - A file-like object. For example, this can be an ``UploadedFile``
| from ``st.file_uploader``, or this can be a local file opened
| with ``open()``.
| - Raw bytes data.
|
| height : int or "stretch"
| The height of the PDF viewer. This can be one of the following:
|
| - An integer specifying the height in pixels: The viewer has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled. This is ``500`` by default.
| - ``"stretch"``: The height of the viewer matches the height of
| its content or the height of the parent container, whichever is
| larger. If the viewer is not in a parent container, the height
| of the viewer matches the height of its content.
|
| Examples
| --------
| >>> st.pdf("https://example.com/sample.pdf")
| >>> st.pdf("https://example.com/sample.pdf", height=600)
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.plotly_chart.PlotlyMixin:
|
| plotly_chart(self, figure_or_data: 'FigureOrData', use_container_width: 'bool | None' = None, *, width: 'Width' = 'stretch', height: 'Height' = 'content', theme: "Literal['streamlit'] | None" = 'streamlit', key: 'Key | None' = None, on_select: "Literal['rerun', 'ignore'] | WidgetCallback" = 'ignore', selection_mode: 'SelectionMode | Iterable[SelectionMode]' = ('points', 'box', 'lasso'), config: 'dict[str, Any] | None' = None) -> 'DeltaGenerator | PlotlyState' from PlotlyMixin
| Display an interactive Plotly chart.
|
| `Plotly <https://plot.ly/python>`_ is a charting library for Python.
|
| To show Plotly charts in Streamlit, pass a Plotly ``Figure`` or
| ``Data`` object to ``st.plotly_chart``.
|
| .. Important::
| You must install ``plotly>=4.0.0`` to use this command. Your app's
| performance may be enhanced by installing ``orjson`` as well. You
| can install all charting dependencies (except Bokeh) as an extra
| with Streamlit:
|
| .. code-block:: shell
|
| pip install streamlit[charts]
|
| Parameters
| ----------
| figure_or_data : plotly.graph_objs.Figure, plotly.graph_objs.Data, or dict/list of plotly.graph_objs.Figure/Data
|
| The Plotly ``Figure`` or ``Data`` object to render. See
| https://plot.ly/python/ for examples of graph descriptions.
|
| .. note::
| If your chart contains more than 1000 data points, Plotly will
| use a WebGL renderer to display the chart. Different browsers
| have different limits on the number of WebGL contexts per page.
| If you have multiple WebGL contexts on a page, you may need to
| switch to SVG rendering mode. You can do this by setting
| ``render_mode="svg"`` within the figure. For example, the
| following code defines a Plotly Express line chart that will
| render in SVG mode when passed to ``st.plotly_chart``:
| ``px.line(df, x="x", y="y", render_mode="svg")``.
|
| width : "stretch", "content", or int
| The width of the chart element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| height : "content", "stretch", or int
| The height of the chart element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| use_container_width : bool or None
| Whether to override the figure's native width with the width of
| the parent container. This can be one of the following:
|
| - ``None`` (default): Streamlit will use the value of ``width``.
| - ``True``: Streamlit sets the width of the figure to match the
| width of the parent container.
| - ``False``: Streamlit sets the width of the figure to fit its
| contents according to the plotting library, up to the width of
| the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| theme : "streamlit" or None
| The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
| Streamlit uses its own design default. If ``theme`` is ``None``,
| Streamlit falls back to the default behavior of the library.
|
| The ``"streamlit"`` theme can be partially customized through the
| configuration options ``theme.chartCategoricalColors`` and
| ``theme.chartSequentialColors``. Font configuration options are
| also applied.
|
| key : str, int, or None
| An optional string to use for giving this element a stable
| identity. If this is ``None`` (default), the element's identity
| will be determined based on the values of the other parameters.
|
| If selections are activated and ``key`` is provided,
| Streamlit will register the key in Session State to store the
| selection state. The selection state is read-only. For more
| details, see `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| on_select : "ignore" or "rerun" or callable
| How the figure should respond to user selection events. This
| controls whether or not the figure behaves like an input widget.
| ``on_select`` can be one of the following:
|
| - ``"ignore"`` (default): Streamlit will not react to any selection
| events in the chart. The figure will not behave like an input
| widget.
|
| - ``"rerun"``: Streamlit will rerun the app when the user selects
| data in the chart. In this case, ``st.plotly_chart`` will return
| the selection data as a dictionary.
|
| - A ``callable``: Streamlit will rerun the app and execute the
| ``callable`` as a callback function before the rest of the app.
| In this case, ``st.plotly_chart`` will return the selection data
| as a dictionary.
|
| selection_mode : "points", "box", "lasso" or an Iterable of these
| The selection mode of the chart. This can be one of the following:
|
| - ``"points"``: The chart will allow selections based on individual
| data points.
| - ``"box"``: The chart will allow selections based on rectangular
| areas.
| - ``"lasso"``: The chart will allow selections based on freeform
| areas.
| - An ``Iterable`` of the above options: The chart will allow
| selections based on the modes specified.
|
| All selections modes are activated by default.
|
| config : dict or None
| A dictionary of Plotly configuration options. This is passed to
| Plotly's ``show()`` function. For more information about Plotly
| configuration options, see Plotly's documentation on `Configuration
| in Python <https://plotly.com/python/configuration-options/>`_.
|
| Returns
| -------
| element or dict
| If ``on_select`` is ``"ignore"`` (default), this command returns an
| internal placeholder for the chart element. Otherwise, this command
| returns a dictionary-like object that supports both key and
| attribute notation. The attributes are described by the
| ``PlotlyState`` dictionary schema.
|
| Examples
| --------
| **Example 1: Basic Plotly chart**
|
| The example below comes from the examples at https://plot.ly/python.
| Note that ``plotly.figure_factory`` requires ``scipy`` to run.
|
| >>> import plotly.figure_factory as ff
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> hist_data = [
| ... rng(0).standard_normal(200) - 2,
| ... rng(1).standard_normal(200),
| ... rng(2).standard_normal(200) + 2,
| ... ]
| >>> group_labels = ["Group 1", "Group 2", "Group 3"]
| >>>
| >>> fig = ff.create_distplot(
| ... hist_data, group_labels, bin_size=[0.1, 0.25, 0.5]
| ... )
| >>>
| >>> st.plotly_chart(fig)
|
| .. output::
| https://doc-plotly-chart.streamlit.app/
| height: 550px
|
| **Example 2: Plotly Chart with configuration**
|
| By default, Plotly charts have scroll zoom enabled. If you have a
| longer page and want to avoid conflicts between page scrolling and
| zooming, you can use Plotly's configuration options to disable scroll
| zoom. In the following example, scroll zoom is disabled, but the zoom
| buttons are still enabled in the modebar.
|
| >>> import plotly.graph_objects as go
| >>> import streamlit as st
| >>>
| >>> fig = go.Figure()
| >>> fig.add_trace(
| ... go.Scatter(
| ... x=[1, 2, 3, 4, 5],
| ... y=[1, 3, 2, 5, 4]
| ... )
| ... )
| >>>
| >>> st.plotly_chart(fig, config = {'scrollZoom': False})
|
| .. output::
| https://doc-plotly-chart-config.streamlit.app/
| height: 550px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.progress.ProgressMixin:
|
| progress(self, value: 'FloatOrInt', text: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' from ProgressMixin
| Display a progress bar.
|
| Parameters
| ----------
| value : int or float
| 0 <= value <= 100 for int
|
| 0.0 <= value <= 1.0 for float
|
| text : str or None
| A message to display above the progress bar. The text can optionally
| contain GitHub-flavored Markdown of the following types: Bold, Italics,
| Strikethroughs, Inline Code, Links, and Images. Images display like
| icons, with a max height equal to the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| width : "stretch" or int
| The width of the progress element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Examples
| --------
| Here is an example of a progress bar increasing over time and disappearing when it reaches completion:
|
| >>> import streamlit as st
| >>> import time
| >>>
| >>> progress_text = "Operation in progress. Please wait."
| >>> my_bar = st.progress(0, text=progress_text)
| >>>
| >>> for percent_complete in range(100):
| ... time.sleep(0.01)
| ... my_bar.progress(percent_complete + 1, text=progress_text)
| >>> time.sleep(1)
| >>> my_bar.empty()
| >>>
| >>> st.button("Rerun")
|
| .. output::
| https://doc-status-progress.streamlit.app/
| height: 220px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.deck_gl_json_chart.PydeckMixin:
|
| pydeck_chart(self, pydeck_obj: 'Deck | None' = None, *, width: 'WidthWithoutContent' = 'stretch', use_container_width: 'bool | None' = None, height: 'HeightWithoutContent' = 500, selection_mode: 'SelectionMode' = 'single-object', on_select: "Literal['rerun', 'ignore'] | WidgetCallback" = 'ignore', key: 'Key | None' = None) -> 'DeltaGenerator | PydeckState' from PydeckMixin
| Draw a chart using the PyDeck library.
|
| This supports 3D maps, point clouds, and more! More info about PyDeck
| at https://deckgl.readthedocs.io/en/latest/.
|
| These docs are also quite useful:
|
| - DeckGL docs: https://github.com/uber/deck.gl/tree/master/docs
| - DeckGL JSON docs: https://github.com/uber/deck.gl/tree/master/modules/json
|
| When using this command, a service called Carto_ provides the map tiles to render
| map content. If you're using advanced PyDeck features you may need to obtain
| an API key from Carto first. You can do that as
| ``pydeck.Deck(api_keys={"carto": YOUR_KEY})`` or by setting the CARTO_API_KEY
| environment variable. See `PyDeck's documentation`_ for more information.
|
| Another common provider for map tiles is Mapbox_. If you prefer to use that,
| you'll need to create an account at https://mapbox.com and specify your Mapbox
| key when creating the ``pydeck.Deck`` object. You can do that as
| ``pydeck.Deck(api_keys={"mapbox": YOUR_KEY})`` or by setting the MAPBOX_API_KEY
| environment variable.
|
| .. _Carto: https://carto.com
| .. _Mapbox: https://mapbox.com
| .. _PyDeck's documentation: https://deckgl.readthedocs.io/en/latest/deck.html
|
| Carto and Mapbox are third-party products and Streamlit accepts no responsibility
| or liability of any kind for Carto or Mapbox, or for any content or information
| made available by Carto or Mapbox. The use of Carto or Mapbox is governed by
| their respective Terms of Use.
|
| .. note::
| Pydeck uses two WebGL contexts per chart, and different browsers
| have different limits on the number of WebGL contexts per page.
| If you exceed this limit, the oldest contexts will be dropped to
| make room for the new ones. To avoid this limitation in most
| browsers, don't display more than eight Pydeck charts on a single
| page.
|
| Parameters
| ----------
| pydeck_obj : pydeck.Deck or None
| Object specifying the PyDeck chart to draw.
| width : "stretch" or int
| The width of the chart element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| use_container_width : bool or None
| Whether to override the chart's native width with the width of
| the parent container. This can be one of the following:
|
| - ``None`` (default): Streamlit will use the chart's default behavior.
| - ``True``: Streamlit sets the width of the chart to match the
| width of the parent container.
| - ``False``: Streamlit sets the width of the chart to fit its
| contents according to the plotting library, up to the width of
| the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| height : "stretch" or int
| The height of the chart element. This can be one of the following:
|
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled. This is ``500`` by default.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
|
| on_select : "ignore" or "rerun" or callable
| How the figure should respond to user selection events. This controls
| whether or not the chart behaves like an input widget.
| ``on_select`` can be one of the following:
|
| - ``"ignore"`` (default): Streamlit will not react to any selection
| events in the chart. The figure will not behave like an
| input widget.
| - ``"rerun"``: Streamlit will rerun the app when the user selects
| data in the chart. In this case, ``st.pydeck_chart`` will return
| the selection data as a dictionary.
| - A ``callable``: Streamlit will rerun the app and execute the callable
| as a callback function before the rest of the app. In this case,
| ``st.pydeck_chart`` will return the selection data as a
| dictionary.
|
| If ``on_select`` is not ``"ignore"``, all layers must have a
| declared ``id`` to keep the chart stateful across reruns.
| selection_mode : "single-object" or "multi-object"
| The selection mode of the chart. This can be one of the following:
|
| - ``"single-object"`` (default): Only one object can be selected at
| a time.
| - ``"multi-object"``: Multiple objects can be selected at a time.
|
| key : str, int, or None
| An optional string to use for giving this element a stable
| identity. If this is ``None`` (default), the element's identity
| will be determined based on the values of the other parameters.
|
| If selections are activated and ``key`` is provided,
| Streamlit will register the key in Session State to store the
| selection state. The selection state is read-only. For more
| details, see `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| Returns
| -------
| element or dict
| If ``on_select`` is ``"ignore"`` (default), this command returns an
| internal placeholder for the chart element. Otherwise, this method
| returns a dictionary-like object that supports both key and
| attribute notation. The attributes are described by the
| ``PydeckState`` dictionary schema.
|
| Examples
| --------
| Here's a chart using a HexagonLayer and a ScatterplotLayer. It uses either the
| light or dark map style, based on which Streamlit theme is currently active:
|
| >>> import pandas as pd
| >>> import pydeck as pdk
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... rng(0).standard_normal((1000, 2)) / [50, 50] + [37.76, -122.4],
| ... columns=["lat", "lon"],
| ... )
| >>>
| >>> st.pydeck_chart(
| ... pdk.Deck(
| ... map_style=None, # Use Streamlit theme to pick map style
| ... initial_view_state=pdk.ViewState(
| ... latitude=37.76,
| ... longitude=-122.4,
| ... zoom=11,
| ... pitch=50,
| ... ),
| ... layers=[
| ... pdk.Layer(
| ... "HexagonLayer",
| ... data=df,
| ... get_position="[lon, lat]",
| ... radius=200,
| ... elevation_scale=4,
| ... elevation_range=[0, 1000],
| ... pickable=True,
| ... extruded=True,
| ... ),
| ... pdk.Layer(
| ... "ScatterplotLayer",
| ... data=df,
| ... get_position="[lon, lat]",
| ... get_color="[200, 30, 0, 160]",
| ... get_radius=200,
| ... ),
| ... ],
| ... )
| ... )
|
| .. output::
| https://doc-pydeck-chart.streamlit.app/
| height: 530px
|
| .. note::
| To make the PyDeck chart's style consistent with Streamlit's theme,
| you can set ``map_style=None`` in the ``pydeck.Deck`` object.
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.pyplot.PyplotMixin:
|
| pyplot(self, fig: 'Figure | None' = None, clear_figure: 'bool | None' = None, *, width: 'Width' = 'stretch', use_container_width: 'bool | None' = None, **kwargs: 'Any') -> 'DeltaGenerator' from PyplotMixin
| Display a matplotlib.pyplot figure.
|
| .. Important::
| You must install ``matplotlib>=3.0.0`` to use this command. You can
| install all charting dependencies (except Bokeh) as an extra with
| Streamlit:
|
| .. code-block:: shell
|
| pip install streamlit[charts]
|
| Parameters
| ----------
| fig : Matplotlib Figure
| The Matplotlib ``Figure`` object to render. See
| https://matplotlib.org/stable/gallery/index.html for examples.
|
| .. note::
| When this argument isn't specified, this function will render the global
| Matplotlib figure object. However, this feature is deprecated and
| will be removed in a later version.
|
| clear_figure : bool
| If True, the figure will be cleared after being rendered.
| If False, the figure will not be cleared after being rendered.
| If left unspecified, we pick a default based on the value of ``fig``.
|
| - If ``fig`` is set, defaults to ``False``.
|
| - If ``fig`` is not set, defaults to ``True``. This simulates Jupyter's
| approach to matplotlib rendering.
|
| width : "stretch", "content", or int
| The width of the chart element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| use_container_width : bool
| Whether to override the figure's native width with the width of
| the parent container. If ``use_container_width`` is ``True``
| (default), Streamlit sets the width of the figure to match the
| width of the parent container. If ``use_container_width`` is
| ``False``, Streamlit sets the width of the chart to fit its
| contents according to the plotting library, up to the width of the
| parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``. For ``use_container_width=False``, use
| ``width="content"``.
|
| **kwargs : any
| Arguments to pass to Matplotlib's savefig function.
|
| Examples
| --------
| >>> import matplotlib.pyplot as plt
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> arr = rng(0).normal(1, 1, size=100)
| >>> fig, ax = plt.subplots()
| >>> ax.hist(arr, bins=20)
| >>>
| >>> st.pyplot(fig)
|
| .. output::
| https://doc-pyplot.streamlit.app/
| height: 630px
|
| Matplotlib supports several types of "backends". If you're getting an
| error using Matplotlib with Streamlit, try setting your backend to "TkAgg"::
|
| echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc
|
| For more information, see https://matplotlib.org/faq/usage_faq.html.
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.radio.RadioMixin:
|
| radio(self, label: 'str', options: 'OptionSequence[T]', index: 'int | None' = 0, format_func: 'Callable[[Any], Any]' = <class 'str'>, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, horizontal: 'bool' = False, captions: 'Sequence[str] | None' = None, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'T | None' from RadioMixin
| Display a radio button widget.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this radio group is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| options : Iterable
| Labels for the select options in an ``Iterable``. This can be a
| ``list``, ``set``, or anything supported by ``st.dataframe``. If
| ``options`` is dataframe-like, the first column will be used. Each
| label will be cast to ``str`` internally by default.
|
| Labels can include markdown as described in the ``label`` parameter.
|
| index : int or None
| The index of the preselected option on first render. If ``None``,
| will initialize empty and return ``None`` until the user selects an option.
| Defaults to 0 (the first option).
|
| format_func : function
| Function to modify the display of radio options. It receives
| the raw option as an argument and should output the label to be
| shown for that option. This has no impact on the return value of
| the radio.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this radio's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the radio button if set to
| ``True``. The default is ``False``.
|
| horizontal : bool
| An optional boolean, which orients the radio group horizontally.
| The default is false (vertical buttons).
|
| captions : iterable of str or None
| A list of captions to show below each radio button. If None (default),
| no captions are shown.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "content", "stretch", or int
| The width of the radio button widget. This can be one of the
| following:
|
| - ``"content"`` (default): The width of the widget matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the widget matches the width of the
| parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Invalid query parameter values are ignored and removed
| from the URL. If ``index`` is ``None``, an empty query
| parameter (e.g., ``?my_key=``) clears the widget.
|
| Returns
| -------
| any
| The selected option or ``None`` if no option is selected.
|
| This is a copy of the selected option, not the original.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> genre = st.radio(
| ... "What's your favorite movie genre",
| ... [":rainbow[Comedy]", "***Drama***", "Documentary :movie_camera:"],
| ... captions=[
| ... "Laugh out loud.",
| ... "Get the popcorn.",
| ... "Never stop learning.",
| ... ],
| ... )
| >>>
| >>> if genre == ":rainbow[Comedy]":
| ... st.write("You selected comedy.")
| ... else:
| ... st.write("You didn't select comedy.")
|
| .. output::
| https://doc-radio.streamlit.app/
| height: 300px
|
| To initialize an empty radio widget, use ``None`` as the index value:
|
| >>> import streamlit as st
| >>>
| >>> genre = st.radio(
| ... "What's your favorite movie genre",
| ... [":rainbow[Comedy]", "***Drama***", "Documentary :movie_camera:"],
| ... index=None,
| ... )
| >>>
| >>> st.write("You selected:", genre)
|
| .. output::
| https://doc-radio-empty.streamlit.app/
| height: 300px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.selectbox.SelectboxMixin:
|
| selectbox(self, label: 'str', options: 'OptionSequence[T]', index: 'int | None' = 0, format_func: 'Callable[[Any], str]' = <class 'str'>, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, placeholder: 'str | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', accept_new_options: 'bool' = False, filter_mode: 'SelectWidgetFilterMode' = 'fuzzy', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'T | str | None' from SelectboxMixin
| Display a select widget.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this select widget is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| options : Iterable
| Labels for the select options in an ``Iterable``. This can be a
| ``list``, ``set``, or anything supported by ``st.dataframe``. If
| ``options`` is dataframe-like, the first column will be used. Each
| label will be cast to ``str`` internally by default.
|
| index : int or None
| The index of the preselected option on first render. If ``None``,
| will initialize empty and return ``None`` until the user selects an option.
| Defaults to 0 (the first option).
|
| format_func : function
| Function to modify the display of the options. It receives
| the raw option as an argument and should output the label to be
| shown for that option. This has no impact on the return value of
| the command.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``accept_new_options`` resets the widget even when
| a key is provided.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this selectbox's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| placeholder : str or None
| A string to display when no options are selected.
| If this is ``None`` (default), the widget displays placeholder text
| based on the widget's configuration:
|
| - "Choose an option" is displayed when options are available and
| ``accept_new_options=False``.
| - "Choose or add an option" is displayed when options are available
| and ``accept_new_options=True``.
| - "Add an option" is displayed when no options are available and
| ``accept_new_options=True``.
| - "No options to select" is displayed when no options are available
| and ``accept_new_options=False``. The widget is also disabled in
| this case.
|
| disabled : bool
| An optional boolean that disables the selectbox if set to ``True``.
| The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| accept_new_options : bool
| Whether the user can add a selection that isn't included in ``options``.
| If this is ``False`` (default), the user can only select from the
| items in ``options``. If this is ``True``, the user can enter a new
| item that doesn't exist in ``options``.
|
| When a user enters a new item, it is returned by the widget as a
| string. The new item is not added to the widget's drop-down menu.
| Streamlit will use a case-insensitive match from ``options`` before
| adding a new item.
|
| filter_mode : "fuzzy", "contains", "prefix", or None
| The matching mode used to filter options while the user types.
| If this is ``"fuzzy"`` (default), options are matched by in-order
| subsequence and sorted by match score. If this is ``"contains"``,
| options are matched by case-insensitive substring. If this is
| ``"prefix"``, options are matched by case-insensitive prefix. If
| this is ``None``, typing is disabled and the options are not
| filtered.
|
| ``filter_mode=None`` is incompatible with
| ``accept_new_options=True``.
|
| width : "stretch" or int
| The width of the selectbox widget. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Invalid query parameter values are ignored and removed
| from the URL. If ``index`` is ``None``, an empty query
| parameter (e.g., ``?my_key=``) clears the widget.
|
| Returns
| -------
| any
| The selected option or ``None`` if no option is selected.
|
| This is a copy of the selected option, not the original.
|
| Examples
| --------
| **Example 1: Use a basic selectbox widget**
|
| If no index is provided, the first option is selected by default.
|
| >>> import streamlit as st
| >>>
| >>> option = st.selectbox(
| ... "How would you like to be contacted?",
| ... ("Email", "Home phone", "Mobile phone"),
| ... )
| >>>
| >>> st.write("You selected:", option)
|
| .. output::
| https://doc-selectbox.streamlit.app/
| height: 320px
|
| **Example 2: Use a selectbox widget with no initial selection**
|
| To initialize an empty selectbox, use ``None`` as the index value.
|
| >>> import streamlit as st
| >>>
| >>> option = st.selectbox(
| ... "How would you like to be contacted?",
| ... ("Email", "Home phone", "Mobile phone"),
| ... index=None,
| ... placeholder="Select contact method...",
| ... )
| >>>
| >>> st.write("You selected:", option)
|
| .. output::
| https://doc-selectbox-empty.streamlit.app/
| height: 320px
|
| **Example 3: Let users add a new option**
|
| To allow users to add a new option that isn't included in the
| ``options`` list, use the ``accept_new_options=True`` parameter. You
| can also customize the placeholder text.
|
| >>> import streamlit as st
| >>>
| >>> option = st.selectbox(
| ... "Default email",
| ... ["foo@example.com", "bar@example.com", "baz@example.com"],
| ... index=None,
| ... placeholder="Select a saved email or enter a new one",
| ... accept_new_options=True,
| ... )
| >>>
| >>> st.write("You selected:", option)
|
| .. output::
| https://doc-selectbox-accept-new-options.streamlit.app/
| height: 320px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.select_slider.SelectSliderMixin:
|
| select_slider(self, label: 'str', options: 'OptionSequence[T]' = (), value: 'T | Sequence[T] | None' = None, format_func: 'Callable[[Any], Any]' = <class 'str'>, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'T | tuple[T, T]' from SelectSliderMixin
| Display a slider widget to select items from a list.
|
| This also allows you to render a range slider by passing a two-element
| tuple or list as the ``value``.
|
| The difference between ``st.select_slider`` and ``st.slider`` is that
| ``select_slider`` accepts any datatype and takes an iterable set of
| options, while ``st.slider`` only accepts numerical or date/time data and
| takes a range as input.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this slider is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| options : Iterable
| Labels for the select options in an ``Iterable``. This can be a
| ``list``, ``set``, or anything supported by ``st.dataframe``. If
| ``options`` is dataframe-like, the first column will be used. Each
| label will be cast to ``str`` internally by default.
|
| Each item in the iterable can optionally contain GitHub-flavored
| Markdown, subject to the same limitations described in the
| ``label`` parameter.
|
| value : a supported type or a tuple/list of supported types or None
| The value of the slider when it first renders. If a tuple/list
| of two values is passed here, then a range slider with those lower
| and upper bounds is rendered. For example, if set to `(1, 10)` the
| slider will have a selectable range between 1 and 10.
| Defaults to first option.
|
| format_func : function
| Function to modify the display of the labels from the options.
| argument. It receives the option as an argument and its output
| will be cast to str.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this select_slider's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the select slider if set to
| ``True``. The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "stretch" or int
| The width of the slider widget. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Invalid query parameter values are ignored and removed
| from the URL. Range select sliders use repeated parameters
| (e.g., ``?color=red&color=blue``).
|
| Returns
| -------
| any value or tuple of any value
| The current value of the slider widget. The return type will match
| the data type of the value parameter.
|
| This contains copies of the selected options, not the originals.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> color = st.select_slider(
| ... "Select a color of the rainbow",
| ... options=[
| ... "red",
| ... "orange",
| ... "yellow",
| ... "green",
| ... "blue",
| ... "indigo",
| ... "violet",
| ... ],
| ... )
| >>> st.write("My favorite color is", color)
|
| And here's an example of a range select slider:
|
| >>> import streamlit as st
| >>>
| >>> start_color, end_color = st.select_slider(
| ... "Select a range of color wavelength",
| ... options=[
| ... "red",
| ... "orange",
| ... "yellow",
| ... "green",
| ... "blue",
| ... "indigo",
| ... "violet",
| ... ],
| ... value=("red", "blue"),
| ... )
| >>> st.write("You selected wavelengths between", start_color, "and", end_color)
|
| .. output::
| https://doc-select-slider.streamlit.app/
| height: 450px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.slider.SliderMixin:
|
| slider(self, label: 'str', min_value: 'SliderScalar | None' = None, max_value: 'SliderScalar | None' = None, value: 'SliderValue | None' = None, step: 'SliderStep | None' = None, format: 'str | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'Any' from SliderMixin
| Display a slider widget.
|
| This supports int, float, date, time, and datetime types.
|
| This also allows you to render a range slider by passing a two-element
| tuple or list as the ``value``.
|
| The difference between ``st.slider`` and ``st.select_slider`` is that
| ``slider`` only accepts numerical or date/time data and takes a range as
| input, while ``select_slider`` accepts any datatype and takes an iterable
| set of options.
|
| .. note::
| Integer values exceeding +/- ``(1<<53) - 1`` cannot be accurately
| stored or returned by the widget due to serialization constraints
| between the Python server and JavaScript client. You must handle
| such numbers as floats, leading to a loss in precision.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this slider is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| min_value : a supported type or None
| The minimum permitted value.
| If this is ``None`` (default), the minimum value depends on the
| type as follows:
|
| - integer: ``0``
| - float: ``0.0``
| - date or datetime: ``value - timedelta(days=14)``
| - time: ``time.min``
|
| max_value : a supported type or None
| The maximum permitted value.
| If this is ``None`` (default), the maximum value depends on the
| type as follows:
|
| - integer: ``100``
| - float: ``1.0``
| - date or datetime: ``value + timedelta(days=14)``
| - time: ``time.max``
|
| value : a supported type or a tuple/list of supported types or None
| The value of the slider when it first renders. If a tuple/list
| of two values is passed here, then a range slider with those lower
| and upper bounds is rendered. For example, if set to `(1, 10)` the
| slider will have a selectable range between 1 and 10.
| This defaults to ``min_value``. If the type is not otherwise
| specified in any of the numeric parameters, the widget will have an
| integer value.
|
| step : int, float, timedelta, or None
| The stepping interval.
| Defaults to 1 if the value is an int, 0.01 if a float,
| timedelta(days=1) if a date/datetime, timedelta(minutes=15) if a time
| (or if max_value - min_value < 1 day)
|
| format : str or None
| A printf-style format string or a predefined format name controlling
| how the interface should display values. This does not impact the
| return value.
|
| For integers and floats, you can use a printf-style format string
| or one of the following predefined formats:
|
| - ``"plain"``: Show the full number without formatting (e.g. ``1234.567``).
| - ``"localized"``: Show the number in the user's locale format (e.g. ``1,234.567``).
| - ``"percent"``: Show as a percentage (e.g. ``50%`` from ``0.5``).
| - ``"dollar"``: Show as US dollars (e.g. ``$1,234.57``).
| - ``"euro"``: Show as euros (e.g. ``€1,234.57``).
| - ``"yen"``: Show as Japanese yen (e.g. ``¥1,235``).
| - ``"compact"``: Show in compact notation (e.g. ``1.2K``).
| - ``"scientific"``: Show in scientific notation (e.g. ``1.235E3``).
| - ``"engineering"``: Show in engineering notation (e.g. ``1.235E3``).
| - ``"accounting"``: Show in accounting format with parentheses for negatives.
| - ``"bytes"``: Show in byte units (e.g. ``1.2KB``).
|
| For information about printf-style format strings, see
| `sprintf.js
| <https://github.com/alexei/sprintf.js?tab=readme-ov-file#format-specification>`_.
| For example, ``format="%0.1f"`` adjusts the displayed decimal
| precision to only show one digit after the decimal. Use ``,`` for
| thousand separators (e.g. ``"%,d"`` yields ``"1,234"``).
|
| For datetimes, dates, and times, you can use a momentJS format string
| or one of the following predefined formats:
|
| - ``"localized"``: Show in the user's locale format.
| - ``"distance"``: Show as relative time (e.g. ``"2 hours ago"``).
| - ``"calendar"``: Show as calendar time (e.g. ``"Tomorrow 12:00"``).
| Works best with datetime values. For date-only values, displays
| relative day names (e.g. ``"Yesterday"``). For time-only values,
| this format may produce unexpected results.
| - ``"iso8601"``: Show in ISO 8601 format.
|
| For information about momentJS format strings, see
| `momentJS <https://momentjs.com/docs/#/displaying/format/>`_.
| For example, ``format="ddd ha"`` adjusts the displayed datetime to
| show the day of the week and the hour ("Tue 8pm").
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``min_value``, ``max_value``, or ``step`` resets
| the widget even when a key is provided, because those
| parameters constrain valid values.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this slider's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the slider if set to ``True``.
| The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "stretch" or int
| The width of the slider widget. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Invalid query parameter values are ignored and removed
| from the URL. Range sliders use repeated parameters (e.g.,
| ``?price=10&price=90``).
|
| Returns
| -------
| int/float/date/time/datetime or tuple of int/float/date/time/datetime
| The current value of the slider widget. The return type will match
| the data type of the value parameter.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> age = st.slider("How old are you?", 0, 130, 25)
| >>> st.write("I'm ", age, "years old")
|
| And here's an example of a range slider:
|
| >>> import streamlit as st
| >>>
| >>> values = st.slider("Select a range of values", 0.0, 100.0, (25.0, 75.0))
| >>> st.write("Values:", values)
|
| This is a range time slider:
|
| >>> import streamlit as st
| >>> from datetime import time
| >>>
| >>> appointment = st.slider(
| ... "Schedule your appointment:", value=(time(11, 30), time(12, 45))
| ... )
| >>> st.write("You're scheduled for:", appointment)
|
| Finally, a datetime slider:
|
| >>> import streamlit as st
| >>> from datetime import datetime
| >>>
| >>> start_time = st.slider(
| ... "When do you start?",
| ... value=datetime(2020, 1, 1, 9, 30),
| ... format="MM/DD/YY - hh:mm",
| ... )
| >>> st.write("Start time:", start_time)
|
| .. output::
| https://doc-slider.streamlit.app/
| height: 300px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.snow.SnowMixin:
|
| snow(self) -> 'DeltaGenerator' from SnowMixin
| Draw celebratory snowfall.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.snow()
|
| ...then watch your app and get ready for a cool celebration!
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.space.SpaceMixin:
|
| space(self, size: 'SpaceSize' = 'small') -> 'DeltaGenerator' from SpaceMixin
| Add vertical or horizontal space.
|
| This command adds space in the direction of its parent container. In
| a vertical layout, it adds vertical space. In a horizontal layout, it
| adds horizontal space.
|
| Parameters
| ----------
| size : "xxsmall", "xsmall", "small", "medium", "large", "xlarge", "xxlarge", "stretch", or int
| The size of the space. This can be one of the following values:
|
| - ``"xxsmall"``: 0.25rem, matching the ``"xxsmall"`` gap in
| ``st.container`` and ``st.columns``.
| - ``"xsmall"``: 0.5rem, matching the ``"xsmall"`` gap in
| ``st.container`` and ``st.columns``.
| - ``"small"`` (default): 0.75rem, which is the height of a widget
| label. This is useful for aligning buttons with labeled widgets.
| - ``"medium"``: 2.5rem, which is the height of a button or
| (unlabeled) input field.
| - ``"large"``: 4.25rem, which is the height of a labeled input
| field or unlabeled media widget, like ``st.file_uploader``.
| - ``"xlarge"``: 6rem, matching the ``"xlarge"`` gap in
| ``st.container`` and ``st.columns``.
| - ``"xxlarge"``: 8rem, matching the ``"xxlarge"`` gap in
| ``st.container`` and ``st.columns``.
| - ``"stretch"``: Expands to fill remaining space in the container.
| - An integer: Fixed size in pixels.
|
| Examples
| --------
| **Example 1: Use vertical space to align elements**
|
| Use small spaces to replace label heights. Use medium spaces to replace
| two label heights or a button.
|
| >>> import streamlit as st
| >>>
| >>> left, middle, right = st.columns(3)
| >>>
| >>> left.space("medium")
| >>> left.button("Left button", width="stretch")
| >>>
| >>> middle.space("small")
| >>> middle.text_input("Middle input")
| >>>
| >>> right.audio_input("Right uploader")
|
| .. output::
| https://doc-space-vertical.streamlit.app/
| height: 260px
|
| **Example 2: Add horizontal space in a container**
|
| Use stretch space to float elements left and right.
|
| >>> import streamlit as st
| >>>
| >>> with st.container(horizontal=True):
| ... st.button("Left")
| ... st.space("stretch")
| ... st.button("Right")
|
| .. output::
| https://doc-space-horizontal.streamlit.app/
| height: 200px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.spinner.SpinnerMixin:
|
| spinner(self, text: 'str' = 'In progress...', *, show_time: 'bool' = False, _cache: 'bool' = False, width: 'Width' = 'content') -> 'Iterator[None]' from SpinnerMixin
| Display a loading spinner while executing a block of code.
|
| Parameters
| ----------
| text : str
| The text to display next to the spinner. This defaults to
| ``"In progress..."``.
|
| The text can optionally contain GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional, supported
| Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| show_time : bool
| Whether to show the elapsed time next to the spinner text. If this is
| ``False`` (default), no time is displayed. If this is ``True``,
| elapsed time is displayed with a precision of 0.1 seconds. The time
| format is not configurable.
|
| width : "content", "stretch", or int
| The width of the spinner element. This can be one of the following:
|
| - ``"content"`` (default): The width of the element matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the element matches the width of the
| parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Examples
| --------
| >>> import streamlit as st
| >>> import time
| >>>
| >>> with st.spinner("Wait for it...", show_time=True):
| >>> time.sleep(5)
| >>> st.success("Done!")
| >>> st.button("Rerun")
|
| .. output::
| https://doc-spinner.streamlit.app/
| height: 210px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.table.TableMixin:
|
| table(self, data: 'Data' = None, *, border: "bool | Literal['horizontal']" = True, width: 'Width' = 'stretch', height: 'Height' = 'content', hide_index: 'bool | None' = None, hide_header: 'bool | None' = None) -> 'DeltaGenerator' from TableMixin
| Display a static table.
|
| While ``st.dataframe`` is geared towards large datasets and interactive
| data exploration, ``st.table`` is useful for displaying small, styled
| tables without sorting or scrolling. For example, ``st.table`` may be
| the preferred way to display a confusion matrix or leaderboard.
| Additionally, ``st.table`` supports Markdown.
|
| Parameters
| ----------
| data : Anything supported by st.dataframe
| The table data.
|
| All cells including the index and column headers can optionally
| contain GitHub-flavored Markdown. Syntax information can be found
| at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| border : bool or "horizontal"
| Whether to show borders around the table and between cells. This can be one
| of the following:
|
| - ``True`` (default): Show borders around the table and between cells.
| - ``False``: Don't show any borders.
| - ``"horizontal"``: Show only horizontal borders between rows.
|
| width : "stretch", "content", or int
| The width of the table element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Row index columns are sticky only when the content overflows a
| specified integer width. Otherwise, they aren't sticky.
|
| height : "stretch", "content", or int
| The height of the table element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content, showing all rows.
| - ``"stretch"``: The height of the element expands to fill the
| available vertical space in its parent container. When multiple
| elements with stretch height are in the same container, they
| share the available vertical space evenly.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the table content exceeds this height,
| scrolling is enabled with sticky headers.
|
| hide_index : bool or None
| Whether to hide the index column. This can be one of the following
| values:
|
| - ``None`` (default): Hide the index column if it's a default
| ``RangeIndex``. Show custom indices.
| - ``True``: Always hide the index column.
| - ``False``: Always show the index column.
|
| hide_header : bool or None
| Whether to hide the column header row. This can be one of the
| following values:
|
| - ``None`` (default): Auto-hide headers for data formats without
| user-defined column names, like ``dict``, ``list``, and
| ``numpy.ndarray``. Show headers for data with explicit column
| names, like ``pandas.DataFrame``.
| - ``True``: Always hide the column header row, including all levels
| of ``MultiIndex`` headers.
| - ``False``: Always show the column header row.
|
| Examples
| --------
| **Example 1: Display a confusion matrix as a static table**
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import pandas as pd
| import streamlit as st
|
| confusion_matrix = pd.DataFrame(
| {
| "Predicted Cat": [85, 3, 2, 1],
| "Predicted Dog": [2, 78, 4, 0],
| "Predicted Bird": [1, 5, 72, 3],
| "Predicted Fish": [0, 2, 1, 89],
| },
| index=["Actual Cat", "Actual Dog", "Actual Bird", "Actual Fish"],
| )
| st.table(confusion_matrix)
|
| .. output::
| https://doc-table-confusion.streamlit.app/
| height: 250px
|
| **Example 2: Display a product leaderboard with Markdown and horizontal borders**
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| product_data = {
| "Product": [
| ":material/devices: Widget Pro",
| ":material/smart_toy: Smart Device",
| ":material/inventory: Premium Kit",
| ],
| "Category": [":blue[Electronics]", ":green[IoT]", ":violet[Bundle]"],
| "Stock": ["🟢 Full", "🟡 Low", "🔴 Empty"],
| "Units sold": [1247, 892, 654],
| "Revenue": [125000, 89000, 98000],
| }
| st.table(product_data, border="horizontal")
|
| .. output::
| https://doc-table-horizontal-border.streamlit.app/
| height: 200px
|
| **Example 3: Display a scrollable table with fixed height**
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import pandas as pd
| import streamlit as st
| from numpy.random import default_rng as rng
|
| df = pd.DataFrame(
| rng(0).standard_normal((50, 5)), columns=["A", "B", "C", "D", "E"]
| )
| st.table(df, height=300)
|
| **Example 4: Display key-value data**
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| st.table(
| {
| ":material/folder: Project": "**Streamlit** - The fastest way to build data apps",
| ":material/code: Repository": "[github.com/streamlit/streamlit](https://github.com/streamlit/streamlit)",
| ":material/new_releases: Version": ":gray-badge[1.45.0]",
| ":material/license: License": ":green-badge[Apache 2.0]",
| ":material/group: Maintainers": ":blue-badge[Core Team] :violet-badge[Community]",
| },
| border="horizontal",
| width="content",
| )
|
| .. output::
| https://doc-table-auto-header.streamlit.app/
| height: 250px
|
| **Example 5: Display a minimal table without index and headers**
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import pandas as pd
| import streamlit as st
|
| df = pd.DataFrame({"Name": ["Alice", "Bob"], "Age": [25, 30]})
| st.table(df, hide_index=True, hide_header=True)
|
| .. output::
| https://doc-table-hide-header-and-index.streamlit.app/
| height: 200px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.json.JsonMixin:
|
| json(self, body: 'object', *, expanded: 'bool | int' = True, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' from JsonMixin
| Display an object or string as a pretty-printed, interactive JSON string.
|
| Parameters
| ----------
| body : object or str
| The object to print as JSON. All referenced objects should be
| serializable to JSON as well. If object is a string, we assume it
| contains serialized JSON.
|
| expanded : bool or int
| The initial expansion state of the JSON element. This can be one
| of the following:
|
| - ``True`` (default): The element is fully expanded.
| - ``False``: The element is fully collapsed.
| - An integer: The element is expanded to the depth specified. The
| integer must be non-negative. ``expanded=0`` is equivalent to
| ``expanded=False``.
|
| Regardless of the initial expansion state, users can collapse or
| expand any key-value pair to show or hide any part of the object.
|
| width : "stretch" or int
| The width of the JSON element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.json(
| ... {
| ... "foo": "bar",
| ... "stuff": [
| ... "stuff 1",
| ... "stuff 2",
| ... "stuff 3",
| ... ],
| ... "level1": {"level2": {"level3": {"a": "b"}}},
| ... },
| ... expanded=2,
| ... )
|
| .. output::
| https://doc-json.streamlit.app/
| height: 385px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.text.TextMixin:
|
| text(self, body: 'SupportsStr', *, help: 'str | None' = None, width: 'Width' = 'content', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' from TextMixin
| Write text without Markdown or HTML parsing.
|
| For monospace text, use |st.code|_.
|
| .. |st.code| replace:: ``st.code``
| .. _st.code: https://docs.streamlit.io/develop/api-reference/text/st.code
|
| Parameters
| ----------
| body : str
| The string to display.
|
| help : str or None
| A tooltip that gets displayed next to the text. If this is ``None``
| (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| width : "content", "stretch", or int
| The width of the text element. This can be one of the following:
|
| - ``"content"`` (default): The width of the element matches the
| width of its content, but doesn't exceed the width of the parent
| container.
| - ``"stretch"``: The width of the element matches the width of the
| parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| text_alignment : "left", "center", "right", or "justify"
| The horizontal alignment of the text within the element. This can
| be one of the following:
|
| - ``"left"`` (default): Text is aligned to the left edge.
| - ``"center"``: Text is centered.
| - ``"right"``: Text is aligned to the right edge.
| - ``"justify"``: Text is justified (stretched to fill the available
| width with the last line left-aligned).
|
| .. note::
| For text alignment to have a visible effect, the element's
| width must be wider than its content. If you use
| ``width="content"`` with short text, the alignment may not be
| noticeable.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.text("This is text\n[and more text](that's not a Markdown link).")
|
| .. output::
| https://doc-text.streamlit.app/
| height: 220px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.text_widgets.TextWidgetsMixin:
|
| text_area(self, label: 'str', value: 'str | SupportsStr | None' = '', height: 'Height | None' = None, max_chars: 'int | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, placeholder: 'str | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'str | None' from TextWidgetsMixin
| Display a multi-line text input widget.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this input is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| value : object or None
| The text value of this widget when it first renders. This will be
| cast to str internally. If ``None``, will initialize empty and
| return ``None`` until the user provides input. Defaults to empty string.
|
| height : "content", "stretch", int, or None
| The height of the text area widget. This can be one of the
| following:
|
| - ``None`` (default): The height of the widget fits three lines.
| - ``"content"``: The height of the widget matches the
| height of its content.
| - ``"stretch"``: The height of the widget matches the height of
| its content or the height of the parent container, whichever is
| larger. If the widget is not in a parent container, the height
| of the widget matches the height of its content.
| - An integer specifying the height in pixels: The widget has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| The widget's height can't be smaller than the height of two lines.
| When ``label_visibility="collapsed"``, the minimum height is 68
| pixels. Otherwise, the minimum height is 98 pixels.
|
| max_chars : int or None
| Maximum number of characters allowed in text area.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``max_chars`` resets the widget even when a key
| is provided.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this text_area's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| placeholder : str or None
| An optional string displayed when the text area is empty. If None,
| no text is displayed.
|
| disabled : bool
| An optional boolean that disables the text area if set to ``True``.
| The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "stretch" or int
| The width of the text area widget. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| An empty query parameter (e.g., ``?my_key=``) clears the
| widget.
|
| Returns
| -------
| str or None
| The current value of the text area widget or ``None`` if no value has been
| provided by the user.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> txt = st.text_area(
| ... "Text to analyze",
| ... "It was the best of times, it was the worst of times, it was the age of "
| ... "wisdom, it was the age of foolishness, it was the epoch of belief, it "
| ... "was the epoch of incredulity, it was the season of Light, it was the "
| ... "season of Darkness, it was the spring of hope, it was the winter of "
| ... "despair, (...)",
| ... )
| >>>
| >>> st.write(f"You wrote {len(txt)} characters.")
|
| .. output::
| https://doc-text-area.streamlit.app/
| height: 300px
|
| text_input(self, label: 'str', value: 'str | SupportsStr | None' = '', max_chars: 'int | None' = None, key: 'Key | None' = None, type: "Literal['default', 'password']" = 'default', help: 'str | None' = None, autocomplete: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, placeholder: 'str | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'str | None' from TextWidgetsMixin
| Display a single-line text input widget.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this input is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| value : object or None
| The text value of this widget when it first renders. This will be
| cast to str internally. If ``None``, will initialize empty and
| return ``None`` until the user provides input. Defaults to empty string.
|
| max_chars : int or None
| Max number of characters allowed in text input.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``max_chars`` resets the widget even when a key
| is provided.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| type : "default" or "password"
| The type of the text input. This can be either "default" (for
| a regular text input), or "password" (for a text input that
| masks the user's typed value). Defaults to "default".
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| autocomplete : str
| An optional value that will be passed to the <input> element's
| autocomplete property. If unspecified, this value will be set to
| "new-password" for "password" inputs, and the empty string for
| "default" inputs. For more details, see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
|
| on_change : callable
| An optional callback invoked when this text input's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| placeholder : str or None
| An optional string displayed when the text input is empty. If None,
| no text is displayed.
|
| disabled : bool
| An optional boolean that disables the text input if set to
| ``True``. The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
|
| icon : str, None
| An optional emoji or icon to display within the input field to the
| left of the value. If ``icon`` is ``None`` (default), no icon is
| displayed. If ``icon`` is a string, the following options are
| valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols \
| <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| width : "stretch" or int
| The width of the text input widget. This can be one of the
| following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| This can't be used with ``type="password"``. An empty
| query parameter (e.g., ``?my_key=``) clears the widget.
|
| Returns
| -------
| str or None
| The current value of the text input widget or ``None`` if no value has been
| provided by the user.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> title = st.text_input("Movie title", "Life of Brian")
| >>> st.write("The current movie title is", title)
|
| .. output::
| https://doc-text-input.streamlit.app/
| height: 260px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.time_widgets.TimeWidgetsMixin:
|
| date_input(self, label: 'str', value: 'DateValue' = 'today', min_value: 'NullableScalarDateValue' = None, max_value: 'NullableScalarDateValue' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, format: 'str' = 'YYYY/MM/DD', disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'DateWidgetReturn' from TimeWidgetsMixin
| Display a date input widget.
|
| The date input widget can be configured to accept a single date or a
| date range. The first day of the week is determined from the user's
| locale in their browser.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this date input is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| value : "today", datetime.date, datetime.datetime, str, list/tuple of these, or None
| The value of this widget when it first renders. This can be one of
| the following:
|
| - ``"today"`` (default): The widget initializes with the current date.
| - A ``datetime.date`` or ``datetime.datetime`` object: The widget
| initializes with the given date, ignoring any time if included.
| - An ISO-formatted date (YYYY-MM-DD) or datetime
| (YYYY-MM-DD hh:mm:ss) string: The widget initializes with the
| given date, ignoring any time if included.
| - A list or tuple with up to two of the above: The widget will
| initialize with the given date interval and return a tuple of the
| selected interval. You can pass an empty list to initialize the
| widget with an empty interval or a list with one value to
| initialize only the beginning date of the iterval.
| - ``None``: The widget initializes with no date and returns
| ``None`` until the user selects a date.
|
| min_value : "today", datetime.date, datetime.datetime, str, or None
| The minimum selectable date. This can be any of the date types
| accepted by ``value``, except list or tuple.
|
| If this is ``None`` (default), the minimum selectable date is ten
| years before the initial value. If the initial value is an
| interval, the minimum selectable date is ten years before the start
| date of the interval. If no initial value is set, the minimum
| selectable date is ten years before today.
|
| max_value : "today", datetime.date, datetime.datetime, str, or None
| The maximum selectable date. This can be any of the date types
| accepted by ``value``, except list or tuple.
|
| If this is ``None`` (default), the maximum selectable date is ten
| years after the initial value. If the initial value is an interval,
| the maximum selectable date is ten years after the end date of the
| interval. If no initial value is set, the maximum selectable date
| is ten years after today.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``format`` resets the widget even when a key is
| provided.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this date_input's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| format : str
| A format string controlling how the interface should display dates.
| Supports ``"YYYY/MM/DD"`` (default), ``"DD/MM/YYYY"``, or ``"MM/DD/YYYY"``.
| You may also use a period (.) or hyphen (-) as separators.
|
| disabled : bool
| An optional boolean that disables the date input if set to
| ``True``. The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "stretch" or int
| The width of the date input widget. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Dates use ISO 8601 format (YYYY-MM-DD) in the URL. Invalid
| query parameter values are ignored and removed from the URL.
| If ``value`` is ``None``, an empty query parameter (e.g.,
| ``?vacation=``) clears the widget. Date ranges use repeated
| parameters (e.g.,
| ``?vacation=2025-01-01&vacation=2025-01-31``).
|
| Returns
| -------
| datetime.date or a tuple with 0-2 dates or None
| The current value of the date input widget or ``None`` if no date has been
| selected.
|
| Examples
| --------
| **Example 1: Basic usage**
|
| >>> import datetime
| >>> import streamlit as st
| >>>
| >>> d = st.date_input("When's your birthday", datetime.date(2019, 7, 6))
| >>> st.write("Your birthday is:", d)
|
| .. output::
| https://doc-date-input.streamlit.app/
| height: 380px
|
| **Example 2: Date range**
|
| >>> import datetime
| >>> import streamlit as st
| >>>
| >>> today = datetime.datetime.now()
| >>> next_year = today.year + 1
| >>> jan_1 = datetime.date(next_year, 1, 1)
| >>> dec_31 = datetime.date(next_year, 12, 31)
| >>>
| >>> d = st.date_input(
| ... "Select your vacation for next year",
| ... (jan_1, datetime.date(next_year, 1, 7)),
| ... jan_1,
| ... dec_31,
| ... format="MM.DD.YYYY",
| ... )
| >>> d
|
| .. output::
| https://doc-date-input1.streamlit.app/
| height: 380px
|
| **Example 3: Empty initial value**
|
| To initialize an empty date input, use ``None`` as the value:
|
| >>> import datetime
| >>> import streamlit as st
| >>>
| >>> d = st.date_input("When's your birthday", value=None)
| >>> st.write("Your birthday is:", d)
|
| .. output::
| https://doc-date-input-empty.streamlit.app/
| height: 380px
|
| datetime_input(self, label: 'str', value: 'DateTimeValue' = 'now', min_value: 'DateTimeValue' = None, max_value: 'DateTimeValue' = None, *, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, format: 'str' = 'YYYY/MM/DD', step: 'int | timedelta' = datetime.timedelta(seconds=900), disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'datetime | None' from TimeWidgetsMixin
| Display a date and time input widget.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this datetime input is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| value : "now", datetime.datetime, datetime.date, datetime.time, str, or None
| The value of this widget when it first renders. This can be one of
| the following:
|
| - ``"now"`` (default): The widget initializes with the current date and time.
| - A ``datetime.datetime`` object: The widget initializes with the given
| datetime, stripping any timezone information.
| - A ``datetime.date`` object: The widget initializes with the given date
| at 00:00.
| - A ``datetime.time`` object: The widget initializes with today's date
| and the provided time.
| - An ISO-formatted datetime (YYYY-MM-DD hh:mm[:ss]) or date/time
| string: The widget initializes with the parsed value.
| - ``None``: The widget initializes with no value and returns ``None``
| until the user selects a datetime.
|
| min_value : "now", datetime.datetime, datetime.date, datetime.time, str, or None
| The minimum selectable datetime. This can be any of the datetime
| types accepted by ``value``.
|
| If this is ``None`` (default), the minimum selectable datetime is
| ten years before the initial value. If no initial value is set, the
| minimum selectable datetime is ten years before today at 00:00.
|
| max_value : "now", datetime.datetime, datetime.date, datetime.time, str, or None
| The maximum selectable datetime. This can be any of the datetime
| types accepted by ``value``.
|
| If this is ``None`` (default), the maximum selectable datetime is
| ten years after the initial value. If no initial value is set, the
| maximum selectable datetime is ten years after today at 23:59.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``format`` or ``step`` resets the widget even
| when a key is provided.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this datetime_input's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| format : str
| A format string controlling how the interface displays dates.
| Supports ``"YYYY/MM/DD"`` (default), ``"DD/MM/YYYY"``, or ``"MM/DD/YYYY"``.
| You may also use a period (.) or hyphen (-) as separators. This
| doesn't affect the time format.
|
| step : int or timedelta
| The stepping interval in seconds. This defaults to ``900`` (15
| minutes). You can also pass a ``datetime.timedelta`` object. The
| value must be between 60 seconds and 23 hours.
|
| disabled : bool
| An optional boolean that disables the widget if set to ``True``.
| The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| width : "stretch" or int
| The width of the widget. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the widget matches the width
| of the parent container.
| - An integer specifying the width in pixels: The widget has a fixed
| width. If the specified width is greater than the width of the
| parent container, the widget matches the container width.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Datetimes use ISO 8601 format (YYYY-MM-DDThh:mm) in the URL.
| Invalid query parameter values are ignored and removed from
| the URL. If ``value`` is ``None``, an empty query parameter
| (e.g., ``?my_key=``) clears the widget.
|
| Returns
| -------
| datetime.datetime or None
| The current value of the datetime input widget (without timezone)
| or ``None`` if no value has been selected.
|
| Examples
| --------
| **Example 1: Basic usage**
|
| >>> import datetime
| >>> import streamlit as st
| >>>
| >>> event_time = st.datetime_input(
| ... "Schedule your event",
| ... datetime.datetime(2025, 11, 19, 16, 45),
| ... )
| >>> st.write("Event scheduled for", event_time)
|
| .. output::
| https://doc-datetime-input.streamlit.app/
| height: 500px
|
| **Example 2: Empty initial value**
|
| To initialize an empty datetime input, use ``None`` as the value:
|
| >>> import datetime
| >>> import streamlit as st
| >>>
| >>> event_time = st.datetime_input("Schedule your event", value=None)
| >>> st.write("Event scheduled for", event_time)
|
| .. output::
| https://doc-datetime-input-empty.streamlit.app/
| height: 500px
|
| time_input(self, label: 'str', value: 'TimeValue | None' = 'now', key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', step: 'int | timedelta' = datetime.timedelta(seconds=900), width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'time | None' from TimeWidgetsMixin
| Display a time input widget.
|
| Parameters
| ----------
| label : str
| A short label explaining to the user what this time input is for.
| The label can optionally contain GitHub-flavored Markdown of the
| following types: Bold, Italics, Strikethroughs, Inline Code, Links,
| and Images. Images display like icons, with a max height equal to
| the font height.
|
| Unsupported Markdown elements are unwrapped so only their children
| (text contents) render. Common block-level Markdown (headings,
| lists, blockquotes) is automatically escaped and displays as
| literal text in labels.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| For accessibility reasons, you should never set an empty label, but
| you can hide it with ``label_visibility`` if needed. In the future,
| we may disallow empty labels by raising an exception.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| value : "now", datetime.time, datetime.datetime, str, or None
| The value of this widget when it first renders. This can be one of
| the following:
|
| - ``"now"`` (default): The widget initializes with the current time.
| - A ``datetime.time`` or ``datetime.datetime`` object: The widget
| initializes with the given time, ignoring any date if included.
| - An ISO-formatted time (hh:mm[:ss.sss]) or datetime
| (YYYY-MM-DD hh:mm[:ss]) string: The widget initializes with the
| given time, ignoring any date if included.
| - ``None``: The widget initializes with no time and returns
| ``None`` until the user selects a time.
|
| key : str, int, or None
| An optional string or integer to use as the unique key for
| the widget. If this is ``None`` (default), a key will be
| generated for the widget based on the values of the other
| parameters. No two widgets may have the same key. Assigning
| a key stabilizes the widget's identity and preserves its
| state across reruns even when other parameters change.
|
| .. note::
| Changing ``step`` resets the widget even when a key is
| provided, because it constrains valid values.
|
| A key lets you read or update the widget's value via
| ``st.session_state[key]``. For more details, see `Widget
| behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| help : str or None
| A tooltip that gets displayed next to the widget label. Streamlit
| only displays the tooltip when ``label_visibility="visible"``. If
| this is ``None`` (default), no tooltip is displayed.
|
| The tooltip can optionally contain GitHub-flavored Markdown,
| including the Markdown directives described in the ``body``
| parameter of ``st.markdown``.
|
| on_change : callable
| An optional callback invoked when this time_input's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| disabled : bool
| An optional boolean that disables the time input if set to
| ``True``. The default is ``False``.
|
| label_visibility : "visible", "hidden", or "collapsed"
| The visibility of the label. The default is ``"visible"``. If this
| is ``"hidden"``, Streamlit displays an empty spacer instead of the
| label, which can help keep the widget aligned with other widgets.
| If this is ``"collapsed"``, Streamlit displays no label or spacer.
|
| step : int or timedelta
| The stepping interval in seconds. This defaults to ``900`` (15
| minutes). You can also pass a ``datetime.timedelta`` object. The
| value must be between 60 seconds and 23 hours.
|
| width : "stretch" or int
| The width of the time input widget. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the widget matches the
| width of the parent container.
| - An integer specifying the width in pixels: The widget has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the widget matches the width
| of the parent container.
|
| bind : "query-params" or None
| Binding mode for syncing the widget's value with a URL query
| parameter. If this is ``None`` (default), the widget's value
| is not synced to the URL. When this is set to
| ``"query-params"``, changes to the widget update the URL, and
| the widget can be initialized or updated through a query
| parameter in the URL. This requires ``key`` to be set. The
| key is used as the query parameter name.
|
| When the widget's value equals its default, the query
| parameter is removed from the URL to keep it clean. A bound
| query parameter can't be set or deleted through
| ``st.query_params``; it can only be programmatically changed
| through ``st.session_state``.
|
| Times use HH:MM format in the URL. Invalid query parameter
| values are ignored and removed from the URL. If ``value``
| is ``None``, an empty query parameter (e.g., ``?my_key=``)
| clears the widget.
|
| Returns
| -------
| datetime.time or None
| The current value of the time input widget or ``None`` if no time has been
| selected.
|
| Examples
| --------
| **Example 1: Basic usage**
|
| >>> import datetime
| >>> import streamlit as st
| >>>
| >>> t = st.time_input("Set an alarm for", datetime.time(8, 45))
| >>> st.write("Alarm is set for", t)
|
| .. output::
| https://doc-time-input.streamlit.app/
| height: 260px
|
| **Example 2: Empty initial value**
|
| To initialize an empty time input, use ``None`` as the value:
|
| >>> import datetime
| >>> import streamlit as st
| >>>
| >>> t = st.time_input("Set an alarm for", value=None)
| >>> st.write("Alarm is set for", t)
|
| .. output::
| https://doc-time-input-empty.streamlit.app/
| height: 260px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.toast.ToastMixin:
|
| toast(self, body: 'SupportsStr', *, icon: 'str | None' = None, duration: "Literal['short', 'long', 'infinite'] | int" = 'short') -> 'DeltaGenerator' from ToastMixin
| Display a short message, known as a notification "toast".
| The toast appears in the app's top-right corner and disappears after four seconds.
|
| .. warning::
| ``st.toast`` is not compatible with Streamlit's `caching <https://docs.streamlit.io/develop/concepts/architecture/caching>`_ and
| cannot be called within a cached function.
|
| Parameters
| ----------
| body : str
| The string to display as GitHub-flavored Markdown. Syntax
| information can be found at: https://github.github.com/gfm.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
| icon : str, None
| An optional emoji or icon to display next to the alert. If ``icon``
| is ``None`` (default), no icon is displayed. If ``icon`` is a
| string, the following options are valid:
|
| - A single-character emoji. For example, you can set ``icon="🚨"``
| or ``icon="🔥"``. Emoji short codes are not supported.
|
| - An icon from the Material Symbols library (rounded style) in the
| format ``":material/icon_name:"`` where "icon_name" is the name
| of the icon in snake case.
|
| For example, ``icon=":material/thumb_up:"`` will display the
| Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
| font library.
|
| - ``"spinner"``: Displays a spinner as an icon.
|
| duration : "short", "long", "infinite", or int
| The time to display the toast message. This can be one of the
| following:
|
| - ``"short"`` (default): Displays for 4 seconds.
| - ``"long"``: Displays for 10 seconds.
| - ``"infinite"``: Shows the toast until the user dismisses it.
| - An integer: Displays for the specified number of seconds.
|
| Examples
| --------
| **Example 1: Show a toast message**
|
| >>> import streamlit as st
| >>>
| >>> st.toast("Your edited image was saved!", icon="😍")
|
| .. output::
| https://doc-status-toast.streamlit.app
| height: 200px
|
| **Example 2: Show multiple toasts**
|
| When multiple toasts are generated, they will stack. Hovering over a
| toast will stop it from disappearing. When hovering ends, the toast
| will disappear after time specified in ``duration``.
|
| >>> import time
| >>> import streamlit as st
| >>>
| >>> if st.button("Three cheers"):
| >>> st.toast("Hip!")
| >>> time.sleep(0.5)
| >>> st.toast("Hip!")
| >>> time.sleep(0.5)
| >>> st.toast("Hooray!", icon="🎉")
|
| .. output::
| https://doc-status-toast1.streamlit.app
| height: 300px
|
| **Example 3: Update a toast message**
|
| Toast messages can also be updated. Assign ``st.toast(my_message)`` to
| a variable and use the ``.toast()`` method to update it. If a toast has
| already disappeared or been dismissed, the update will not be seen.
|
| >>> import time
| >>> import streamlit as st
| >>>
| >>> def cook_breakfast():
| >>> msg = st.toast("Gathering ingredients...")
| >>> time.sleep(1)
| >>> msg.toast("Cooking...")
| >>> time.sleep(1)
| >>> msg.toast("Ready!", icon="🥞")
| >>>
| >>> if st.button("Cook breakfast"):
| >>> cook_breakfast()
|
| .. output::
| https://doc-status-toast2.streamlit.app
| height: 200px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.write.WriteMixin:
|
| write(self, *args: 'Any', unsafe_allow_html: 'bool' = False) -> 'None' from WriteMixin
| Displays arguments in the app.
|
| This is the Swiss Army knife of Streamlit commands: it does different
| things depending on what you throw at it. Unlike other Streamlit
| commands, ``st.write()`` has some unique properties:
|
| - You can pass in multiple arguments, all of which will be displayed.
| - Its behavior depends on the input type(s).
|
| Parameters
| ----------
| *args : any
| One or many objects to display in the app.
|
| .. list-table:: Each type of argument is handled as follows:
| :header-rows: 1
|
| * - Type
| - Handling
| * - ``str``
| - Uses ``st.markdown()``.
| * - dataframe-like, ``dict``, or ``list``
| - Uses ``st.dataframe()``.
| * - ``Exception``
| - Uses ``st.exception()``.
| * - function, module, or class
| - Uses ``st.help()``.
| * - ``DeltaGenerator``
| - Uses ``st.help()``.
| * - Altair chart
| - Uses ``st.altair_chart()``.
| * - Bokeh figure
| - Uses ``st.bokeh_chart()``.
| * - Graphviz graph
| - Uses ``st.graphviz_chart()``.
| * - Keras model
| - Converts model and uses ``st.graphviz_chart()``.
| * - Matplotlib figure
| - Uses ``st.pyplot()``.
| * - Plotly figure
| - Uses ``st.plotly_chart()``.
| * - ``PIL.Image``
| - Uses ``st.image()``.
| * - generator or stream (like ``openai.Stream``)
| - Uses ``st.write_stream()``.
| * - SymPy expression
| - Uses ``st.latex()``.
| * - An object with ``._repr_html()``
| - Uses ``st.html()``.
| * - Database cursor
| - Displays DB API 2.0 cursor results in a table.
| * - Any
| - Displays ``str(arg)`` as inline code.
|
| unsafe_allow_html : bool
| Whether to render HTML within ``*args``. This only applies to
| strings or objects falling back on ``_repr_html_()``. If this is
| ``False`` (default), any HTML tags found in ``body`` will be
| escaped and therefore treated as raw text. If this is ``True``, any
| HTML expressions within ``body`` will be rendered.
|
| Adding custom HTML to your app impacts safety, styling, and
| maintainability.
|
| .. note::
| If you only want to insert HTML or CSS without Markdown text,
| we recommend using ``st.html`` instead.
|
| Examples
| --------
| Its basic use case is to draw Markdown-formatted text, whenever the
| input is a string:
|
| >>> import streamlit as st
| >>>
| >>> st.write("Hello, *World!* :sunglasses:")
|
| .. output::
| https://doc-write1.streamlit.app/
| height: 200px
|
| As mentioned earlier, ``st.write()`` also accepts other data formats, such as
| numbers, data frames, styled data frames, and assorted objects:
|
| >>> import streamlit as st
| >>> import pandas as pd
| >>>
| >>> st.write(1234)
| >>> st.write(
| ... pd.DataFrame(
| ... {
| ... "first column": [1, 2, 3, 4],
| ... "second column": [10, 20, 30, 40],
| ... }
| ... )
| ... )
|
| .. output::
| https://doc-write2.streamlit.app/
| height: 350px
|
| Finally, you can pass in multiple arguments to do things like:
|
| >>> import streamlit as st
| >>>
| >>> st.write("1 + 1 = ", 2)
| >>> st.write("Below is a DataFrame:", data_frame, "Above is a dataframe.")
|
| .. output::
| https://doc-write3.streamlit.app/
| height: 410px
|
| Oh, one more thing: ``st.write`` accepts chart objects too! For example:
|
| >>> import altair as alt
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(rng(0).standard_normal((200, 3)), columns=["a", "b", "c"])
| >>> chart = (
| ... alt.Chart(df)
| ... .mark_circle()
| ... .encode(x="a", y="b", size="c", color="c", tooltip=["a", "b", "c"])
| ... )
| >>>
| >>> st.write(chart)
|
| .. output::
| https://doc-vega-lite-chart.streamlit.app/
| height: 300px
|
| write_stream(self, stream: 'Callable[..., Any] | Generator[Any, Any, Any] | Iterable[Any] | AsyncGenerator[Any, Any]', *, cursor: 'str | None' = None) -> 'list[Any] | str' from WriteMixin
| Stream a generator, iterable, or stream-like sequence to the app.
|
| ``st.write_stream`` iterates through the given sequences and writes all
| chunks to the app. String chunks will be written using a typewriter effect.
| Other data types will be written using ``st.write``.
|
| Parameters
| ----------
| stream : Callable, Generator, Iterable, OpenAI Stream, or LangChain Stream
| The generator or iterable to stream.
|
| If you pass an async generator, Streamlit will internally convert
| it to a sync generator. If the generator depends on a cached object
| with async references, this can raise an error.
|
| .. note::
| To use additional LLM libraries, you can create a wrapper to
| manually define a generator function and include custom output
| parsing.
|
| cursor : str or None
| A string to append to text as it's being written. If this is
| ``None`` (default), no cursor is shown. Otherwise, the string is
| rendered as Markdown and appears as a cursor at the end of the
| streamed text. For example, you can use an emoji, emoji shortcode,
| or Material icon.
|
| The first line of the cursor string can contain GitHub-flavored
| Markdown of the following types: Bold, Italics, Strikethroughs,
| Inline Code, Links, and Images. Images display like icons, with a
| max height equal to the font height. If you pass a multiline
| string, additional lines display after the text with the full
| Markdown rendering capabilities of ``st.markdown``.
|
| See the ``body`` parameter of |st.markdown|_ for additional,
| supported Markdown directives.
|
| .. |st.markdown| replace:: ``st.markdown``
| .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
|
| Returns
| -------
| str or list
| The full response. If the streamed output only contains text, this
| is a string. Otherwise, this is a list of all the streamed objects.
| The return value is fully compatible as input for ``st.write``.
|
| Examples
| --------
| You can pass an OpenAI stream as shown in our tutorial, `Build a \
| basic LLM chat app <https://docs.streamlit.io/develop/tutorials/llms\
| /build-conversational-apps#build-a-chatgpt-like-app>`_. Alternatively,
| you can pass a generic generator function as input:
|
| >>> import time
| >>> import numpy as np
| >>> import pandas as pd
| >>> import streamlit as st
| >>>
| >>> _LOREM_IPSUM = \"\"\"
| >>> Lorem ipsum dolor sit amet, **consectetur adipiscing** elit, sed do eiusmod tempor
| >>> incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
| >>> nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
| >>> \"\"\"
| >>>
| >>>
| >>> def stream_data():
| >>> for word in _LOREM_IPSUM.split(" "):
| >>> yield word + " "
| >>> time.sleep(0.02)
| >>>
| >>> yield pd.DataFrame(
| >>> np.random.randn(5, 10),
| >>> columns=["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"],
| >>> )
| >>>
| >>> for word in _LOREM_IPSUM.split(" "):
| >>> yield word + " "
| >>> time.sleep(0.02)
| >>>
| >>>
| >>> if st.button("Stream data"):
| >>> st.write_stream(stream_data)
|
| .. output::
| https://doc-write-stream-data.streamlit.app/
| height: 550px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.arrow.ArrowMixin:
|
| add_rows(self, data: 'Data' = None, **kwargs: 'Any') -> 'DeltaGenerator | None' from ArrowMixin
| Concatenate a dataframe to the bottom of the current one.
|
| .. important::
| ``add_rows`` is deprecated and might be removed in a future version.
| If you have a specific use-case that requires the ``add_rows``
| functionality, please tell us via this
| [issue on Github](https://github.com/streamlit/streamlit/issues/13063).
|
| Parameters
| ----------
| data : pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, Iterable, dict, or None
| Table to concat. Optional.
|
| **kwargs : pandas.DataFrame, numpy.ndarray, Iterable, dict, or None
| The named dataset to concat. Optional. You can only pass in 1
| dataset (including the one in the data parameter).
|
| Examples
| --------
| >>> import time
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df1 = pd.DataFrame(
| >>> rng(0).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
| >>> )
| >>>
| >>> df2 = pd.DataFrame(
| >>> rng(1).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
| >>> )
| >>>
| >>> my_table = st.table(df1)
| >>> time.sleep(1)
| >>> my_table.add_rows(df2)
|
| You can do the same thing with plots. For example, if you want to add
| more data to a line chart:
|
| >>> # Assuming df1 and df2 from the example above still exist...
| >>> my_chart = st.line_chart(df1)
| >>> time.sleep(1)
| >>> my_chart.add_rows(df2)
|
| And for plots whose datasets are named, you can pass the data with a
| keyword argument where the key is the name:
|
| >>> my_chart = st.vega_lite_chart(
| ... {
| ... "mark": "line",
| ... "encoding": {"x": "a", "y": "b"},
| ... "datasets": {
| ... "some_fancy_name": df1, # <-- named dataset
| ... },
| ... "data": {"name": "some_fancy_name"},
| ... }
| ... )
| >>> my_chart.add_rows(some_fancy_name=df2) # <-- name used as keyword
|
| dataframe(self, data: 'Data' = None, width: 'Width' = 'stretch', height: "Height | Literal['auto']" = 'auto', *, use_container_width: 'bool | None' = None, hide_index: 'bool | None' = None, column_order: 'Iterable[str] | None' = None, column_config: 'ColumnConfigMappingInput | None' = None, key: 'Key | None' = None, on_select: "Literal['ignore', 'rerun'] | WidgetCallback" = 'ignore', selection_mode: 'SelectionMode | Iterable[SelectionMode]' = 'multi-row', selection_default: 'DataframeState | None' = None, row_height: 'int | None' = None, placeholder: 'str | None' = None) -> 'DeltaGenerator | DataframeState' from ArrowMixin
| Display a dataframe as an interactive table.
|
| This command works with a wide variety of collection-like and
| dataframe-like object types.
|
| Parameters
| ----------
| data : dataframe-like, collection-like, or None
| The data to display.
|
| Dataframe-like objects include dataframe and series objects from
| popular libraries like Dask, Modin, Numpy, pandas, Polars, PyArrow,
| Snowpark, Xarray, and more. You can use database cursors and
| clients that comply with the
| `Python Database API Specification v2.0 (PEP 249)
| <https://peps.python.org/pep-0249/>`_. Additionally, you can use
| anything that supports the `Python dataframe interchange protocol
| <https://data-apis.org/dataframe-protocol/latest/>`_.
|
| For example, you can use the following:
|
| - ``pandas.DataFrame``, ``pandas.Series``, ``pandas.Index``,
| ``pandas.Styler``, and ``pandas.Array``
| - ``polars.DataFrame``, ``polars.LazyFrame``, and ``polars.Series``
| - ``snowflake.snowpark.dataframe.DataFrame``,
| ``snowflake.snowpark.table.Table``
|
| If a data type is not recognized, Streamlit will convert the object
| to a ``pandas.DataFrame`` or ``pyarrow.Table`` using a
| ``.to_pandas()`` or ``.to_arrow()`` method, respectively, if
| available.
|
| If ``data`` is a ``pandas.Styler``, it will be used to style its
| underlying ``pandas.DataFrame``. Streamlit supports custom cell
| values, colors, and font weights. It does not support some of the
| more exotic styling options, like bar charts, hovering, and
| captions. For these styling options, use column configuration
| instead. Text and number formatting from ``column_config`` always
| takes precedence over text and number formatting from ``pandas.Styler``.
|
| Collection-like objects include all Python-native ``Collection``
| types, such as ``dict``, ``list``, and ``set``.
|
| If ``data`` is ``None``, Streamlit renders an empty table.
|
| width : "stretch", "content", or int
| The width of the dataframe element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| height : "auto", "content", "stretch", or int
| The height of the dataframe element. This can be one of the following:
|
| - ``"auto"`` (default): Streamlit sets the height to show at most
| ten rows.
| - ``"content"``: The height of the element matches the height of
| its content. The height is capped at 10,000 pixels to prevent
| performance issues with very large dataframes.
| - ``"stretch"``: The height of the element expands to fill the
| available vertical space in its parent container. When multiple
| elements with stretch height are in the same container, they
| share the available vertical space evenly. The dataframe will
| maintain a minimum height to display up to three rows, but
| otherwise won't exceed the available height in its parent
| container.
| - An integer specifying the height in pixels: The element has a
| fixed height.
|
| Vertical scrolling within the dataframe element is enabled when the
| height does not accommodate all rows.
|
| use_container_width : bool
| Whether to override ``width`` with the width of the parent
| container. If this is ``True`` (default), Streamlit sets the width
| of the dataframe to match the width of the parent container. If
| this is ``False``, Streamlit sets the dataframe's width according
| to ``width``.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| hide_index : bool or None
| Whether to hide the index column(s). If ``hide_index`` is ``None``
| (default), the visibility of index columns is automatically
| determined based on the data and other configurations.
|
| column_order : Iterable[str] or None
| The ordered list of columns to display. If this is ``None``
| (default), Streamlit displays all columns in the order inherited
| from the underlying data structure. If this is a list, the
| indicated columns will display in the order they appear within the
| list. Columns may be omitted or repeated within the list.
|
| For example, ``column_order=("col2", "col1")`` will display
| ``"col2"`` first, followed by ``"col1"``, and will hide all other
| non-index columns.
|
| ``column_order`` does not accept positional column indices and
| can't move the index column(s).
|
| .. note::
| Columns omitted from ``column_order`` are hidden by default
| but can still be shown by the user via the column visibility
| menu in the table toolbar. If a column contains sensitive data
| that should not be exposed to the user, remove it from the
| data before passing it to the function.
|
| column_config : dict or None
| Configuration to customize how columns are displayed. If this is
| ``None`` (default), columns are styled based on the underlying data
| type of each column.
|
| Column configuration can modify column names, visibility, type,
| width, format, and more. If this is a dictionary, the keys are
| column names (strings) and/or positional column indices (integers),
| and the values are one of the following:
|
| - ``None`` to hide the column. Hidden columns can still be shown
| by the user via the table toolbar.
| - A string to set the display label of the column.
| - One of the column types defined under ``st.column_config``. For
| example, to show a column as dollar amounts, use
| ``st.column_config.NumberColumn("Dollar values", format="$ %d")``.
| See more info on the available column types and config options
| `here <https://docs.streamlit.io/develop/api-reference/data/st.column_config>`_.
|
| To configure the index column(s), use ``"_index"`` as the column
| name, or use a positional column index where ``0`` refers to the
| first index column.
|
| key : str, int, or None
| An optional string to use for giving this element a stable
| identity. If this is ``None`` (default), the element's identity
| will be determined based on the values of the other parameters.
|
| If selections are activated, a key lets you read or update the
| selection state via ``st.session_state[key]``. The value in
| Session State must be a dictionary consistent with the
| ``DataframeState`` schema. For more details, see `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| on_select : "ignore" or "rerun" or callable
| How the dataframe should respond to user selection events. This
| controls whether or not the dataframe behaves like an input widget.
| ``on_select`` can be one of the following:
|
| - ``"ignore"`` (default): Streamlit will not react to any selection
| events in the dataframe. The dataframe will not behave like an
| input widget.
|
| - ``"rerun"``: Streamlit will rerun the app when the user selects
| rows, columns, or cells in the dataframe. In this case,
| ``st.dataframe`` will return the selection data as a dictionary.
|
| - A ``callable``: Streamlit will rerun the app and execute the
| ``callable`` as a callback function before the rest of the app.
| In this case, ``st.dataframe`` will return the selection data
| as a dictionary.
|
| selection_mode : "single-row", "single-row-required", "multi-row", "single-column", "multi-column", "single-cell", "multi-cell", or Iterable of these
| The types of selections Streamlit should allow when selections are
| enabled with ``on_select``. This can be one of the following:
|
| - "multi-row" (default): Multiple rows can be selected at a time.
| - "single-row": Only one row can be selected at a time.
| - "single-row-required": Exactly one row must always be selected
| (radio-like behavior). Auto-selects the first row if no default
| is given.
| - "multi-column": Multiple columns can be selected at a time.
| - "single-column": Only one column can be selected at a time.
| - "multi-cell": A rectangular range of cells can be selected.
| - "single-cell": Only one cell can be selected at a time.
| - An ``Iterable`` of the above options: The table will allow
| selection based on the modes specified. For example, to allow the
| user to select multiple rows and multiple cells, use
| ``["multi-row", "multi-cell"]``.
|
| When column selections are enabled, column sorting is disabled.
|
| selection_default : dict or None
| The default selection state to apply on first render when selections
| are activated and no prior selection is stored. This uses the same
| schema as ``st.session_state[key]`` for selections, for example:
| ``{"selection": {"rows": [0, 2]}}``.
|
| ``selection_default`` is only applied when ``on_select`` is not
| ``"ignore"``. It does not override user selections on subsequent
| runs, and multi-cell selections cannot be set programmatically.
|
| row_height : int or None
| The height of each row in the dataframe in pixels. If ``row_height``
| is ``None`` (default), Streamlit will use a default row height,
| which fits one line of text.
|
| placeholder : str or None
| The text that should be shown for missing values. If this is
| ``None`` (default), missing values are displayed as "None". To
| leave a cell empty, use an empty string (``""``). Other common
| values are ``"null"``, ``"NaN"`` and ``"-"``.
|
| Returns
| -------
| element or dict
| If ``on_select`` is ``"ignore"`` (default), this command returns an
| internal placeholder for the dataframe element that can be used
| with the ``.add_rows()`` method. Otherwise, this command returns a
| dictionary-like object that supports both key and attribute
| notation. The attributes are described by the ``DataframeState``
| dictionary schema.
|
| Examples
| --------
| **Example 1: Display a dataframe**
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... rng(0).standard_normal((50, 20)), columns=("col %d" % i for i in range(20))
| ... )
| >>>
| >>> st.dataframe(df)
|
| .. output::
| https://doc-dataframe.streamlit.app/
| height: 500px
|
| **Example 2: Use Pandas Styler**
|
| You can also pass a Pandas Styler object to change the style of
| the rendered DataFrame:
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... rng(0).standard_normal((10, 20)), columns=("col %d" % i for i in range(20))
| ... )
| >>>
| >>> st.dataframe(df.style.highlight_max(axis=0))
|
| .. output::
| https://doc-dataframe1.streamlit.app/
| height: 500px
|
| **Example 3: Use column configuration**
|
| You can customize a dataframe via ``column_config``, ``hide_index``, or ``column_order``.
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... {
| ... "name": ["Roadmap", "Extras", "Issues"],
| ... "url": [
| ... "https://roadmap.streamlit.app",
| ... "https://extras.streamlit.app",
| ... "https://issues.streamlit.app",
| ... ],
| ... "stars": rng(0).integers(0, 1000, size=3),
| ... "views_history": rng(0).integers(0, 5000, size=(3, 30)).tolist(),
| ... }
| ... )
| >>>
| >>> st.dataframe(
| ... df,
| ... column_config={
| ... "name": "App name",
| ... "stars": st.column_config.NumberColumn(
| ... "Github Stars",
| ... help="Number of stars on GitHub",
| ... format="%d ⭐",
| ... ),
| ... "url": st.column_config.LinkColumn("App URL"),
| ... "views_history": st.column_config.LineChartColumn(
| ... "Views (past 30 days)", y_min=0, y_max=5000
| ... ),
| ... },
| ... hide_index=True,
| ... )
|
| .. output::
| https://doc-dataframe-config.streamlit.app/
| height: 350px
|
| **Example 4: Customize your index**
|
| You can use column configuration to format your index.
|
| >>> from datetime import datetime, date
| >>> import numpy as np
| >>> import pandas as pd
| >>> import streamlit as st
| >>>
| >>> @st.cache_data
| >>> def load_data():
| >>> year = datetime.now().year
| >>> df = pd.DataFrame(
| ... {
| ... "Date": [date(year, month, 1) for month in range(1, 4)],
| ... "Total": np.random.randint(1000, 5000, size=3),
| ... }
| ... )
| >>> df.set_index("Date", inplace=True)
| >>> return df
| >>>
| >>> df = load_data()
| >>> config = {
| ... "_index": st.column_config.DateColumn("Month", format="MMM YYYY"),
| ... "Total": st.column_config.NumberColumn("Total ($)"),
| ... }
| >>>
| >>> st.dataframe(df, column_config=config)
|
| .. output::
| https://doc-dataframe-config-index.streamlit.app/
| height: 225px
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.vega_charts.VegaChartsMixin:
|
| altair_chart(self, altair_chart: 'AltairChart', *, width: 'Width | None' = None, height: 'Height' = 'content', use_container_width: 'bool | None' = None, theme: "Literal['streamlit'] | None" = 'streamlit', key: 'Key | None' = None, on_select: "Literal['rerun', 'ignore'] | WidgetCallback" = 'ignore', selection_mode: 'str | Iterable[str] | None' = None) -> 'DeltaGenerator | VegaLiteState' from VegaChartsMixin
| Display a chart using the Vega-Altair library.
|
| `Vega-Altair <https://altair-viz.github.io/>`_ is a declarative
| statistical visualization library for Python, based on Vega and
| Vega-Lite.
|
| Parameters
| ----------
| altair_chart : altair.Chart
| The Altair chart object to display. See
| https://altair-viz.github.io/gallery/ for examples of graph
| descriptions.
|
| width : "stretch", "content", int, or None
| The width of the chart element. This can be one of the following:
|
| - ``"stretch"``: The width of the element matches the width of the
| parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
| - ``None`` (default): Streamlit uses ``"stretch"`` for most charts,
| and uses ``"content"`` for the following multi-view charts:
|
| - Facet charts: the spec contains ``"facet"`` or encodings for
| ``"row"``, ``"column"``, or ``"facet"``.
| - Horizontal concatenation charts: the spec contains
| ``"hconcat"``.
| - Repeat charts: the spec contains ``"repeat"``.
| - Nested composition charts: the spec contains ``"vconcat"``
| with nested ``"hconcat"``, ``"vconcat"``, ``"concat"``, or
| ``"layer"`` operators (e.g., scatter plots with marginal
| histograms).
|
| height : "content", "stretch", or int
| The height of the chart element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| use_container_width : bool or None
| Whether to override the chart's native width with the width of
| the parent container. This can be one of the following:
|
| - ``None`` (default): Streamlit will use the parent container's
| width for all charts except those with known incompatibility
| (``altair.Facet``, ``altair.HConcatChart``, and
| ``altair.RepeatChart``).
| - ``True``: Streamlit sets the width of the chart to match the
| width of the parent container.
| - ``False``: Streamlit sets the width of the chart to fit its
| contents according to the plotting library, up to the width of
| the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| theme : "streamlit" or None
| The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
| Streamlit uses its own design default. If ``theme`` is ``None``,
| Streamlit falls back to the default behavior of the library.
|
| The ``"streamlit"`` theme can be partially customized through the
| configuration options ``theme.chartCategoricalColors`` and
| ``theme.chartSequentialColors``. Font configuration options are
| also applied.
|
| key : str, int, or None
| An optional string to use for giving this element a stable
| identity. If this is ``None`` (default), the element's identity
| will be determined based on the values of the other parameters.
|
| Additionally, if selections are activated and ``key`` is provided,
| Streamlit will register the key in Session State to store the
| selection state. The selection state is read-only. For more
| details, see `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| on_select : "ignore", "rerun", or callable
| How the figure should respond to user selection events. This
| controls whether or not the figure behaves like an input widget.
| ``on_select`` can be one of the following:
|
| - ``"ignore"`` (default): Streamlit will not react to any selection
| events in the chart. The figure will not behave like an input
| widget.
|
| - ``"rerun"``: Streamlit will rerun the app when the user selects
| data in the chart. In this case, ``st.altair_chart`` will return
| the selection data as a dictionary.
|
| - A ``callable``: Streamlit will rerun the app and execute the
| ``callable`` as a callback function before the rest of the app.
| In this case, ``st.altair_chart`` will return the selection data
| as a dictionary.
|
| To use selection events, the object passed to ``altair_chart`` must
| include selection parameters. To learn about defining interactions
| in Altair and how to declare selection-type parameters, see
| `Interactive Charts <https://altair-viz.github.io/user_guide/interactions.html>`_
| in Altair's documentation.
|
| For consistent selection output, especially in multi-view charts
| (layer, hconcat, vconcat, facet, repeat), specify ``fields`` or
| ``encodings`` in your selection, like
| ``alt.selection_point(fields=["Origin"])`` or
| ``alt.selection_point(encodings=["x", "y"])``. Without explicit
| fields, Vega may add an internal row identifier field (``vgsid``)
| to your data, and selections can then return this identifier
| instead of your original data values.
|
| selection_mode : str or Iterable of str
| The selection parameters Streamlit should use. If
| ``selection_mode`` is ``None`` (default), Streamlit will use all
| selection parameters defined in the chart's Altair spec.
|
| When Streamlit uses a selection parameter, selections from that
| parameter will trigger a rerun and be included in the selection
| state. When Streamlit does not use a selection parameter,
| selections from that parameter will not trigger a rerun and not be
| included in the selection state.
|
| Selection parameters are identified by their ``name`` property.
|
| Returns
| -------
| element or dict
| If ``on_select`` is ``"ignore"`` (default), this command returns an
| internal placeholder for the chart element that can be used with
| the ``.add_rows()`` method. Otherwise, this command returns a
| dictionary-like object that supports both key and attribute
| notation. The attributes are described by the ``VegaLiteState``
| dictionary schema.
|
| Examples
| --------
| >>> import altair as alt
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(rng(0).standard_normal((60, 3)), columns=["a", "b", "c"])
| >>>
| >>> chart = (
| ... alt.Chart(df)
| ... .mark_circle()
| ... .encode(x="a", y="b", size="c", color="c", tooltip=["a", "b", "c"])
| ... )
| >>>
| >>> st.altair_chart(chart)
|
| .. output::
| https://doc-vega-lite-chart.streamlit.app/
| height: 450px
|
| area_chart(self, data: 'Data' = None, *, x: 'str | None' = None, y: 'str | Sequence[str] | None' = None, x_label: 'str | None' = None, y_label: 'str | None' = None, color: 'str | Color | list[Color] | None' = None, stack: 'bool | ChartStackType | None' = None, width: 'Width' = 'stretch', height: 'Height' = 'content', use_container_width: 'bool | None' = None) -> 'DeltaGenerator' from VegaChartsMixin
| Display an area chart.
|
| This is syntax-sugar around ``st.altair_chart``. The main difference
| is this command uses the data's own column and indices to figure out
| the chart's Altair spec. As a result this is easier to use for many
| "just plot this" scenarios, while being less customizable.
|
| Parameters
| ----------
| data : Anything supported by st.dataframe
| Data to be plotted.
|
| x : str or None
| Column name or key associated to the x-axis data. If ``x`` is
| ``None`` (default), Streamlit uses the data index for the x-axis
| values.
|
| y : str, Sequence of str, or None
| Column name(s) or key(s) associated to the y-axis data. If this is
| ``None`` (default), Streamlit draws the data of all remaining
| columns as data series. If this is a ``Sequence`` of strings,
| Streamlit draws several series on the same chart by melting your
| wide-format table into a long-format table behind the scenes.
|
| x_label : str or None
| The label for the x-axis. If this is ``None`` (default), Streamlit
| will use the column name specified in ``x`` if available, or else
| no label will be displayed.
|
| y_label : str or None
| The label for the y-axis. If this is ``None`` (default), Streamlit
| will use the column name(s) specified in ``y`` if available, or
| else no label will be displayed.
|
| color : str, tuple, Sequence of str, Sequence of tuple, or None
| The color to use for different series in this chart.
|
| For an area chart with just 1 series, this can be:
|
| - None, to use the default color.
| - A hex string like "#ffaa00" or "#ffaa0088".
| - An RGB or RGBA tuple with the red, green, blue, and alpha
| components specified as ints from 0 to 255 or floats from 0.0 to
| 1.0.
| - A built-in color name: "red", "orange", "yellow", "green",
| "blue", "violet", "gray"/"grey", or "primary". These map to
| theme colors that you can customize using ``theme.<color>Color``
| configuration options.
|
| For an area chart with multiple series, where the dataframe is in
| long format (that is, y is None or just one column), this can be:
|
| - None, to use the default colors.
| - The name of a column in the dataset. Data points will be grouped
| into series of the same color based on the value of this column.
| In addition, if the values in this column match one of the color
| formats above (hex string or color tuple), then that color will
| be used.
|
| For example: if the dataset has 1000 rows, but this column only
| contains the values "adult", "child", and "baby", then those 1000
| datapoints will be grouped into three series whose colors will be
| automatically selected from the default palette.
|
| But, if for the same 1000-row dataset, this column contained
| the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
| datapoints would still be grouped into 3 series, but their
| colors would be "#ffaa00", "#f0f", "#0000ff" this time around.
|
| For an area chart with multiple series, where the dataframe is in
| wide format (that is, y is a Sequence of columns), this can be:
|
| - None, to use the default colors.
| - A list of string colors or color tuples to be used for each of
| the series in the chart. This list should have the same length
| as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
| for three lines). You can also use built-in color names in the
| list (e.g. ``color=["red", "blue", "green"]``).
|
| You can set the default colors in the ``theme.chartCategoryColors``
| configuration option.
|
| stack : bool, "normalize", "center", or None
| Whether to stack the areas. If this is ``None`` (default),
| Streamlit uses Vega's default. Other values can be as follows:
|
| - ``True``: The areas form a non-overlapping, additive stack within
| the chart.
| - ``False``: The areas overlap each other without stacking.
| - ``"normalize"``: The areas are stacked and the total height is
| normalized to 100% of the height of the chart.
| - ``"center"``: The areas are stacked and shifted to center their
| baseline, which creates a steamgraph.
|
| width : "stretch", "content", or int
| The width of the chart element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| height : "stretch", "content", or int
| The height of the chart element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| use_container_width : bool or None
| Whether to override the chart's native width with the width of
| the parent container. This can be one of the following:
|
| - ``None`` (default): Streamlit will use the chart's default behavior.
| - ``True``: Streamlit sets the width of the chart to match the
| width of the parent container.
| - ``False``: Streamlit sets the width of the chart to fit its
| contents according to the plotting library, up to the width of
| the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| Examples
| --------
| **Example 1: Basic area chart from a dataframe**
|
| If you don't use any of the optional parameters, Streamlit plots each
| column as a separate area, uses the index as the x values, and labels
| each series with the column name:
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
| >>>
| >>> st.area_chart(df)
|
| .. output::
| https://doc-area-chart.streamlit.app/
| height: 440px
|
| **Example 2: Area chart from specific dataframe columns**
|
| You can choose different columns to use for the x and y values. If your
| dataframe is in long format (all y-values in one column), you can set
| the area colors from another column.
|
| If the column contains color strings, the colors will be applied
| directly and the series will be unlabeled. If the column contains other
| values, those values will label each area, and the area colors will be
| selected from the default color palette. You can configure this color
| palette in the ``theme.chartCategoryColors`` configuration option.
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... {
| ... "col1": list(range(20)) * 3,
| ... "col2": rng(0).standard_normal(60),
| ... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20,
| ... }
| ... )
| >>>
| >>> st.area_chart(df, x="col1", y="col2", color="col3")
|
| .. output::
| https://doc-area-chart1.streamlit.app/
| height: 440px
|
| **Example 3: Area chart from wide-format dataframe**
|
| If your dataframe is in wide format (y-values are in multiple columns),
| you can pass a list of columns to the ``y`` parameter. Each column
| name becomes a series label. To override the default colors, pass a
| list of colors to the ``color`` parameter, one for each series. If your
| areas are overlapping, use colors with some transparency (alpha
| channel) for the best results.
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... {
| ... "col1": list(range(20)),
| ... "col2": rng(0).standard_normal(20),
| ... "col3": rng(1).standard_normal(20),
| ... }
| ... )
| >>>
| >>> st.area_chart(
| ... df,
| ... x="col1",
| ... y=["col2", "col3"],
| ... color=["#FF000080", "#0000FF80"],
| ... )
|
| .. output::
| https://doc-area-chart2.streamlit.app/
| height: 440px
|
| **Example 4: Area chart with different stacking**
|
| You can adjust the stacking behavior by setting ``stack``. You can
| create a streamgraph by setting ``stack="center"``:
|
| >>> import streamlit as st
| >>> from vega_datasets import data
| >>>
| >>> df = data.unemployment_across_industries()
| >>>
| >>> st.area_chart(df, x="date", y="count", color="series", stack="center")
|
| .. output::
| https://doc-area-chart-steamgraph.streamlit.app/
| height: 440px
|
| bar_chart(self, data: 'Data' = None, *, x: 'str | None' = None, y: 'str | Sequence[str] | None' = None, x_label: 'str | None' = None, y_label: 'str | None' = None, color: 'str | Color | list[Color] | None' = None, horizontal: 'bool' = False, sort: 'bool | str' = True, stack: 'bool | ChartStackType | None' = None, width: 'Width' = 'stretch', height: 'Height' = 'content', use_container_width: 'bool | None' = None) -> 'DeltaGenerator' from VegaChartsMixin
| Display a bar chart.
|
| This is syntax-sugar around ``st.altair_chart``. The main difference
| is this command uses the data's own column and indices to figure out
| the chart's Altair spec. As a result this is easier to use for many
| "just plot this" scenarios, while being less customizable.
|
| Parameters
| ----------
| data : Anything supported by st.dataframe
| Data to be plotted.
|
| x : str or None
| Column name or key associated to the x-axis data. If ``x`` is
| ``None`` (default), Streamlit uses the data index for the x-axis
| values.
|
| y : str, Sequence of str, or None
| Column name(s) or key(s) associated to the y-axis data. If this is
| ``None`` (default), Streamlit draws the data of all remaining
| columns as data series. If this is a ``Sequence`` of strings,
| Streamlit draws several series on the same chart by melting your
| wide-format table into a long-format table behind the scenes.
|
| x_label : str or None
| The label for the x-axis. If this is ``None`` (default), Streamlit
| will use the column name specified in ``x`` if available, or else
| no label will be displayed.
|
| y_label : str or None
| The label for the y-axis. If this is ``None`` (default), Streamlit
| will use the column name(s) specified in ``y`` if available, or
| else no label will be displayed.
|
| color : str, tuple, Sequence of str, Sequence of tuple, or None
| The color to use for different series in this chart.
|
| For a bar chart with just one series, this can be:
|
| - None, to use the default color.
| - A hex string like "#ffaa00" or "#ffaa0088".
| - An RGB or RGBA tuple with the red, green, blue, and alpha
| components specified as ints from 0 to 255 or floats from 0.0 to
| 1.0.
| - A built-in color name: "red", "orange", "yellow", "green",
| "blue", "violet", "gray"/"grey", or "primary". These map to
| theme colors that you can customize using ``theme.<color>Color``
| configuration options.
|
| For a bar chart with multiple series, where the dataframe is in
| long format (that is, y is None or just one column), this can be:
|
| - None, to use the default colors.
| - The name of a column in the dataset. Data points will be grouped
| into series of the same color based on the value of this column.
| In addition, if the values in this column match one of the color
| formats above (hex string or color tuple), then that color will
| be used.
|
| For example: if the dataset has 1000 rows, but this column only
| contains the values "adult", "child", and "baby", then those 1000
| datapoints will be grouped into three series whose colors will be
| automatically selected from the default palette.
|
| But, if for the same 1000-row dataset, this column contained
| the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
| datapoints would still be grouped into 3 series, but their
| colors would be "#ffaa00", "#f0f", "#0000ff" this time around.
|
| For a bar chart with multiple series, where the dataframe is in
| wide format (that is, y is a Sequence of columns), this can be:
|
| - None, to use the default colors.
| - A list of string colors or color tuples to be used for each of
| the series in the chart. This list should have the same length
| as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
| for three lines). You can also use built-in color names in the
| list (e.g. ``color=["red", "blue", "green"]``).
|
| You can set the default colors in the ``theme.chartCategoryColors``
| configuration option.
|
| horizontal : bool
| Whether to make the bars horizontal. If this is ``False``
| (default), the bars display vertically. If this is ``True``,
| Streamlit swaps the x-axis and y-axis and the bars display
| horizontally.
|
| sort : bool or str
| How to sort the bars. This can be one of the following:
|
| - ``True`` (default): The bars are sorted automatically along the
| independent/categorical axis with Altair's default sorting. This
| also correctly sorts ordered categorical columns
| (``pd.Categorical``).
| - ``False``: The bars are shown in data order without sorting.
| - The name of a column (e.g. ``"col1"``): The bars are sorted by
| that column in ascending order.
| - The name of a column with a minus-sign prefix (e.g. ``"-col1"``):
| The bars are sorted by that column in descending order.
|
| stack : bool, "normalize", "center", "layered", or None
| Whether to stack the bars. If this is ``None`` (default),
| Streamlit uses Vega's default. Other values can be as follows:
|
| - ``True``: The bars form a non-overlapping, additive stack within
| the chart.
| - ``False``: The bars display side by side.
| - ``"layered"``: The bars overlap each other without stacking.
| - ``"normalize"``: The bars are stacked and the total height is
| normalized to 100% of the height of the chart.
| - ``"center"``: The bars are stacked and shifted to center the
| total height around an axis.
|
| width : "stretch", "content", or int
| The width of the chart element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| height : "stretch", "content", or int
| The height of the chart element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| use_container_width : bool or None
| Whether to override the chart's native width with the width of
| the parent container. This can be one of the following:
|
| - ``None`` (default): Streamlit will use the chart's default behavior.
| - ``True``: Streamlit sets the width of the chart to match the
| width of the parent container.
| - ``False``: Streamlit sets the width of the chart to fit its
| contents according to the plotting library, up to the width of
| the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| Examples
| --------
| **Example 1: Basic bar chart from a dataframe**
|
| If you don't use any of the optional parameters, Streamlit plots each
| column as a series of bars, uses the index as the x values, and labels
| each series with the column name:
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
| >>>
| >>> st.bar_chart(df)
|
| .. output::
| https://doc-bar-chart.streamlit.app/
| height: 440px
|
| **Example 2: Bar chart from specific dataframe columns**
|
| You can choose different columns to use for the x and y values. If your
| dataframe is in long format (all y-values in one column), you can set
| the bar colors from another column.
|
| If the column contains color strings, the colors will be applied
| directly and the series will be unlabeled. If the column contains other
| values, those values will label each series, and the bar colors will be
| selected from the default color palette. You can configure this color
| palette in the ``theme.chartCategoryColors`` configuration option.
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... {
| ... "col1": list(range(20)) * 3,
| ... "col2": rng(0).standard_normal(60),
| ... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20,
| ... }
| ... )
| >>>
| >>> st.bar_chart(df, x="col1", y="col2", color="col3")
|
| .. output::
| https://doc-bar-chart1.streamlit.app/
| height: 440px
|
| **Example 3: Bar chart from wide-format dataframe**
|
| If your dataframe is in wide format (y-values are in multiple columns),
| you can pass a list of columns to the ``y`` parameter. Each column
| name becomes a series label. To override the default colors, pass a
| list of colors to the ``color`` parameter, one for each series:
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... {
| ... "col1": list(range(20)),
| ... "col2": rng(0).standard_normal(20),
| ... "col3": rng(1).standard_normal(20),
| ... }
| ... )
| >>>
| >>> st.bar_chart(
| ... df,
| ... x="col1",
| ... y=["col2", "col3"],
| ... color=["#FF0000", "#0000FF"],
| ... )
|
| .. output::
| https://doc-bar-chart2.streamlit.app/
| height: 440px
|
| **Example 4: Horizontal bar chart**
|
| You can use the ``horizontal`` parameter to display horizontal bars
| instead of vertical bars. This is useful when you have long labels on
| the x-axis, or when you want to display a large number of categories.
| This example requires ``vega_datasets`` to be installed.
|
| >>> import streamlit as st
| >>> from vega_datasets import data
| >>>
| >>> source = data.barley()
| >>>
| >>> st.bar_chart(source, x="variety", y="yield", color="site", horizontal=True)
|
| .. output::
| https://doc-bar-chart-horizontal.streamlit.app/
| height: 440px
|
| **Example 5: Unstacked bar chart**
|
| You can configure the stacking behavior of the bars by setting the
| ``stack`` parameter. Set it to ``False`` to display bars side by side.
| This example requires ``vega_datasets`` to be installed.
|
| >>> import streamlit as st
| >>> from vega_datasets import data
| >>>
| >>> source = data.barley()
| >>>
| >>> st.bar_chart(source, x="year", y="yield", color="site", stack=False)
|
| .. output::
| https://doc-bar-chart-unstacked.streamlit.app/
| height: 440px
|
| line_chart(self, data: 'Data' = None, *, x: 'str | None' = None, y: 'str | Sequence[str] | None' = None, x_label: 'str | None' = None, y_label: 'str | None' = None, color: 'str | Color | list[Color] | None' = None, width: 'Width' = 'stretch', height: 'Height' = 'content', use_container_width: 'bool | None' = None) -> 'DeltaGenerator' from VegaChartsMixin
| Display a line chart.
|
| This is syntax-sugar around ``st.altair_chart``. The main difference
| is this command uses the data's own column and indices to figure out
| the chart's Altair spec. As a result this is easier to use for many
| "just plot this" scenarios, while being less customizable.
|
| Parameters
| ----------
| data : Anything supported by st.dataframe
| Data to be plotted.
|
| x : str or None
| Column name or key associated to the x-axis data. If ``x`` is
| ``None`` (default), Streamlit uses the data index for the x-axis
| values.
|
| y : str, Sequence of str, or None
| Column name(s) or key(s) associated to the y-axis data. If this is
| ``None`` (default), Streamlit draws the data of all remaining
| columns as data series. If this is a ``Sequence`` of strings,
| Streamlit draws several series on the same chart by melting your
| wide-format table into a long-format table behind the scenes.
|
| x_label : str or None
| The label for the x-axis. If this is ``None`` (default), Streamlit
| will use the column name specified in ``x`` if available, or else
| no label will be displayed.
|
| y_label : str or None
| The label for the y-axis. If this is ``None`` (default), Streamlit
| will use the column name(s) specified in ``y`` if available, or
| else no label will be displayed.
|
| color : str, tuple, Sequence of str, Sequence of tuple, or None
| The color to use for different lines in this chart.
|
| For a line chart with just one line, this can be:
|
| - None, to use the default color.
| - A hex string like "#ffaa00" or "#ffaa0088".
| - An RGB or RGBA tuple with the red, green, blue, and alpha
| components specified as ints from 0 to 255 or floats from 0.0 to
| 1.0.
| - A built-in color name: "red", "orange", "yellow", "green",
| "blue", "violet", "gray"/"grey", or "primary". These map to
| theme colors that you can customize using ``theme.<color>Color``
| configuration options.
|
| For a line chart with multiple lines, where the dataframe is in
| long format (that is, y is None or just one column), this can be:
|
| - None, to use the default colors.
| - The name of a column in the dataset. Data points will be grouped
| into lines of the same color based on the value of this column.
| In addition, if the values in this column match one of the color
| formats above (hex string or color tuple), then that color will
| be used.
|
| For example: if the dataset has 1000 rows, but this column only
| contains the values "adult", "child", and "baby", then those 1000
| datapoints will be grouped into three lines whose colors will be
| automatically selected from the default palette.
|
| But, if for the same 1000-row dataset, this column contained
| the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
| datapoints would still be grouped into three lines, but their
| colors would be "#ffaa00", "#f0f", "#0000ff" this time around.
|
| For a line chart with multiple lines, where the dataframe is in
| wide format (that is, y is a Sequence of columns), this can be:
|
| - None, to use the default colors.
| - A list of string colors or color tuples to be used for each of
| the lines in the chart. This list should have the same length
| as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
| for three lines). You can also use built-in color names in the
| list (e.g. ``color=["red", "blue", "green"]``).
|
| You can set the default colors in the ``theme.chartCategoryColors``
| configuration option.
|
| width : "stretch", "content", or int
| The width of the chart element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| height : "content", "stretch", or int
| The height of the chart element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| use_container_width : bool or None
| Whether to override the chart's native width with the width of
| the parent container. This can be one of the following:
|
| - ``None`` (default): Streamlit will use the chart's default behavior.
| - ``True``: Streamlit sets the width of the chart to match the
| width of the parent container.
| - ``False``: Streamlit sets the width of the chart to fit its
| contents according to the plotting library, up to the width of
| the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| Examples
| --------
| **Example 1: Basic line chart from a dataframe**
|
| If you don't use any of the optional parameters, Streamlit plots each
| column as a separate line, uses the index as the x values, and labels
| each series with the column name:
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
| >>>
| >>> st.line_chart(df)
|
| .. output::
| https://doc-line-chart.streamlit.app/
| height: 440px
|
| **Example 2: Line chart from specific dataframe columns**
|
| You can choose different columns to use for the x and y values. If your
| dataframe is in long format (all y-values in one column), you can set
| the line colors from another column.
|
| If the column contains color strings, the colors will be applied
| directly and the series will be unlabeled. If the column contains other
| values, those values will label each line, and the line colors will be
| selected from the default color palette. You can configure this color
| palette in the ``theme.chartCategoryColors`` configuration option.
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... {
| ... "col1": list(range(20)) * 3,
| ... "col2": rng(0).standard_normal(60),
| ... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20,
| ... }
| ... )
| >>>
| >>> st.line_chart(df, x="col1", y="col2", color="col3")
|
| .. output::
| https://doc-line-chart1.streamlit.app/
| height: 440px
|
| **Example 3: Line chart from wide-format dataframe**
|
| If your dataframe is in wide format (y-values are in multiple columns),
| you can pass a list of columns to the ``y`` parameter. Each column
| name becomes a series label. To override the default colors, pass a
| list of colors to the ``color`` parameter, one for each series:
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
| >>>
| >>> st.line_chart(
| ... df,
| ... x="a",
| ... y=["b", "c"],
| ... color=["#FF0000", "#0000FF"],
| ... )
|
| .. output::
| https://doc-line-chart2.streamlit.app/
| height: 440px
|
| scatter_chart(self, data: 'Data' = None, *, x: 'str | None' = None, y: 'str | Sequence[str] | None' = None, x_label: 'str | None' = None, y_label: 'str | None' = None, color: 'str | Color | list[Color] | None' = None, size: 'str | float | int | None' = None, width: 'Width' = 'stretch', height: 'Height' = 'content', use_container_width: 'bool | None' = None) -> 'DeltaGenerator' from VegaChartsMixin
| Display a scatterplot chart.
|
| This is syntax-sugar around ``st.altair_chart``. The main difference
| is this command uses the data's own column and indices to figure out
| the chart's Altair spec. As a result this is easier to use for many
| "just plot this" scenarios, while being less customizable.
|
| Parameters
| ----------
| data : Anything supported by st.dataframe
| Data to be plotted.
|
| x : str or None
| Column name or key associated to the x-axis data. If ``x`` is
| ``None`` (default), Streamlit uses the data index for the x-axis
| values.
|
| y : str, Sequence of str, or None
| Column name(s) or key(s) associated to the y-axis data. If this is
| ``None`` (default), Streamlit draws the data of all remaining
| columns as data series. If this is a ``Sequence`` of strings,
| Streamlit draws several series on the same chart by melting your
| wide-format table into a long-format table behind the scenes.
|
| x_label : str or None
| The label for the x-axis. If this is ``None`` (default), Streamlit
| will use the column name specified in ``x`` if available, or else
| no label will be displayed.
|
| y_label : str or None
| The label for the y-axis. If this is ``None`` (default), Streamlit
| will use the column name(s) specified in ``y`` if available, or
| else no label will be displayed.
|
| color : str, tuple, Sequence of str, Sequence of tuple, or None
| The color of the circles representing each datapoint.
|
| This can be:
|
| - None, to use the default color.
| - A hex string like "#ffaa00" or "#ffaa0088".
| - An RGB or RGBA tuple with the red, green, blue, and alpha
| components specified as ints from 0 to 255 or floats from 0.0 to
| 1.0.
| - A built-in color name: "red", "orange", "yellow", "green",
| "blue", "violet", "gray"/"grey", or "primary". These map to
| theme colors that you can customize using ``theme.<color>Color``
| configuration options.
| - The name of a column in the dataset where the color of that
| datapoint will come from.
|
| If the values in this column are in one of the color formats
| above (hex string or color tuple), then that color will be used.
|
| Otherwise, the color will be automatically picked from the
| default palette.
|
| For example: if the dataset has 1000 rows, but this column only
| contains the values "adult", "child", and "baby", then those 1000
| datapoints be shown using three colors from the default palette.
|
| But if this column only contains floats or ints, then those
| 1000 datapoints will be shown using a colors from a continuous
| color gradient.
|
| Finally, if this column only contains the values "#ffaa00",
| "#f0f", "#0000ff", then then each of those 1000 datapoints will
| be assigned "#ffaa00", "#f0f", or "#0000ff" as appropriate.
|
| If the dataframe is in wide format (that is, y is a Sequence of
| columns), this can also be:
|
| - A list of string colors or color tuples to be used for each of
| the series in the chart. This list should have the same length
| as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
| for three series). You can also use built-in color names in the
| list (e.g. ``color=["red", "blue", "green"]``).
|
| size : str, float, int, or None
| The size of the circles representing each point.
|
| This can be:
|
| - A number like 100, to specify a single size to use for all
| datapoints.
| - The name of the column to use for the size. This allows each
| datapoint to be represented by a circle of a different size.
|
| width : "stretch", "content", or int
| The width of the chart element. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the element matches the
| width of the parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
|
| height : "stretch", "content", or int
| The height of the chart element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| use_container_width : bool or None
| Whether to override the chart's native width with the width of
| the parent container. This can be one of the following:
|
| - ``None`` (default): Streamlit will use the chart's default behavior.
| - ``True``: Streamlit sets the width of the chart to match the
| width of the parent container.
| - ``False``: Streamlit sets the width of the chart to fit its
| contents according to the plotting library, up to the width of
| the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| Examples
| --------
| **Example 1: Basic scatter chart from a dataframe**
|
| If you don't use any of the optional parameters, Streamlit plots each
| column as a color-coded group of points, uses the index as the x
| values, and labels each group with the column name:
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
| >>>
| >>> st.scatter_chart(df)
|
| .. output::
| https://doc-scatter-chart.streamlit.app/
| height: 440px
|
| **Example 2: Scatter chart from specific dataframe columns**
|
| You can choose different columns to use for the x and y values. If your
| dataframe is in long format (all y-values in one column), you can set
| the scatter point colors from another column.
|
| If the column contains color strings, the colors will be applied
| directly and each color group will be unlabeled. If the column contains
| other values, those values will label each group, and the scatter point
| colors will be selected from the default color palette. You can
| configure this color palette in the ``theme.chartCategoryColors``
| configuration option.
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... rng(0).standard_normal((20, 3)), columns=["col1", "col2", "col3"]
| ... )
| >>> df["col4"] = rng(0).choice(["a", "b", "c"], 20)
| >>>
| >>> st.scatter_chart(
| ... df,
| ... x="col1",
| ... y="col2",
| ... color="col4",
| ... size="col3",
| ... )
|
| .. output::
| https://doc-scatter-chart1.streamlit.app/
| height: 440px
|
| **Example 3: Scatter chart from wide-format dataframe**
|
| If your dataframe is in wide format (y-values are in multiple columns),
| you can pass a list of columns to the ``y`` parameter. Each column
| name becomes a group label. To override the default colors, pass a
| list of colors to the ``color`` parameter, one for each group:
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(
| ... rng(0).standard_normal((20, 4)),
| ... columns=["col1", "col2", "col3", "col4"],
| ... )
| >>>
| >>> st.scatter_chart(
| ... df,
| ... x="col1",
| ... y=["col2", "col3"],
| ... size="col4",
| ... color=["#FF0000", "#0000FF"],
| ... )
|
| .. output::
| https://doc-scatter-chart2.streamlit.app/
| height: 440px
|
| vega_lite_chart(self, data: 'Data' = None, spec: 'VegaLiteSpec | None' = None, *, width: 'Width | None' = None, height: 'Height' = 'content', use_container_width: 'bool | None' = None, theme: "Literal['streamlit'] | None" = 'streamlit', key: 'Key | None' = None, on_select: "Literal['rerun', 'ignore'] | WidgetCallback" = 'ignore', selection_mode: 'str | Iterable[str] | None' = None) -> 'DeltaGenerator | VegaLiteState' from VegaChartsMixin
| Display a chart using the Vega-Lite library.
|
| `Vega-Lite <https://vega.github.io/vega-lite/>`_ is a high-level
| grammar for defining interactive graphics.
|
| Parameters
| ----------
| data : Anything supported by st.dataframe
| Either the data to be plotted or a Vega-Lite spec containing the
| data (which more closely follows the Vega-Lite API).
|
| spec : dict or None
| The Vega-Lite spec for the chart. If ``spec`` is ``None`` (default),
| Streamlit uses the spec passed in ``data``. You cannot pass a spec
| to both ``data`` and ``spec``. See
| https://vega.github.io/vega-lite/docs/ for more info.
|
| width : "stretch", "content", int, or None
| The width of the chart element. This can be one of the following:
|
| - ``"stretch"``: The width of the element matches the width of the
| parent container.
| - ``"content"``: The width of the element matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The element has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the element matches the width
| of the parent container.
| - ``None`` (default): Streamlit uses ``"stretch"`` for most charts,
| and uses ``"content"`` for the following multi-view charts:
|
| - Facet charts: the spec contains ``"facet"`` or encodings for
| ``"row"``, ``"column"``, or ``"facet"``.
| - Horizontal concatenation charts: the spec contains
| ``"hconcat"``.
| - Repeat charts: the spec contains ``"repeat"``.
| - Nested composition charts: the spec contains ``"vconcat"``
| with nested ``"hconcat"``, ``"vconcat"``, ``"concat"``, or
| ``"layer"`` operators (e.g., scatter plots with marginal
| histograms).
|
| height : "content", "stretch", or int
| The height of the chart element. This can be one of the following:
|
| - ``"content"`` (default): The height of the element matches the
| height of its content.
| - ``"stretch"``: The height of the element matches the height of
| its content or the height of the parent container, whichever is
| larger. If the element is not in a parent container, the height
| of the element matches the height of its content.
| - An integer specifying the height in pixels: The element has a
| fixed height. If the content is larger than the specified
| height, scrolling is enabled.
|
| use_container_width : bool or None
| Whether to override the chart's native width with the width of
| the parent container. This can be one of the following:
|
| - ``None`` (default): Streamlit will use the parent container's
| width for all charts except those with known incompatibility
| (``altair.Facet``, ``altair.HConcatChart``, and
| ``altair.RepeatChart``).
| - ``True``: Streamlit sets the width of the chart to match the
| width of the parent container.
| - ``False``: Streamlit sets the width of the chart to fit its
| contents according to the plotting library, up to the width of
| the parent container.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| theme : "streamlit" or None
| The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
| Streamlit uses its own design default. If ``theme`` is ``None``,
| Streamlit falls back to the default behavior of the library.
|
| The ``"streamlit"`` theme can be partially customized through the
| configuration options ``theme.chartCategoricalColors`` and
| ``theme.chartSequentialColors``. Font configuration options are
| also applied.
|
| key : str, int, or None
| An optional string to use for giving this element a stable
| identity. If this is ``None`` (default), the element's identity
| will be determined based on the values of the other parameters.
|
| If selections are activated and ``key`` is provided,
| Streamlit will register the key in Session State to store the
| selection state. The selection state is read-only. For more
| details, see `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| on_select : "ignore", "rerun", or callable
| How the figure should respond to user selection events. This
| controls whether or not the figure behaves like an input widget.
| ``on_select`` can be one of the following:
|
| - ``"ignore"`` (default): Streamlit will not react to any selection
| events in the chart. The figure will not behave like an input
| widget.
|
| - ``"rerun"``: Streamlit will rerun the app when the user selects
| data in the chart. In this case, ``st.vega_lite_chart`` will
| return the selection data as a dictionary.
|
| - A ``callable``: Streamlit will rerun the app and execute the
| ``callable`` as a callback function before the rest of the app.
| In this case, ``st.vega_lite_chart`` will return the selection data
| as a dictionary.
|
| To use selection events, the Vega-Lite spec defined in ``data`` or
| ``spec`` must include selection parameters from the charting
| library. To learn about defining interactions in Vega-Lite, see
| `Dynamic Behaviors with Parameters <https://vega.github.io/vega-lite/docs/parameter.html>`_
| in Vega-Lite's documentation.
|
| For consistent selection output, especially in multi-view charts
| (layer, hconcat, vconcat, facet, repeat), specify ``fields`` or
| ``encodings`` in your selection, like
| ``alt.selection_point(fields=["Origin"])`` or
| ``alt.selection_point(encodings=["x", "y"])``. Without explicit
| fields, Vega may add an internal row identifier field (``vgsid``)
| to your data, and selections can then return this identifier
| instead of your original data values.
|
| selection_mode : str or Iterable of str
| The selection parameters Streamlit should use. If
| ``selection_mode`` is ``None`` (default), Streamlit will use all
| selection parameters defined in the chart's Vega-Lite spec.
|
| When Streamlit uses a selection parameter, selections from that
| parameter will trigger a rerun and be included in the selection
| state. When Streamlit does not use a selection parameter,
| selections from that parameter will not trigger a rerun and not be
| included in the selection state.
|
| Selection parameters are identified by their ``name`` property.
|
| Returns
| -------
| element or dict
| If ``on_select`` is ``"ignore"`` (default), this command returns an
| internal placeholder for the chart element that can be used with
| the ``.add_rows()`` method. Otherwise, this command returns a
| dictionary-like object that supports both key and attribute
| notation. The attributes are described by the ``VegaLiteState``
| dictionary schema.
|
| Examples
| --------
| >>> import pandas as pd
| >>> import streamlit as st
| >>> from numpy.random import default_rng as rng
| >>>
| >>> df = pd.DataFrame(rng(0).standard_normal((60, 3)), columns=["a", "b", "c"])
| >>>
| >>> st.vega_lite_chart(
| ... df,
| ... {
| ... "mark": {"type": "circle", "tooltip": True},
| ... "encoding": {
| ... "x": {"field": "a", "type": "quantitative"},
| ... "y": {"field": "b", "type": "quantitative"},
| ... "size": {"field": "c", "type": "quantitative"},
| ... "color": {"field": "c", "type": "quantitative"},
| ... },
| ... },
| ... )
|
| .. output::
| https://doc-vega-lite-chart.streamlit.app/
| height: 450px
|
| Examples of Vega-Lite usage without Streamlit can be found at
| https://vega.github.io/vega-lite/examples/. Most of those can be easily
| translated to the syntax shown above.
|
| ----------------------------------------------------------------------
| Methods inherited from streamlit.elements.widgets.data_editor.DataEditorMixin:
|
| data_editor(self, data: 'DataTypes', *, width: 'Width' = 'stretch', height: "Height | Literal['auto']" = 'auto', use_container_width: 'bool | None' = None, hide_index: 'bool | None' = None, column_order: 'Iterable[str] | None' = None, column_config: 'ColumnConfigMappingInput | None' = None, num_rows: "Literal['fixed', 'dynamic', 'add', 'delete']" = 'fixed', disabled: 'bool | Iterable[str | int]' = False, key: 'Key | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, row_height: 'int | None' = None, placeholder: 'str | None' = None) -> 'DataTypes' from DataEditorMixin
| Display a data editor widget.
|
| The data editor widget allows you to edit dataframes and many other data structures in a table-like UI.
|
| Parameters
| ----------
| data : Anything supported by st.dataframe
| The data to edit in the data editor.
|
| .. note::
| - Styles from ``pandas.Styler`` will only be applied to non-editable columns.
| - Text and number formatting from ``column_config`` always takes
| precedence over text and number formatting from ``pandas.Styler``.
| - If your dataframe starts with an empty column, you should set
| the column datatype in the underlying dataframe to ensure your
| intended datatype, especially for integers versus floats.
| - Mixing data types within a column can make the column uneditable.
| - Additionally, the following data types are not yet supported for editing:
| ``complex``, ``tuple``, ``bytes``, ``bytearray``,
| ``memoryview``, ``dict``, ``set``, ``frozenset``,
| ``fractions.Fraction``, ``pandas.Interval``, and
| ``pandas.Period``.
| - To prevent overflow in JavaScript, columns containing
| ``datetime.timedelta`` and ``pandas.Timedelta`` values will
| default to uneditable, but this can be changed through column
| configuration.
|
| width : "stretch", "content", or int
| The width of the data editor. This can be one of the following:
|
| - ``"stretch"`` (default): The width of the editor matches the
| width of the parent container.
| - ``"content"``: The width of the editor matches the width of its
| content, but doesn't exceed the width of the parent container.
| - An integer specifying the width in pixels: The editor has a
| fixed width. If the specified width is greater than the width of
| the parent container, the width of the editor matches the width
| of the parent container.
|
| height : "auto", "content", "stretch", or int
| The height of the data editor. This can be one of the following:
|
| - ``"auto"`` (default): Streamlit sets the height to show at most
| ten rows.
| - ``"content"``: The height of the editor matches the height of
| its content. The height is capped at 10,000 pixels to prevent
| performance issues with very large dataframes.
| - ``"stretch"``: The height of the editor expands to fill the
| available vertical space in its parent container. When multiple
| elements with stretch height are in the same container, they
| share the available vertical space evenly. The editor will
| maintain a minimum height to display up to three rows, but
| otherwise won't exceed the available height in its parent
| container.
| - An integer specifying the height in pixels: The editor has a
| fixed height.
|
| Vertical scrolling within the editor is enabled when the height
| does not accommodate all rows.
|
| use_container_width : bool
| Whether to override ``width`` with the width of the parent
| container. If this is ``True`` (default), Streamlit sets the width
| of the data editor to match the width of the parent container. If
| this is ``False``, Streamlit sets the data editor's width according
| to ``width``.
|
| .. deprecated::
| ``use_container_width`` is deprecated and will be removed in a
| future release. For ``use_container_width=True``, use
| ``width="stretch"``.
|
| hide_index : bool or None
| Whether to hide the index column(s). If ``hide_index`` is ``None``
| (default), the visibility of index columns is automatically
| determined based on the data.
|
| column_order : Iterable[str] or None
| The ordered list of columns to display. If this is ``None``
| (default), Streamlit displays all columns in the order inherited
| from the underlying data structure. If this is a list, the
| indicated columns will display in the order they appear within the
| list. Columns may be omitted or repeated within the list.
|
| For example, ``column_order=("col2", "col1")`` will display
| ``"col2"`` first, followed by ``"col1"``, and will hide all other
| non-index columns.
|
| ``column_order`` does not accept positional column indices and
| can't move the index column(s).
|
| .. note::
| Columns omitted from ``column_order`` are hidden by default
| but can still be shown by the user via the column visibility
| menu in the table toolbar. If a column contains sensitive data
| that should not be exposed to the user, remove it from the
| data before passing it to the function.
|
| column_config : dict or None
| Configuration to customize how columns are displayed. If this is
| ``None`` (default), columns are styled based on the underlying data
| type of each column.
|
| Column configuration can modify column names, visibility, type,
| width, format, editing properties like min/max, and more. If this
| is a dictionary, the keys are column names (strings) and/or
| positional column indices (integers), and the values are one of the
| following:
|
| - ``None`` to hide the column. Hidden columns can still be shown
| by the user via the table toolbar.
| - A string to set the display label of the column.
| - One of the column types defined under ``st.column_config``. For
| example, to show a column as dollar amounts, use
| ``st.column_config.NumberColumn("Dollar values", format="$ %d")``.
| See more info on the available column types and config options
| `here <https://docs.streamlit.io/develop/api-reference/data/st.column_config>`_.
|
| To configure the index column(s), use ``"_index"`` as the column
| name, or use a positional column index where ``0`` refers to the
| first index column.
|
| num_rows : "fixed", "dynamic", "add", or "delete"
| Specifies if the user can add and/or delete rows in the data editor.
|
| - ``"fixed"`` (default): The user can't add or delete rows.
| - ``"dynamic"``: The user can add and delete rows, and column
| sorting is disabled.
| - ``"add"``: The user can only add rows (no deleting), and column
| sorting is disabled.
| - ``"delete"``: The user can only delete rows (no adding), and
| column sorting remains enabled.
|
| disabled : bool or Iterable[str | int]
| Controls the editing of columns. This can be one of the following:
|
| - ``False`` (default): All columns that support editing are editable.
| - ``True``: All columns are disabled for editing.
| - An Iterable of column names and/or positional indices: The
| specified columns are disabled for editing while the remaining
| columns are editable where supported. For example,
| ``disabled=["col1", "col2"]`` will disable editing for the
| columns named "col1" and "col2".
|
| To disable editing for the index column(s), use ``"_index"`` as the
| column name, or use a positional column index where ``0`` refers to
| the first index column.
|
| key : str, int, or None
| An optional string to use as the unique key for this widget.
| If this is ``None`` (default), a key will be generated for
| the widget based on the values of the other parameters. No
| two widgets may have the same key.
|
| A key lets you access the widget's value via
| ``st.session_state[key]`` (read-only). For more details, see
| `Widget behavior
| <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
|
| Additionally, if ``key`` is provided, it will be used as a
| CSS class name prefixed with ``st-key-``.
|
| on_change : callable
| An optional callback invoked when this data_editor's value changes.
|
| args : list or tuple
| An optional list or tuple of args to pass to the callback.
|
| kwargs : dict
| An optional dict of kwargs to pass to the callback.
|
| row_height : int or None
| The height of each row in the data editor in pixels. If ``row_height``
| is ``None`` (default), Streamlit will use a default row height,
| which fits one line of text.
|
| placeholder : str or None
| The text that should be shown for missing values. If this is
| ``None`` (default), missing values are displayed as "None". To
| leave a cell empty, use an empty string (``""``). Other common
| values are ``"null"``, ``"NaN"`` and ``"-"``.
|
| Returns
| -------
| pandas.DataFrame, pandas.Series, pyarrow.Table, numpy.ndarray, list, set, tuple, or dict.
| The edited data. The edited data is returned in its original data type if
| it corresponds to any of the supported return types. All other data types
| are returned as a ``pandas.DataFrame``.
|
| Examples
| --------
| **Example 1: Basic usage**
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>>
| >>> df = pd.DataFrame(
| >>> [
| >>> {"command": "st.selectbox", "rating": 4, "is_widget": True},
| >>> {"command": "st.balloons", "rating": 5, "is_widget": False},
| >>> {"command": "st.time_input", "rating": 3, "is_widget": True},
| >>> ]
| >>> )
| >>> edited_df = st.data_editor(df)
| >>>
| >>> favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
| >>> st.markdown(f"Your favorite command is **{favorite_command}** 🎈")
|
| .. output::
| https://doc-data-editor.streamlit.app/
| height: 350px
|
| **Example 2: Allowing users to add and delete rows**
|
| You can allow your users to add and delete rows by setting ``num_rows``
| to "dynamic":
|
| >>> import streamlit as st
| >>> import pandas as pd
| >>>
| >>> df = pd.DataFrame(
| >>> [
| >>> {"command": "st.selectbox", "rating": 4, "is_widget": True},
| >>> {"command": "st.balloons", "rating": 5, "is_widget": False},
| >>> {"command": "st.time_input", "rating": 3, "is_widget": True},
| >>> ]
| >>> )
| >>> edited_df = st.data_editor(df, num_rows="dynamic")
| >>>
| >>> favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
| >>> st.markdown(f"Your favorite command is **{favorite_command}** 🎈")
|
| .. output::
| https://doc-data-editor1.streamlit.app/
| height: 450px
|
| **Example 3: Data editor configuration**
|
| You can customize the data editor via ``column_config``, ``hide_index``,
| ``column_order``, or ``disabled``:
|
| >>> import pandas as pd
| >>> import streamlit as st
| >>>
| >>> df = pd.DataFrame(
| >>> [
| >>> {"command": "st.selectbox", "rating": 4, "is_widget": True},
| >>> {"command": "st.balloons", "rating": 5, "is_widget": False},
| >>> {"command": "st.time_input", "rating": 3, "is_widget": True},
| >>> ]
| >>> )
| >>> edited_df = st.data_editor(
| >>> df,
| >>> column_config={
| >>> "command": "Streamlit Command",
| >>> "rating": st.column_config.NumberColumn(
| >>> "Your rating",
| >>> help="How much do you like this command (1-5)?",
| >>> min_value=1,
| >>> max_value=5,
| >>> step=1,
| >>> format="%d ⭐",
| >>> ),
| >>> "is_widget": "Widget ?",
| >>> },
| >>> disabled=["command", "is_widget"],
| >>> hide_index=True,
| >>> )
| >>>
| >>> favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
| >>> st.markdown(f"Your favorite command is **{favorite_command}** 🎈")
|
|
| .. output::
| https://doc-data-editor-config.streamlit.app/
| height: 350px
DATA
AncestorBlockTypes = collections.abc.Iterable[str]
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
ForwardMsgCreator = collections.abc.Callable[[], streamlit.proto.Forwa...
Literal = typing.Literal
Special typing form to define literal types (a.k.a. value types).
This form can be used to indicate to type checkers that the corresponding
variable or function parameter has a value equivalent to the provided
literal (or one of several literals)::
def validate_simple(data: Any) -> Literal[True]: # always returns True
...
MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
...
open_helper('/some/path', 'r') # Passes type check
open_helper('/other/path', 'typo') # Error in type checker
Literal[...] cannot be subclassed. At runtime, an arbitrary value
is allowed as type argument to Literal[...], but type checkers may
impose restrictions.
MAX_DELTA_BYTES = 14680064
NoReturn = typing.NoReturn
Special type indicating functions that never return.
Example::
from typing import NoReturn
def stop() -> NoReturn:
raise Exception('no way')
NoReturn can also be used as a bottom type, a type that
has no values. Starting in Python 3.11, the Never type should
be used for this concept instead. Type checkers should treat the two
equivalently.
RootContainer = <google.protobuf.internal.enum_type_wrapper.EnumTypeWr...
TYPE_CHECKING = False
TypeAlias = typing.TypeAlias
Special form for marking type aliases.
Use TypeAlias to indicate that an assignment should
be recognized as a proper type alias definition by type
checkers.
For example::
Predicate: TypeAlias = Callable[..., bool]
It's invalid when used anywhere except as in the example above.
Value = ~Value
__annotations__ = {'AncestorBlockTypes': 'TypeAlias', 'BlockType': 'Ty...
context_dg_stack = <streamlit.delta_generator_singletons.ContextVarWit...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\delta_generator.py
streamlit.delta_generator_singletons
Python Library Documentation: module streamlit.delta_generator_singletons in streamlit
NAME
streamlit.delta_generator_singletons
DESCRIPTION
The main purpose of this module (right now at least) is to avoid a dependency
cycle between streamlit.delta_generator and some elements.
CLASSES
builtins.object
DeltaGeneratorSingleton
typing.Generic(builtins.object)
ContextVarWithLazyDefault
class ContextVarWithLazyDefault(typing.Generic)
| ContextVarWithLazyDefault(name: 'str', *, default: 'Callable[[], _T]') -> 'None'
|
| The dg_stack tracks the currently active DeltaGenerator, and is pushed to when
| a DeltaGenerator is entered via a `with` block. This is implemented as a ContextVar
| so that different threads or async tasks can have their own stacks.
|
| We have a wrapper around it because ContextVar default cannot be a function, but
| the default dg (main_dg) might not exist yet when this module is imported.
|
| Method resolution order:
| ContextVarWithLazyDefault
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __eq__(self, other: 'object') -> 'bool'
| Return self==value.
|
| __hash__(self) -> 'int'
| Return hash(self).
|
| __init__(self, name: 'str', *, default: 'Callable[[], _T]') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| get(self) -> '_T'
|
| reset(self, token: 'Token[_T]') -> 'None'
|
| set(self, value: '_T') -> 'Token[_T]'
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| __orig_bases__ = (typing.Generic[~_T],)
|
| __parameters__ = (~_T,)
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.
class DeltaGeneratorSingleton(builtins.object)
| DeltaGeneratorSingleton(delta_generator_cls: 'type[DeltaGenerator]', status_container_cls: 'type[StatusContainer]', dialog_container_cls: 'type[Dialog]', expander_container_cls: 'type[ExpanderContainer]', tab_container_cls: 'type[TabContainer]', popover_container_cls: 'type[PopoverContainer]') -> 'None'
|
| Used to initialize the DeltaGenerator classes and store them as singletons.
| This module allows us to avoid circular imports between DeltaGenerator and elements,
| because elements can import this singleton module instead of DeltaGenerator directly.
|
| Methods defined here:
|
| __init__(self, delta_generator_cls: 'type[DeltaGenerator]', status_container_cls: 'type[StatusContainer]', dialog_container_cls: 'type[Dialog]', expander_container_cls: 'type[ExpanderContainer]', tab_container_cls: 'type[TabContainer]', popover_container_cls: 'type[PopoverContainer]') -> 'None'
| Registers and initializes all delta-generator classes.
|
| Parameters
| ----------
| delta_generator_cls : type[DeltaGenerator]
| The main DeltaGenerator class.
| status_container_cls : type[StatusContainer]
| The delta-generator class that is used as return value for `st.status`.
| dialog_container_cls : type[Dialog]
| The delta-generator class is used as return value for `st.dialog`.
| expander_container_cls : type[ExpanderContainer]
| The delta-generator class used as return value for `st.expander`.
| tab_container_cls : type[TabContainer]
| The delta-generator class used as return value for individual tabs
| in `st.tabs`.
| popover_container_cls : type[PopoverContainer]
| The delta-generator class used as return value for `st.popover`.
|
| Raises
| ------
| RuntimeError
| If the DeltaGeneratorSingleton instance already exists.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| instance() -> 'DeltaGeneratorSingleton'
| Return the singleton DeltaGeneratorSingleton instance. Raise an Error if the
| DeltaGeneratorSingleton hasn't been created yet.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| bottom_dg
|
| dialog_container_cls
| Stub for Dialog. Since Dialog inherits from DeltaGenerator,
| this is used to avoid circular imports.
|
| event_dg
|
| expander_container_cls
| Stub for ExpanderContainer. Since ExpanderContainer inherits from
| DeltaGenerator, this is used to avoid circular imports.
|
| main_dg
|
| popover_container_cls
| Stub for PopoverContainer. Since PopoverContainer inherits from
| DeltaGenerator, this is used to avoid circular imports.
|
| sidebar_dg
|
| status_container_cls
| Stub for StatusContainer. Since StatusContainer inherits from DeltaGenerator,
| this is used to avoid circular imports.
|
| tab_container_cls
| Stub for TabContainer. Since TabContainer inherits from
| DeltaGenerator, this is used to avoid circular imports.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'_instance': 'DeltaGeneratorSingleton | None'}
FUNCTIONS
get_default_dg_stack_value() -> 'tuple[DeltaGenerator, ...]'
Get the default dg_stack value with which the dg_stack should
be initialized and reset if needed.
get_dg_singleton_instance() -> 'DeltaGeneratorSingleton'
Return the DeltaGeneratorSingleton instance. Raise an Error if the
DeltaGeneratorSingleton hasn't been created yet.
get_last_dg_added_to_context_stack() -> 'DeltaGenerator | None'
Get the last added DeltaGenerator of the stack in the current context.
Returns None if the stack has only one element or is empty for whatever reason.
DATA
TYPE_CHECKING = False
__annotations__ = {'context_dg_stack': 'ContextVarWithLazyDefault[tupl...
context_dg_stack = <streamlit.delta_generator_singletons.ContextVarWit...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\delta_generator_singletons.py
streamlit.deprecation_util
Python Library Documentation: module streamlit.deprecation_util in streamlit
NAME
streamlit.deprecation_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUNCTIONS
deprecate_func_name(func: 'TFunc', old_name: 'str', removal_date: 'str', extra_message: 'str | None' = None, name_override: 'str | None' = None, include_st_prefix: 'bool' = True, show_in_browser: 'bool' = True, show_once: 'bool' = False) -> 'TFunc'
Wrap an `st` function whose name has changed.
Wrapped functions will run as normal, but will also show an st.warning
saying that the old name will be removed after removal_date.
(We generally set `removal_date` to 3 months from the deprecation date.)
Parameters
----------
func
The `st.` function whose name has changed.
old_name
The function's deprecated name within __init__.py.
removal_date
A date like "2020-01-01", indicating the last day we'll guarantee
support for the deprecated name.
extra_message
An optional extra message to show in the deprecation warning.
name_override
An optional name to use in place of func.__name__.
include_st_prefix
If False, does not prefix each of the function names in the deprecation
message with `st.*`. Defaults to True.
show_in_browser
Whether to show the deprecation warning in the browser. Defaults to True.
Set to False for less intrusive deprecation warnings that only log to
the console.
show_once
If True, the warning will only be shown once per unique message.
Defaults to False.
deprecate_obj_name(obj: 'TObj', old_name: 'str', new_name: 'str', removal_date: 'str', include_st_prefix: 'bool' = True) -> 'TObj'
Wrap an `st` object whose name has changed.
Wrapped objects will behave as normal, but will also show an st.warning
saying that the old name will be removed after `removal_date`.
(We generally set `removal_date` to 3 months from the deprecation date.)
Parameters
----------
obj
The `st.` object whose name has changed.
old_name
The object's deprecated name within __init__.py.
new_name
The object's new name within __init__.py.
removal_date
A date like "2020-01-01", indicating the last day we'll guarantee
support for the deprecated name.
include_st_prefix
If False, does not prefix each of the object names in the deprecation
message with `st.*`. Defaults to True.
make_deprecated_name_warning(old_name: 'str', new_name: 'str', removal_date: 'str', extra_message: 'str | None' = None, include_st_prefix: 'bool' = True) -> 'str'
show_deprecation_warning(message: 'str', show_in_browser: 'bool' = True, show_once: 'bool' = False) -> 'None'
Show a deprecation warning message.
Parameters
----------
message : str
The deprecation warning message.
show_in_browser : bool, default=True
Whether to show the deprecation warning in the browser. When this is True,
we will show the deprecation warning in the browser only if the user has
set `client.showErrorDetails` to "full" or the legacy True value. All
other values ("stacktrace", "type", "none", False) will hide deprecation
warnings in the browser (but still log them to the console).
show_once : bool, default=False
If True, the warning will only be shown once per unique message (based on
message hash). Subsequent calls with the same message will be skipped.
This is useful for warnings that may be triggered many times during a
script run.
DATA
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
TFunc = ~TFunc
TObj = ~TObj
__annotations__ = {'_LOGGER': 'Final', '_shown_warnings': 'set[str]'}
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\deprecation_util.py
streamlit.development
Python Library Documentation: module streamlit.development in streamlit
NAME
streamlit.development - Variables for dev purposes.
DESCRIPTION
The main purpose of this module (right now at least) is to avoid a dependency
cycle between streamlit.config and streamlit.logger.
DATA
is_development_mode = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\development.py
streamlit.dialog
Python Library Documentation: function dialog_decorator in module streamlit.elements.dialog_decorator
dialog_decorator(title: 'F | str', *, width: 'DialogWidth' = 'small', dismissible: 'bool' = True, icon: 'str | None' = None, on_dismiss: "Literal['ignore', 'rerun'] | WidgetCallback" = 'ignore') -> 'F | Callable[[F], F]'
Function decorator to create a modal dialog.
A function decorated with ``@st.dialog`` becomes a dialog
function. When you call a dialog function, Streamlit inserts a modal dialog
into your app. Streamlit element commands called within the dialog function
render inside the modal dialog.
The dialog function can accept arguments that can be passed when it is
called. Any values from the dialog that need to be accessed from the wider
app should generally be stored in Session State.
If a dialog is dismissible, a user can dismiss it by clicking outside of
it, clicking the "**X**" in its upper-right corner, or pressing ``ESC`` on
their keyboard. You can configure whether this triggers a rerun of the app
by setting the ``on_dismiss`` parameter.
If a dialog is not dismissible, it must be closed programmatically by
calling ``st.rerun()`` inside the dialog function. This is useful when you
want to ensure that the dialog is always closed programmatically, such as
when the dialog contains a form that must be submitted before closing.
``st.dialog`` inherits behavior from |st.fragment|_.
When a user interacts with an input widget created inside a dialog function,
Streamlit only reruns the dialog function instead of the full script.
Calling ``st.sidebar`` in a dialog function is not supported.
Dialog code can interact with Session State, imported modules, and other
Streamlit elements created outside the dialog. Note that these interactions
are additive across multiple dialog reruns. You are responsible for
handling any side effects of that behavior.
.. warning::
Only one dialog function may be called in a script run, which means
that only one dialog can be open at any given time.
.. |st.fragment| replace:: ``st.fragment``
.. _st.fragment: https://docs.streamlit.io/develop/api-reference/execution-flow/st.fragment
Parameters
----------
title : str
The title to display at the top of the modal dialog. It cannot be empty.
The title can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
width : "small", "medium", "large"
The width of the modal dialog. This can be one of the following:
- ``"small"`` (default): The modal dialog will be a maximum of 500
pixels wide.
- ``"medium"``: The modal dialog will be up to 750 pixels wide.
- ``"large"``: The modal dialog will be up to 1280 pixels wide.
dismissible : bool
Whether the modal dialog can be dismissed by the user. If this is
``True`` (default), the user can dismiss the dialog by clicking
outside of it, clicking the "**X**" in its upper-right corner, or
pressing ``ESC`` on their keyboard. If this is ``False``, the "**X**"
in the upper-right corner is hidden and the dialog must be closed
programmatically by calling ``st.rerun()`` inside the dialog function.
.. note::
Setting ``dismissible`` to ``False`` does not guarantee that all
interactions in the main app are blocked. Don't rely on
``dismissible`` for security-critical checks.
icon : str or None
An optional emoji or icon to display next to the dialog title. If ``icon``
is ``None`` (default), no icon is displayed. If ``icon`` is a
string, the following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols \
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
on_dismiss : "ignore", "rerun", or callable
How the dialog should respond to dismissal events.
This can be one of the following:
- ``"ignore"`` (default): Streamlit will not rerun the app when the
user dismisses the dialog.
- ``"rerun"``: Streamlit will rerun the app when the user dismisses
the dialog.
- A ``callable``: Streamlit will rerun the app when the user dismisses
the dialog and execute the ``callable`` as a callback function
before the rest of the app.
Examples
--------
The following example demonstrates the basic usage of ``@st.dialog``.
In this app, clicking "**A**" or "**B**" will open a modal dialog and prompt you
to enter a reason for your vote. In the modal dialog, click "**Submit**" to record
your vote into Session State and rerun the app. This will close the modal dialog
since the dialog function is not called during the full-script rerun.
>>> import streamlit as st
>>>
>>> @st.dialog("Cast your vote")
>>> def vote(item):
>>> st.write(f"Why is {item} your favorite?")
>>> reason = st.text_input("Because...")
>>> if st.button("Submit"):
>>> st.session_state.vote = {"item": item, "reason": reason}
>>> st.rerun()
>>>
>>> if "vote" not in st.session_state:
>>> st.write("Vote for your favorite")
>>> if st.button("A"):
>>> vote("A")
>>> if st.button("B"):
>>> vote("B")
>>> else:
>>> f"You voted for {st.session_state.vote['item']} because {st.session_state.vote['reason']}"
.. output::
https://doc-modal-dialog.streamlit.app/
height: 350px
streamlit.divider
Python Library Documentation: method divider in module streamlit.delta_generator
divider(*, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a horizontal rule.
.. note::
You can achieve the same effect with st.write("---") or
even just "---" in your script (via magic).
Parameters
----------
width : "stretch" or int
The width of the divider element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Examples
--------
>>> import streamlit as st
>>>
>>> st.divider()
streamlit.download_button
Python Library Documentation: method download_button in module streamlit.delta_generator
download_button(label: 'str', data: 'DownloadButtonDataType', file_name: 'str | None' = None, mime: 'str | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_click: "WidgetCallback | Literal['rerun', 'ignore'] | None" = 'rerun', args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', icon: 'str | None' = None, icon_position: 'IconPosition' = 'left', disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', shortcut: 'str | None' = None) -> 'bool' method of streamlit.delta_generator.DeltaGenerator instance
Display a download button widget.
This is useful when you would like to provide a way for your users
to download a file directly from your app.
If you pass the data directly to the ``data`` parameter, then the data
is stored in-memory while the user is connected. It's a good idea to
keep file sizes under a couple hundred megabytes to conserve memory or
use deferred data generation by passing a callable to the ``data``
parameter.
If you want to prevent your app from rerunning when a user clicks the
download button, wrap the download button in a `fragment
<https://docs.streamlit.io/develop/concepts/architecture/fragments>`_.
Parameters
----------
label : str
A short label explaining to the user what this button is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
data : str, bytes, file-like, or callable
The contents of the file to be downloaded or a callable that
returns the contents of the file.
File contents can be a string, bytes, or file-like object.
File-like objects include ``io.BytesIO``, ``io.StringIO``, or any
class that implements the abstract base class ``io.RawIOBase``.
If a callable is passed, it is executed when the user clicks
the download button and runs on a separate thread from the
resulting script rerun. This deferred generation is helpful for
large files to avoid blocking the page script. The callable can't
accept any arguments. If any Streamlit commands are executed inside
the callable, they will be ignored.
To prevent unnecessary recomputation, use caching when converting
your data for download. For more information, see the Example 1
below.
file_name: str
An optional string to use as the name of the file to be downloaded,
such as ``"my_file.csv"``. If not specified, the name will be
automatically generated.
mime : str or None
The MIME type of the data. If this is ``None`` (default), Streamlit
sets the MIME type depending on the value of ``data`` as follows:
- If ``data`` is a string or textual file (i.e. ``str`` or
``io.TextIOWrapper`` object), Streamlit uses the "text/plain"
MIME type.
- If ``data`` is a binary file or bytes (i.e. ``bytes``,
``io.BytesIO``, ``io.BufferedReader``, or ``io.RawIOBase``
object), Streamlit uses the "application/octet-stream" MIME type.
For more information about MIME types, see
https://www.iana.org/assignments/media-types/media-types.xhtml.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you access the widget's value via
``st.session_state[key]`` (read-only). For more details, see
`Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed when the button is hovered over. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_click : callable, "rerun", "ignore", or None
How the button should respond to user interaction. This controls
whether or not the button triggers a rerun and if a callback
function is called. This can be one of the following values:
- ``"rerun"`` (default): The user downloads the file and the app
reruns. No callback function is called.
- ``"ignore"``: The user downloads the file and the app doesn't
rerun. No callback function is called.
- A ``callable``: The user downloads the file and app reruns. The
callable is called before the rest of the app.
- ``None``: This is same as ``on_click="rerun"``. This value exists
for backwards compatibility and shouldn't be used.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
type : "primary", "secondary", or "tertiary"
An optional string that specifies the button type. This can be one
of the following:
- ``"primary"``: The button's background is the app's primary color
for additional emphasis.
- ``"secondary"`` (default): The button's background coordinates
with the app's background color for normal emphasis.
- ``"tertiary"``: The button is plain text without a border or
background for subtlety.
icon : str or None
An optional emoji or icon to display next to the button label. If ``icon``
is ``None`` (default), no icon is displayed. If ``icon`` is a
string, the following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols \
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
icon_position : "left" or "right"
The position of the icon relative to the button label. This
defaults to ``"left"``.
disabled : bool
An optional boolean that disables the download button if set to
``True``. The default is ``False``.
use_container_width : bool
Whether to expand the button's width to fill its parent container.
If ``use_container_width`` is ``False`` (default), Streamlit sizes
the button to fit its contents. If ``use_container_width`` is
``True``, the width of the button matches its parent container.
In both cases, if the contents of the button are wider than the
parent container, the contents will line wrap.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``. For ``use_container_width=False``, use
``width="content"``.
width : "content", "stretch", or int
The width of the download button. This can be one of the following:
- ``"content"`` (default): The width of the button matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the button matches the width of the
parent container.
- An integer specifying the width in pixels: The button has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the button matches the width
of the parent container.
shortcut : str or None
An optional keyboard shortcut that triggers the button. This can be
one of the following strings:
- A single alphanumeric key like ``"K"`` or ``"4"``.
- A function key like ``"F11"``.
- A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
- Any of the above combined with modifiers. For example, you can use
``"Ctrl+K"`` or ``"Cmd+Shift+O"``.
.. important::
The keys ``"C"`` and ``"R"`` are reserved and can't be used,
even with modifiers. Punctuation keys like ``"."`` and ``","``
aren't currently supported.
For a list of supported keys and modifiers, see the documentation
for |st.button|_.
.. |st.button| replace:: ``st.button``
.. _st.button: https://docs.streamlit.io/develop/api-reference/widgets/st.button
Returns
-------
bool
True if the button was clicked on the last run of the app,
False otherwise.
Examples
--------
**Example 1: Download a dataframe as a CSV file**
When working with a large dataframe, it's recommended to fetch your
data with a cached function. When working with a download button, it's
similarly recommended to convert your data into a downloadable format
with a cached function. Caching ensures that the app reruns
efficiently.
>>> import streamlit as st
>>> import pandas as pd
>>> import numpy as np
>>>
>>> @st.cache_data
>>> def get_data():
>>> df = pd.DataFrame(
... np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
... )
>>> return df
>>>
>>> @st.cache_data
>>> def convert_for_download(df):
>>> return df.to_csv().encode("utf-8")
>>>
>>> df = get_data()
>>> csv = convert_for_download(df)
>>>
>>> st.download_button(
... label="Download CSV",
... data=csv,
... file_name="data.csv",
... mime="text/csv",
... icon=":material/download:",
... )
.. output::
https://doc-download-button-csv.streamlit.app/
height: 200px
**Example 2: Download a string as a text file**
If you pass a string to the ``data`` argument, Streamlit will
automatically use the "text/plain" MIME type.
When you have a widget (like a text area) affecting the value of your
download, it's recommended to use another button to prepare the
download. In this case, use ``on_click="ignore"`` in your download
button to prevent the download button from rerunning your app. This
turns the download button into a frontend-only element that can be
nested in another button.
Without a preparation button, a user can type something into the text
area and immediately click the download button. Because a download is
initiated concurrently with the app rerun, this can create a race-like
condition where the user doesn't see the updated data in their
download.
.. important::
Even when you prevent your download button from triggering a rerun,
another widget with a pending change can still trigger a rerun. For
example, if a text area has a pending change when a user clicks a
download button, the text area will trigger a rerun.
>>> import streamlit as st
>>>
>>> message = st.text_area("Message", value="Lorem ipsum.\nStreamlit is cool.")
>>>
>>> if st.button("Prepare download"):
>>> st.download_button(
... label="Download text",
... data=message,
... file_name="message.txt",
... on_click="ignore",
... type="primary",
... icon=":material/download:",
... )
.. output::
https://doc-download-button-text.streamlit.app/
height: 250px
**Example 3: Download a file**
Use a context manager to open and read a local file on your Streamlit
server. Pass the ``io.BufferedReader`` object directly to ``data``.
Remember to specify the MIME type if you don't want the default
type of ``"application/octet-stream"`` for generic binary data. In the
example below, the MIME type is set to ``"image/png"`` for a PNG file.
>>> import streamlit as st
>>>
>>> with open("flower.png", "rb") as file:
... st.download_button(
... label="Download image",
... data=file,
... file_name="flower.png",
... mime="image/png",
... )
.. output::
https://doc-download-button-file.streamlit.app/
height: 200px
**Example 4: Generate the data on-click with a callable**
Pass a callable to ``data`` to generate the bytes lazily when the user
clicks the button. Streamlit commands inside this callable are ignored.
The callable can't accept any arguments and must return a file-like
object.
>>> import streamlit as st
>>> import time
>>>
>>> def make_report():
>>> time.sleep(1)
>>> return "col1,col2\n1,2\n3,4".encode("utf-8")
>>>
>>> st.download_button(
... label="Download report",
... data=make_report,
... file_name="report.csv",
... mime="text/csv",
... )
.. output::
https://doc-download-button-deferred.streamlit.app/
height: 200px
streamlit.echo
Python Library Documentation: function echo in module streamlit.commands.echo
echo(code_location: "Literal['above', 'below']" = 'above') -> 'Generator[None, None, None]'
Use in a `with` block to draw some code on the app, then execute it.
Parameters
----------
code_location : "above" or "below"
Whether to show the echoed code before or after the results of the
executed code block.
Examples
--------
>>> import streamlit as st
>>>
>>> with st.echo():
>>> st.write('This code will be printed')
streamlit.elements
Python Library Documentation: package streamlit.elements in streamlit
NAME
streamlit.elements
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PACKAGE CONTENTS
alert
arrow
balloons
bokeh_chart
bottom
code
deck_gl_json_chart
dialog_decorator
empty
exception
form
graphviz_chart
heading
help
html
iframe
image
json
layouts
lib (package)
map
markdown
media
metric
pdf
plotly_chart
progress
pyplot
snow
space
spinner
table
text
toast
vega_charts
widgets (package)
write
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\elements\__init__.py
streamlit.empty
Python Library Documentation: method empty in module streamlit.delta_generator
empty() -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Insert a single-element container.
Inserts a container into your app that can be used to hold a single element.
This allows you to, for example, remove elements at any point, or replace
several elements at once (using a child multi-element container).
To insert/replace/clear an element on the returned container, you can
use ``with`` notation or just call methods directly on the returned object.
See examples below.
Examples
--------
Inside a ``with st.empty():`` block, each displayed element will
replace the previous one.
>>> import streamlit as st
>>> import time
>>>
>>> with st.empty():
... for seconds in range(10):
... st.write(f"⏳ {seconds} seconds have passed")
... time.sleep(1)
... st.write(":material/check: 10 seconds over!")
... st.button("Rerun")
.. output::
https://doc-empty.streamlit.app/
height: 220px
You can use an ``st.empty`` to replace multiple elements in
succession. Use ``st.container`` inside ``st.empty`` to display (and
later replace) a group of elements.
>>> import streamlit as st
>>> import time
>>>
>>> st.button("Start over")
>>>
>>> placeholder = st.empty()
>>> placeholder.markdown("Hello")
>>> time.sleep(1)
>>>
>>> placeholder.progress(0, "Wait for it...")
>>> time.sleep(1)
>>> placeholder.progress(50, "Wait for it...")
>>> time.sleep(1)
>>> placeholder.progress(100, "Wait for it...")
>>> time.sleep(1)
>>>
>>> with placeholder.container():
... st.line_chart({"data": [1, 5, 2, 6]})
... time.sleep(1)
... st.markdown("3...")
... time.sleep(1)
... st.markdown("2...")
... time.sleep(1)
... st.markdown("1...")
... time.sleep(1)
>>>
>>> placeholder.markdown("Poof!")
>>> time.sleep(1)
>>>
>>> placeholder.empty()
.. output::
https://doc-empty-placeholder.streamlit.app/
height: 600px
streamlit.env_util
Python Library Documentation: module streamlit.env_util in streamlit
NAME
streamlit.env_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUNCTIONS
is_executable_in_path(name: 'str') -> 'bool'
Check if executable is in OS path.
is_pex() -> 'bool'
Return if streamlit running in pex.
Pex modifies sys.path so the pex file is the first path and that's
how we determine we're running in the pex file.
is_repl() -> 'bool'
Return True if running in the Python REPL.
DATA
IS_DARWIN = False
IS_LINUX_OR_BSD = False
IS_WINDOWS = True
SYSTEM = 'windows'
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\env_util.py
streamlit.error
Python Library Documentation: method error in module streamlit.delta_generator
error(body: 'SupportsStr', *, icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', title: 'SupportsStr | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display error message.
Parameters
----------
body : str
The text to display as GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
If ``icon`` is ``None``, and ``body`` begins with an emoji or
Material icon shortcode, Streamlit will extract it and display it
slightly enlarged, as if it were passed to ``icon``. If ``body``
contains multiple icons, or you want to override this behavior,
you can insert a null Markdown directive like ``:red[]`` before
your leading icon.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
icon : str or None
An optional emoji or icon to display next to the alert. If ``icon``
is ``None`` (default), Streamlit attempts to extract a leading
emoji or Material icon shortcode from ``body``. If found, the icon
is displayed and removed from the body text. If no leading icon is
found, no icon is displayed. If ``icon`` is a string, it takes
precedence over any icon in the body, and the following options
are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
width : "stretch" or int
The width of the alert element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
title : str or None
An optional title to display above the body text. If ``None``
(default), no title is displayed. The title is rendered with bold
styling and can optionally contain GitHub-flavored Markdown of the
following types: Italics, Strikethroughs, Inline Code, Links, and
Images. Images display like icons, with a max height equal to the
font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Display elements are not supported.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
Examples
--------
>>> import streamlit as st
>>>
>>> st.error('This is an error', icon="🚨")
streamlit.error_util
Python Library Documentation: module streamlit.error_util in streamlit
NAME
streamlit.error_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUNCTIONS
handle_uncaught_app_exception(ex: 'BaseException') -> 'None'
Handle an exception that originated from a user app.
By default, we show exceptions directly in the browser. However,
if the user has disabled client error details, we display a generic
warning in the frontend instead.
DATA
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
__annotations__ = {'_LOGGER': 'Final'}
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\error_util.py
streamlit.errors
Python Library Documentation: module streamlit.errors in streamlit
NAME
streamlit.errors
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CLASSES
builtins.Exception(builtins.BaseException)
Error
CustomComponentError
DeprecationError
FragmentStorageKeyError(Error, builtins.KeyError)
MarkdownFormattedException
StreamlitAPIException
DuplicateWidgetID
StreamlitDuplicateElementId
StreamlitDuplicateElementKey
LocalizableStreamlitException
BidiComponentInvalidCallbackNameError
BidiComponentInvalidDefaultKeyError
BidiComponentInvalidIdError
BidiComponentUnserializableDataError
StreamlitBadTimeStringError
StreamlitFragmentWidgetsNotAllowedOutsideError
StreamlitInvalidBindValueError
StreamlitInvalidColorError
StreamlitInvalidColumnGapError
StreamlitInvalidColumnSpecError
StreamlitInvalidFormCallbackError
StreamlitInvalidHeightError
StreamlitInvalidHorizontalAlignmentError
StreamlitInvalidMaxError
StreamlitInvalidMenuItemKeyError
StreamlitInvalidNumberFormatError
StreamlitInvalidPageLayoutError
StreamlitInvalidSidebarStateError
StreamlitInvalidSizeError
StreamlitInvalidTextAlignmentError
StreamlitInvalidThemeError
StreamlitInvalidThemeOptionError
StreamlitInvalidThemeSectionError
StreamlitInvalidURLError
StreamlitInvalidVerticalAlignmentError
StreamlitInvalidWidthError
StreamlitJSNumberBoundsError
StreamlitMissingPageLabelError
StreamlitMixedNumericTypesError
StreamlitPageNotFoundError
StreamlitQueryParamDictValueError
StreamlitSecretNotFoundError(LocalizableStreamlitException, builtins.FileNotFoundError)
StreamlitSelectionCountExceedsMaxError
StreamlitValueAboveMaxError
StreamlitValueAssignmentNotAllowedError
StreamlitValueBelowMinError
StreamlitValueError
StreamlitAPIWarning(StreamlitAPIException, builtins.Warning)
StreamlitModuleNotFoundError
StreamlitAuthError
UnserializableSessionStateError
NoSessionContext
NoStaticFiles
StreamlitComponentRegistryError
StreamlitMaxRetriesError
FragmentHandledException
class BidiComponentInvalidCallbackNameError(LocalizableStreamlitException)
| BidiComponentInvalidCallbackNameError(callback_name: 'str') -> 'None'
|
| Exception raised when a callback with an invalid name is provided.
|
| Method resolution order:
| BidiComponentInvalidCallbackNameError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, callback_name: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class BidiComponentInvalidDefaultKeyError(LocalizableStreamlitException)
| BidiComponentInvalidDefaultKeyError(state_key: 'str', available_keys: 'list[str]') -> 'None'
|
| Exception raised when an invalid key is provided in the default dict.
|
| Method resolution order:
| BidiComponentInvalidDefaultKeyError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, state_key: 'str', available_keys: 'list[str]') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class BidiComponentInvalidIdError(LocalizableStreamlitException)
| BidiComponentInvalidIdError(part: 'str', delimiter: 'str') -> 'None'
|
| Exception raised when an invalid ID component is provided.
|
| Method resolution order:
| BidiComponentInvalidIdError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, part: 'str', delimiter: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class BidiComponentUnserializableDataError(LocalizableStreamlitException)
| BidiComponentUnserializableDataError() -> 'None'
|
| Exception raised when data provided to a bidirectional component cannot be serialized.
|
| Method resolution order:
| BidiComponentUnserializableDataError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class CustomComponentError(Error)
| Exceptions thrown in the custom components code path.
|
| Method resolution order:
| CustomComponentError
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class DeprecationError(Error)
| Method resolution order:
| DeprecationError
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class DuplicateWidgetID(StreamlitAPIException)
| Method resolution order:
| DuplicateWidgetID
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class Error(builtins.Exception)
| The base class for all exceptions thrown by Streamlit.
|
| Should be used for exceptions raised due to user errors (typically via
| StreamlitAPIException) as well as exceptions raised by Streamlit's internal
| code.
|
| Method resolution order:
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class FragmentHandledException(builtins.Exception)
| An exception that is raised by the fragment
| when it has handled the exception itself.
|
| Method resolution order:
| FragmentHandledException
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class FragmentStorageKeyError(Error, builtins.KeyError)
| A KeyError raised when a KeyError is encountered during a FragmentStorage
| operation.
|
| Method resolution order:
| FragmentStorageKeyError
| Error
| builtins.KeyError
| builtins.LookupError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.KeyError:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __str__(self, /)
| Return str(self).
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.LookupError:
|
| __new__(*args, **kwargs) class method of builtins.LookupError
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class LocalizableStreamlitException(StreamlitAPIException)
| LocalizableStreamlitException(message: 'str', **kwargs: 'Any') -> 'None'
|
| Method resolution order:
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, message: 'str', **kwargs: 'Any') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class MarkdownFormattedException(Error)
| Exceptions with Markdown in their description.
|
| Instances of this class can use markdown in their messages, which will get
| nicely formatted on the frontend.
|
| Method resolution order:
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class NoSessionContext(Error)
| Method resolution order:
| NoSessionContext
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class NoStaticFiles(Error)
| Method resolution order:
| NoStaticFiles
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitAPIException(MarkdownFormattedException)
| Base class for Streamlit API exceptions.
|
| An API exception should be thrown when user code interacts with the
| Streamlit API incorrectly. (That is, when we throw an exception as a
| result of a user's malformed `st.foo` call, it should be a
| StreamlitAPIException or subclass.)
|
| When displaying these exceptions on the frontend, we strip Streamlit
| entries from the stack trace so that the user doesn't see a bunch of
| noise related to Streamlit internals.
|
| Method resolution order:
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitAPIWarning(StreamlitAPIException, builtins.Warning)
| StreamlitAPIWarning(*args: 'Any') -> 'None'
|
| Used to display a warning.
|
| Note that this should not be "raised", but passed to st.exception
| instead.
|
| Method resolution order:
| StreamlitAPIWarning
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Warning
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, *args: 'Any') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Warning:
|
| __new__(*args, **kwargs) class method of builtins.Warning
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitAuthError(StreamlitAPIException)
| Method resolution order:
| StreamlitAuthError
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitBadTimeStringError(LocalizableStreamlitException)
| StreamlitBadTimeStringError(time_string: 'str') -> 'None'
|
| Exception Raised when a time string argument is passed that cannot be parsed.
|
| Method resolution order:
| StreamlitBadTimeStringError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, time_string: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitComponentRegistryError(Error)
| Exceptions raised while discovering or registering Streamlit components.
|
| These errors occur during Streamlit startup when scanning installed
| distributions for component metadata and registering them with the component
| registry.
|
| Method resolution order:
| StreamlitComponentRegistryError
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitDuplicateElementId(DuplicateWidgetID)
| StreamlitDuplicateElementId(element_type: 'str') -> 'None'
|
| An exception raised when the auto-generated ID of an element is not unique.
|
| Method resolution order:
| StreamlitDuplicateElementId
| DuplicateWidgetID
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, element_type: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitDuplicateElementKey(DuplicateWidgetID)
| StreamlitDuplicateElementKey(user_key: 'str') -> 'None'
|
| An exception raised when the key of an element is not unique.
|
| Method resolution order:
| StreamlitDuplicateElementKey
| DuplicateWidgetID
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, user_key: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitFragmentWidgetsNotAllowedOutsideError(LocalizableStreamlitException)
| StreamlitFragmentWidgetsNotAllowedOutsideError() -> 'None'
|
| Exception raised when the fragment attempts to write to an element outside of its container.
|
| Method resolution order:
| StreamlitFragmentWidgetsNotAllowedOutsideError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidBindValueError(LocalizableStreamlitException)
| StreamlitInvalidBindValueError(bind_value: 'Any') -> 'None'
|
| Exception raised when an invalid value is specified for the bind parameter.
|
| Method resolution order:
| StreamlitInvalidBindValueError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, bind_value: 'Any') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidColorError(LocalizableStreamlitException)
| StreamlitInvalidColorError(color: 'str | Collection[Any] | tuple[int, int, int, int]') -> 'None'
|
| Method resolution order:
| StreamlitInvalidColorError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, color: 'str | Collection[Any] | tuple[int, int, int, int]') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidColumnGapError(LocalizableStreamlitException)
| StreamlitInvalidColumnGapError(gap: 'str', element_type: 'str') -> 'None'
|
| Exception raised when an invalid value is specified for gap.
|
| Method resolution order:
| StreamlitInvalidColumnGapError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, gap: 'str', element_type: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidColumnSpecError(LocalizableStreamlitException)
| StreamlitInvalidColumnSpecError() -> 'None'
|
| Exception raised when no weights are specified, or a negative weight is specified.
|
| Method resolution order:
| StreamlitInvalidColumnSpecError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidFormCallbackError(LocalizableStreamlitException)
| StreamlitInvalidFormCallbackError() -> 'None'
|
| Exception raised a `on_change` callback is set on any element in a form except for
| the `st.form_submit_button`.
|
| Method resolution order:
| StreamlitInvalidFormCallbackError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidHeightError(LocalizableStreamlitException)
| StreamlitInvalidHeightError(height: 'Any', allow_content: 'bool' = False) -> 'None'
|
| Exception raised when an invalid height value is provided.
|
| Method resolution order:
| StreamlitInvalidHeightError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, height: 'Any', allow_content: 'bool' = False) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidHorizontalAlignmentError(LocalizableStreamlitException)
| StreamlitInvalidHorizontalAlignmentError(horizontal_alignment: 'str', element_type: 'str') -> 'None'
|
| Exception raised when an invalid value is specified for horizontal_alignment.
|
| Method resolution order:
| StreamlitInvalidHorizontalAlignmentError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, horizontal_alignment: 'str', element_type: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidMaxError(LocalizableStreamlitException)
| StreamlitInvalidMaxError(widget_name: 'str', parameter_name: 'str', value: 'int', corrective_action: 'str | None' = None) -> 'None'
|
| Exception raised when an invalid max value is provided (e.g. zero or negative).
|
| Method resolution order:
| StreamlitInvalidMaxError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, widget_name: 'str', parameter_name: 'str', value: 'int', corrective_action: 'str | None' = None) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidMenuItemKeyError(LocalizableStreamlitException)
| StreamlitInvalidMenuItemKeyError(key: 'str') -> 'None'
|
| Exception raised when an invalid key is specified.
|
| Method resolution order:
| StreamlitInvalidMenuItemKeyError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, key: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidNumberFormatError(LocalizableStreamlitException)
| StreamlitInvalidNumberFormatError(format: 'str') -> 'None'
|
| Exception raised when the format string for `st.number_input` contains
| invalid characters.
|
| Method resolution order:
| StreamlitInvalidNumberFormatError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, format: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidPageLayoutError(LocalizableStreamlitException)
| StreamlitInvalidPageLayoutError(layout: 'str') -> 'None'
|
| Exception raised when an invalid value is specified for layout.
|
| Method resolution order:
| StreamlitInvalidPageLayoutError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, layout: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidSidebarStateError(LocalizableStreamlitException)
| StreamlitInvalidSidebarStateError(initial_sidebar_state: 'str') -> 'None'
|
| Exception raised when an invalid value is specified for `initial_sidebar_state`.
|
| Method resolution order:
| StreamlitInvalidSidebarStateError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, initial_sidebar_state: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidSizeError(LocalizableStreamlitException)
| StreamlitInvalidSizeError(size: 'Any') -> 'None'
|
| Exception raised when an invalid size value is provided.
|
| Method resolution order:
| StreamlitInvalidSizeError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, size: 'Any') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidTextAlignmentError(LocalizableStreamlitException)
| StreamlitInvalidTextAlignmentError(text_alignment: 'Any') -> 'None'
|
| Exception raised when an invalid text_alignment value is provided.
|
| Method resolution order:
| StreamlitInvalidTextAlignmentError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, text_alignment: 'Any') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidThemeError(LocalizableStreamlitException)
| StreamlitInvalidThemeError(message: 'str') -> 'None'
|
| Exception raised for general theme errors.
|
| Method resolution order:
| StreamlitInvalidThemeError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, message: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidThemeOptionError(LocalizableStreamlitException)
| StreamlitInvalidThemeOptionError(message: 'str') -> 'None'
|
| Exception raised when an invalid theme config option is provided.
|
| Method resolution order:
| StreamlitInvalidThemeOptionError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, message: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidThemeSectionError(LocalizableStreamlitException)
| StreamlitInvalidThemeSectionError(option_name: 'str', file_path_or_url: 'str' = 'config.toml') -> 'None'
|
| Exception raised when an invalid theme section is provided.
|
| Method resolution order:
| StreamlitInvalidThemeSectionError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, option_name: 'str', file_path_or_url: 'str' = 'config.toml') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidURLError(LocalizableStreamlitException)
| StreamlitInvalidURLError(url: 'str') -> 'None'
|
| Exception raised when an invalid URL is specified for any of the menu items except for “About”.
|
| Method resolution order:
| StreamlitInvalidURLError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, url: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidVerticalAlignmentError(LocalizableStreamlitException)
| StreamlitInvalidVerticalAlignmentError(vertical_alignment: 'str', element_type: 'str') -> 'None'
|
| Exception raised when an invalid value is specified for vertical_alignment.
|
| Method resolution order:
| StreamlitInvalidVerticalAlignmentError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, vertical_alignment: 'str', element_type: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitInvalidWidthError(LocalizableStreamlitException)
| StreamlitInvalidWidthError(width: 'Any', allow_content: 'bool' = False) -> 'None'
|
| Exception raised when an invalid width value is provided.
|
| Method resolution order:
| StreamlitInvalidWidthError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, width: 'Any', allow_content: 'bool' = False) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitJSNumberBoundsError(LocalizableStreamlitException)
| StreamlitJSNumberBoundsError(message: 'str') -> 'None'
|
| Exception raised when a number exceeds the Javascript limits.
|
| Method resolution order:
| StreamlitJSNumberBoundsError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, message: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitMaxRetriesError(Error)
| An exception raised when a file or folder cannot be accessed after multiple retries.
|
| Method resolution order:
| StreamlitMaxRetriesError
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitMissingPageLabelError(LocalizableStreamlitException)
| StreamlitMissingPageLabelError() -> 'None'
|
| Exception raised when a page_link is created without a label.
|
| Method resolution order:
| StreamlitMissingPageLabelError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitMixedNumericTypesError(LocalizableStreamlitException)
| StreamlitMixedNumericTypesError(value: "int | float | Literal['min'] | None", min_value: 'int | float | None', max_value: 'int | float | None', step: 'int | float | None') -> 'None'
|
| Exception raised mixing floats and ints in st.number_input.
|
| Method resolution order:
| StreamlitMixedNumericTypesError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, value: "int | float | Literal['min'] | None", min_value: 'int | float | None', max_value: 'int | float | None', step: 'int | float | None') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitModuleNotFoundError(StreamlitAPIWarning)
| StreamlitModuleNotFoundError(module_name: 'str', *args: 'Any') -> 'None'
|
| Print a pretty message when a Streamlit command requires a dependency
| that is not one of our core dependencies.
|
| Method resolution order:
| StreamlitModuleNotFoundError
| StreamlitAPIWarning
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Warning
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, module_name: 'str', *args: 'Any') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIWarning:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Warning:
|
| __new__(*args, **kwargs) class method of builtins.Warning
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitPageNotFoundError(LocalizableStreamlitException)
| StreamlitPageNotFoundError(page: 'str', main_script_directory: 'str', uses_pages_directory: 'bool') -> 'None'
|
| Exception raised the linked page can not be found.
|
| Method resolution order:
| StreamlitPageNotFoundError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, page: 'str', main_script_directory: 'str', uses_pages_directory: 'bool') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitQueryParamDictValueError(LocalizableStreamlitException)
| StreamlitQueryParamDictValueError(key: 'str') -> 'None'
|
| Exception raised when a query param value is a dictionary.
|
| Method resolution order:
| StreamlitQueryParamDictValueError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, key: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitSecretNotFoundError(LocalizableStreamlitException, builtins.FileNotFoundError)
| StreamlitSecretNotFoundError(message: 'str') -> 'None'
|
| Exception raised when a secret cannot be found or parsed in the secrets.toml file.
|
| Method resolution order:
| StreamlitSecretNotFoundError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.FileNotFoundError
| builtins.OSError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, message: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.OSError:
|
| __reduce__(...)
| Helper for pickle.
|
| __str__(self, /)
| Return str(self).
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.OSError:
|
| __new__(*args, **kwargs) class method of builtins.OSError
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.OSError:
|
| characters_written
|
| errno
| POSIX exception code
|
| filename
| exception filename
|
| filename2
| second exception filename
|
| strerror
| exception strerror
|
| winerror
| Win32 exception code
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __setstate__(...)
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitSelectionCountExceedsMaxError(LocalizableStreamlitException)
| StreamlitSelectionCountExceedsMaxError(current_selections_count: 'int', max_selections_count: 'int') -> 'None'
|
| Exception raised when there are more default selections specified than the max allowable selections.
|
| Method resolution order:
| StreamlitSelectionCountExceedsMaxError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, current_selections_count: 'int', max_selections_count: 'int') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitValueAboveMaxError(LocalizableStreamlitException)
| StreamlitValueAboveMaxError(value: 'int | float | date | time', max_value: 'int | float | date | time') -> 'None'
|
| Exception raised when the `max_value` is less than the `value`.
|
| Method resolution order:
| StreamlitValueAboveMaxError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, value: 'int | float | date | time', max_value: 'int | float | date | time') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitValueAssignmentNotAllowedError(LocalizableStreamlitException)
| StreamlitValueAssignmentNotAllowedError(key: 'str') -> 'None'
|
| Exception raised when trying to set values where writes are not allowed.
|
| Method resolution order:
| StreamlitValueAssignmentNotAllowedError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, key: 'str') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitValueBelowMinError(LocalizableStreamlitException)
| StreamlitValueBelowMinError(value: 'int | float | date | time', min_value: 'int | float | date | time') -> 'None'
|
| Exception raised when the `min_value` is greater than the `value`.
|
| Method resolution order:
| StreamlitValueBelowMinError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, value: 'int | float | date | time', min_value: 'int | float | date | time') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class StreamlitValueError(LocalizableStreamlitException)
| StreamlitValueError(parameter: 'str', valid_values: 'list[str]') -> 'None'
|
| Exception raised when a value is not valid for a parameter.
|
| Method resolution order:
| StreamlitValueError
| LocalizableStreamlitException
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, parameter: 'str', valid_values: 'list[str]') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from LocalizableStreamlitException:
|
| exec_kwargs
|
| ----------------------------------------------------------------------
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class UnserializableSessionStateError(StreamlitAPIException)
| Method resolution order:
| UnserializableSessionStateError
| StreamlitAPIException
| MarkdownFormattedException
| Error
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods inherited from StreamlitAPIException:
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Error:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
DATA
Literal = typing.Literal
Special typing form to define literal types (a.k.a. value types).
This form can be used to indicate to type checkers that the corresponding
variable or function parameter has a value equivalent to the provided
literal (or one of several literals)::
def validate_simple(data: Any) -> Literal[True]: # always returns True
...
MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
...
open_helper('/some/path', 'r') # Passes type check
open_helper('/other/path', 'typo') # Error in type checker
Literal[...] cannot be subclassed. At runtime, an arbitrary value
is allowed as type argument to Literal[...], but type checkers may
impose restrictions.
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\errors.py
streamlit.exception
Python Library Documentation: method exception in module streamlit.delta_generator
exception(exception: 'BaseException', width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display an exception.
When accessing the app through ``localhost``, in the lower-right corner
of the exception, Streamlit displays links to Google and ChatGPT that
are prefilled with the contents of the exception message.
Parameters
----------
exception : Exception
The exception to display.
width : "stretch" or int
The width of the exception element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Examples
--------
>>> import streamlit as st
>>>
>>> e = RuntimeError("This is an exception of type RuntimeError")
>>> st.exception(e)
.. output::
https://doc-status-exception.streamlit.app/
height: 220px
streamlit.expander
Python Library Documentation: method expander in module streamlit.delta_generator
expander(label: 'str', expanded: 'bool' = False, *, key: 'Key | None' = None, icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', on_change: "Literal['ignore', 'rerun'] | WidgetCallback" = 'ignore', args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None) -> 'ExpanderContainer' method of streamlit.delta_generator.DeltaGenerator instance
Insert a multi-element container that can be expanded/collapsed.
Inserts a container into your app that can be used to hold multiple elements
and can be expanded or collapsed by the user. When collapsed, all that is
visible is the provided label.
To add elements to the returned container, you can use the ``with`` notation
(preferred) or just call methods directly on the returned object. See
examples below.
By default, all content within the expander is computed and sent to the
frontend, even if the expander is closed. To enable lazy execution
where content only runs when the expander is open, use
``on_change="rerun"`` or pass a callable to ``on_change``. The ``.open``
property indicates whether the expander is currently open, letting you
conditionally render expensive content.
.. note::
To follow best design practices and maintain a good appearance on
all screen sizes, don't nest expanders.
Parameters
----------
label : str
A string to use as the header for the expander. The label can optionally
contain GitHub-flavored Markdown of the following types: Bold, Italics,
Strikethroughs, Inline Code, Links, and Images. Images display like
icons, with a max height equal to the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
expanded : bool
If True, initializes the expander in "expanded" state. Defaults to
False (collapsed).
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key.
When ``on_change`` is set to ``"rerun"`` or a callable, setting a
key lets you read or update the expanded state via
``st.session_state[key]``. For more details, see `Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
icon : str, None
An optional emoji or icon to display next to the expander label. If ``icon``
is ``None`` (default), no icon is displayed. If ``icon`` is a
string, the following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols \
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
width : "stretch" or int
The width of the expander container. This can be one of the following:
- ``"stretch"`` (default): The width of the container matches the
width of the parent container.
- An integer specifying the width in pixels: The container has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the container matches the width
of the parent container.
on_change : "ignore", "rerun", or callable
How the expander should respond when the user expands or
collapses it. This controls whether the expander tracks state
and triggers reruns. ``on_change`` can be one of the following:
- ``"ignore"`` (default): The expander doesn't track state. All
expander content runs regardless of whether the expander is open
or closed. The ``.open`` attribute of the expander container
returns ``None``.
- ``"rerun"``: The expander tracks state. Streamlit reruns the app
when the user expands or collapses the expander. The ``.open``
attribute of the expander container returns the current state,
which is ``True`` if the expander is open and ``False`` if it's
closed. This lets you skip expensive work when the expander is
closed.
- A callable: The expander tracks state. Streamlit executes the
callable as a callback function and reruns the app when the user
expands or collapses the expander. The ``.open`` attribute of the
expander container returns its state like when
``on_change="rerun"``. If you need to access the current state
inside your callback, fetch it through Session State.
When the expander tracks state, it can't be used inside Streamlit
cache-decorated functions.
args : list or tuple or None
An optional list or tuple of args to pass to the ``on_change``
callback.
kwargs : dict or None
An optional dict of kwargs to pass to the ``on_change``
callback.
Returns
-------
ExpanderContainer
An ``ExpanderContainer`` object with an ``.open`` property to return
the current state of the expander if the expander tracks state.
Examples
--------
**Example 1: Use context management**
You can use the ``with`` notation to insert any element into an expander
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
st.bar_chart({"data": [1, 5, 2, 6, 2, 1]})
with st.expander("See explanation"):
st.write('''
The chart above shows some numbers I picked for you.
I rolled actual dice for these, so they're *guaranteed* to
be random.
''')
st.image("https://static.streamlit.io/examples/dice.jpg")
.. output::
https://doc-expander.streamlit.app/
height: 750px
**Example 2: Call methods directly**
You can call methods directly on the returned object:
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
st.bar_chart({"data": [1, 5, 2, 6, 2, 1]})
expander = st.expander("See explanation")
expander.write('''
The chart above shows some numbers I picked for you.
I rolled actual dice for these, so they're *guaranteed* to
be random.
''')
expander.image("https://static.streamlit.io/examples/dice.jpg")
.. output::
https://doc-expander.streamlit.app/
height: 750px
**Example 3: Programmatically control the expander state**
You can use a key to programmatically control the expander state or
access the state in callbacks. You must set the ``on_change`` parameter
for the expander to track state.
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
def toggle_expander():
st.session_state.summary = not st.session_state.summary
def on_expander_change():
if st.session_state.summary:
st.toast("You opened the expander.")
else:
st.toast("You closed the expander.")
with st.expander("Open expander", on_change=on_expander_change, key="summary"):
st.write("This is the expander")
st.button("Toggle expander", on_click=toggle_expander)
.. output::
https://doc-expander-callback.streamlit.app/
height: 300px
streamlit.feedback
Python Library Documentation: method feedback in module streamlit.delta_generator
feedback(options: "Literal['thumbs', 'faces', 'stars']" = 'thumbs', *, key: 'Key | None' = None, default: 'int | None' = None, disabled: 'bool' = False, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, width: 'Width' = 'content') -> 'int | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a feedback widget.
A feedback widget is an icon-based button group available in three
styles, as described in ``options``. It is commonly used in chat and AI
apps to allow users to rate responses.
Parameters
----------
options : "thumbs", "faces", or "stars"
The feedback options displayed to the user. ``options`` can be one
of the following:
- ``"thumbs"`` (default): Streamlit displays a thumb-up and
thumb-down button group.
- ``"faces"``: Streamlit displays a row of five buttons with
facial expressions depicting increasing satisfaction from left to
right.
- ``"stars"``: Streamlit displays a row of star icons, allowing the
user to select a rating from one to five stars.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``options`` resets the widget even when a key is
provided.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
default : int or None
Default feedback value. This must be consistent with the feedback
type in ``options``:
- 0 or 1 if ``options="thumbs"``.
- Between 0 and 4, inclusive, if ``options="faces"`` or
``options="stars"``.
disabled : bool
An optional boolean that disables the feedback widget if set
to ``True``. The default is ``False``.
on_change : callable
An optional callback invoked when this feedback widget's value
changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
width : "content", "stretch", or int
The width of the feedback widget. This can be one of the following:
- ``"content"`` (default): The width of the widget matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the widget matches the width of the
parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
Returns
-------
int or None
An integer indicating the user's selection, where ``0`` is the
lowest feedback. Higher values indicate more positive feedback.
If no option was selected, the widget returns ``None``.
- For ``options="thumbs"``, a return value of ``0`` indicates
thumbs-down, and ``1`` indicates thumbs-up.
- For ``options="faces"`` and ``options="stars"``, return values
range from ``0`` (least satisfied) to ``4`` (most satisfied).
Examples
--------
Display a feedback widget with stars, and show the selected sentiment:
>>> import streamlit as st
>>>
>>> sentiment_mapping = ["one", "two", "three", "four", "five"]
>>> selected = st.feedback("stars")
>>> if selected is not None:
>>> st.markdown(f"You selected {sentiment_mapping[selected]} star(s).")
.. output::
https://doc-feedback-stars.streamlit.app/
height: 200px
Display a feedback widget with thumbs, and show the selected sentiment:
>>> import streamlit as st
>>>
>>> sentiment_mapping = [":material/thumb_down:", ":material/thumb_up:"]
>>> selected = st.feedback("thumbs")
>>> if selected is not None:
>>> st.markdown(f"You selected: {sentiment_mapping[selected]}")
.. output::
https://doc-feedback-thumbs.streamlit.app/
height: 200px
streamlit.file_uploader
Python Library Documentation: method file_uploader in module streamlit.delta_generator
file_uploader(label: 'str', type: 'str | Sequence[str] | None' = None, accept_multiple_files: 'AcceptMultipleFiles' = False, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, max_upload_size: 'int | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch') -> 'UploadedFile | list[UploadedFile] | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a file uploader widget.
By default, uploaded files are limited to 200 MB each. You can
configure this globally using the ``server.maxUploadSize`` configuration
option. For more information on how to set configuration options, see
|config.toml|_. Additionally, you can set a per-widget limit using the
``max_upload_size`` parameter.
.. |config.toml| replace:: ``config.toml``
.. _config.toml: https://docs.streamlit.io/develop/api-reference/configuration/config.toml
Parameters
----------
label : str
A short label explaining to the user what this file uploader is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
type : str, list of str, or None
The allowed file types for uploaded files. This can be one of the
following values:
- ``None`` (default): All file extensions are allowed.
- A file extension: Only one file extension is allowed. For example,
to only accept CSV files, use ``"csv"`` or ``".csv"``.
- A MIME type: Only one MIME type is allowed. For example,
to accept JPEG images, use ``"image/jpeg"``.
- A MIME wildcard: All types within a MIME media type are allowed.
For example, to accept all images, use ``"image/*"``.
- A MIME media type: This is a shortcut that is equivalent to a
MIME wildcard. If you use ``"image"``, ``"audio"``, ``"video"``, or
``"text"``, Streamlit will internally append ``/*`` to create
a MIME wildcard.
- A sequence of strings: Use a combination of the previously listed
strings to accept multiple file types.
For more information about MIME types, see
https://www.iana.org/assignments/media-types/media-types.xhtml.
.. note::
This is a best-effort check, but doesn't provide a
security guarantee against users uploading files of other types
or type extensions. The correct handling of uploaded files is
part of the app developer's responsibility.
max_upload_size : int or None
The maximum allowed size of each uploaded file in megabytes.
If this is ``None`` (default), the maximum file size is set by the
``server.maxUploadSize`` configuration option in your
``config.toml`` file. If this is an integer, it must be positive
and will override the ``server.maxUploadSize`` configuration option.
accept_multiple_files : bool or "directory"
Whether to accept more than one file in a submission. This can be one
of the following values:
- ``False`` (default): The user can only submit one file at a time.
- ``True``: The user can upload multiple files at the same time.
- ``"directory"``: The user can select a directory to upload all
files in the directory and its subdirectories. If ``type`` is
set, only files matching those type(s) will be uploaded.
When this is ``True`` or ``"directory"``, the return value will be
a list and a user can additively select files if they click the
browse button on the widget multiple times.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``type``, ``accept_multiple_files``, or
``max_upload_size`` resets the widget even when a key is
provided.
A key lets you access the widget's value via
``st.session_state[key]`` (read-only). For more details, see
`Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this file_uploader's value
changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the file uploader if set to
``True``. The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "stretch" or int
The width of the file uploader widget. This can be one of the
following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
Returns
-------
None, UploadedFile, or list of UploadedFile
- If accept_multiple_files is ``False``, returns either ``None`` or
an ``UploadedFile`` object.
- If accept_multiple_files is ``True`` or ``"directory"``, returns
a list with the uploaded files as ``UploadedFile`` objects. If no
files were uploaded, returns an empty list.
The ``UploadedFile`` class is a subclass of ``BytesIO``, and
therefore is "file-like". This means you can pass an instance of it
anywhere a file is expected.
Examples
--------
**Example 1: Accept a single file at a time**
>>> import streamlit as st
>>> import pandas as pd
>>> from io import StringIO
>>>
>>> uploaded_file = st.file_uploader("Choose a file")
>>> if uploaded_file is not None:
... # To read file as bytes:
... bytes_data = uploaded_file.getvalue()
... st.write(bytes_data)
>>>
... # To convert to a string based IO:
... stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
... st.write(stringio)
>>>
... # To read file as string:
... string_data = stringio.read()
... st.write(string_data)
>>>
... # Can be used wherever a "file-like" object is accepted:
... dataframe = pd.read_csv(uploaded_file)
... st.write(dataframe)
**Example 2: Accept multiple files at a time**
>>> import pandas as pd
>>> import streamlit as st
>>>
>>> uploaded_files = st.file_uploader(
... "Upload data", accept_multiple_files=True, type="csv"
... )
>>> for uploaded_file in uploaded_files:
... df = pd.read_csv(uploaded_file)
... st.write(df)
.. output::
https://doc-file-uploader.streamlit.app/
height: 375px
**Example 3: Accept an entire directory**
>>> import streamlit as st
>>>
>>> uploaded_files = st.file_uploader(
... "Upload images", accept_multiple_files="directory", type=["jpg", "png"]
... )
>>> for uploaded_file in uploaded_files:
... st.image(uploaded_file)
.. output::
https://doc-file-uploader-directory.streamlit.app/
height: 375px
streamlit.file_util
Python Library Documentation: module streamlit.file_util in streamlit
NAME
streamlit.file_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUNCTIONS
file_in_pythonpath(filepath: 'str') -> 'bool'
Test whether a filepath is in the same folder of a path specified in the PYTHONPATH env variable.
Parameters
----------
filepath : str
An absolute file path.
Returns
-------
boolean
True if contained in PYTHONPATH, False otherwise. False if PYTHONPATH is not defined or empty.
file_is_in_folder_glob(filepath: 'str', folderpath_glob: 'str') -> 'bool'
Test whether a file is in some folder with globbing support.
Parameters
----------
filepath : str
A file path.
folderpath_glob: str
A path to a folder that may include globbing.
get_app_static_dir(main_script_path: 'str') -> 'str'
Get the folder where app static files live.
get_directory_size(directory: 'str') -> 'int'
Return the size of a directory in bytes.
get_encoded_file_data(data: 'bytes', encoding: 'str' = 'auto') -> 'io.StringIO | io.BytesIO'
Coerce bytes to a BytesIO or a StringIO.
Parameters
----------
data : bytes
encoding : str
Returns
-------
BytesIO or StringIO
If the file's data is in a well-known textual format (or if the encoding
parameter is set), return a StringIO. Otherwise, return BytesIO.
get_main_script_directory(main_script: 'str') -> 'str'
Return the full path to the main script directory.
Parameters
----------
main_script : str
The main script path. The path can be an absolute path or a relative
path.
Returns
-------
str
The full path to the main script directory.
get_main_script_streamlit_file_path(main_script_path: 'str', filename: 'str') -> 'str'
Return the full path to a file in the .streamlit folder relative to the
main script's path.
This doesn't guarantee that the file (or its directory) exists.
get_project_streamlit_file_path(*filepath: 'str') -> 'str'
Return the full path to a filepath in ${CWD}/.streamlit.
This doesn't guarantee that the file (or its directory) exists.
get_static_dir() -> 'str'
Get the folder where static HTML/JS/CSS files live.
get_streamlit_file_path(*filepath: 'str') -> 'str'
Return the full path to a file in ~/.streamlit.
This doesn't guarantee that the file (or its directory) exists.
normalize_path_join(*args: 'str') -> 'str'
Return the normalized path of the joined path.
Parameters
----------
*args : str
The path components to join.
Returns
-------
str
The normalized path of the joined path.
streamlit_read(path: 'str', binary: 'bool' = False) -> 'Generator[IO[Any], None, None]'
Opens a context to read this file relative to the streamlit path.
For example:
with streamlit_read('foo.txt') as foo:
...
opens the file `.streamlit/foo.txt`
path - the path to write to (within the streamlit directory)
binary - set to True for binary IO
streamlit_write(path: 'str', binary: 'bool' = False) -> 'Generator[IO[Any], None, None]'
Opens a file for writing within the streamlit path, and
ensuring that the path exists.
For example:
with streamlit_write('foo/bar.txt') as bar:
...
opens the file .streamlit/foo/bar.txt for writing,
creating any necessary directories along the way.
path - the path to write to (within the streamlit directory)
binary - set to True for binary IO
DATA
APP_STATIC_FOLDER_NAME = 'static'
CONFIG_FOLDER_NAME = '.streamlit'
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
TYPE_CHECKING = False
__annotations__ = {'APP_STATIC_FOLDER_NAME': 'Final', 'CONFIG_FOLDER_N...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\file_util.py
streamlit.form
Python Library Documentation: method form in module streamlit.delta_generator
form(key: 'str', clear_on_submit: 'bool' = False, *, enter_to_submit: 'bool' = True, border: 'bool' = True, width: 'Width' = 'stretch', height: 'Height' = 'content') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Create a form that batches elements together with a "Submit" button.
A form is a container that visually groups other elements and
widgets together, and contains a Submit button. When the form's
Submit button is pressed, all widget values inside the form will be
sent to Streamlit in a batch.
To add elements to a form object, you can use ``with`` notation
(preferred) or just call methods directly on the form. See
examples below.
Forms have a few constraints:
- Every form must contain a ``st.form_submit_button``.
- ``st.button`` and ``st.download_button`` cannot be added to a form.
- Forms can appear anywhere in your app (sidebar, columns, etc),
but they cannot be embedded inside other forms.
- Within a form, the only widget that can have a callback function is
``st.form_submit_button``.
Parameters
----------
key : str
A string that identifies the form. Each form must have its own
key. (This key is not displayed to the user in the interface.)
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
clear_on_submit : bool
If True, all widgets inside the form will be reset to their default
values after the user presses the Submit button. Defaults to False.
(Note that Custom Components are unaffected by this flag, and
will not be reset to their defaults on form submission.)
enter_to_submit : bool
Whether to submit the form when a user presses Enter while
interacting with a widget inside the form.
If this is ``True`` (default), pressing Enter while interacting
with a form widget is equivalent to clicking the first
``st.form_submit_button`` in the form.
If this is ``False``, the user must click an
``st.form_submit_button`` to submit the form.
If the first ``st.form_submit_button`` in the form is disabled,
the form will override submission behavior with
``enter_to_submit=False``.
border : bool
Whether to show a border around the form. Defaults to True.
.. note::
Not showing a border can be confusing to viewers since interacting with a
widget in the form will do nothing. You should only remove the border if
there's another border (e.g. because of an expander) or the form is small
(e.g. just a text input and a submit button).
width : "stretch", "content", or int
The width of the form container. This can be one of the following:
- ``"stretch"`` (default): The width of the container matches the
width of the parent container.
- ``"content"``: The width of the container matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The container has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the container matches the width
of the parent container.
height : "content", "stretch", or int
The height of the form container. This can be one of the following:
- ``"content"`` (default): The height of the container matches the
height of its content.
- ``"stretch"``: The height of the container matches the height of
its content or the height of the parent container, whichever is
larger. If the container is not in a parent container, the height
of the container matches the height of its content.
- An integer specifying the height in pixels: The container has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
.. note::
Use scrolling containers sparingly. If you use scrolling
containers, avoid heights that exceed 500 pixels. Otherwise,
the scroll surface of the container might cover the majority of
the screen on mobile devices, which makes it hard to scroll the
rest of the app.
Examples
--------
Inserting elements using ``with`` notation:
>>> import streamlit as st
>>>
>>> with st.form("my_form"):
... st.write("Inside the form")
... slider_val = st.slider("Form slider")
... checkbox_val = st.checkbox("Form checkbox")
...
... # Every form must have a submit button.
... submitted = st.form_submit_button("Submit")
... if submitted:
... st.write("slider", slider_val, "checkbox", checkbox_val)
>>> st.write("Outside the form")
.. output::
https://doc-form1.streamlit.app/
height: 425px
Inserting elements out of order:
>>> import streamlit as st
>>>
>>> form = st.form("my_form")
>>> form.slider("Inside the form")
>>> st.slider("Outside the form")
>>>
>>> # Now add a submit button to the form:
>>> form.form_submit_button("Submit")
.. output::
https://doc-form2.streamlit.app/
height: 375px
streamlit.form_submit_button
Python Library Documentation: method form_submit_button in module streamlit.delta_generator
form_submit_button(label: 'str' = 'Submit', help: 'str | None' = None, on_click: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, key: 'Key | None' = None, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', icon: 'str | None' = None, icon_position: 'IconPosition' = 'left', disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', shortcut: 'str | None' = None) -> 'bool' method of streamlit.delta_generator.DeltaGenerator instance
Display a form submit button.
When this button is clicked, all widget values inside the form will be
sent from the user's browser to your Streamlit server in a batch.
Every form must have at least one ``st.form_submit_button``. An
``st.form_submit_button`` cannot exist outside of a form.
For more information about forms, check out our `docs
<https://docs.streamlit.io/develop/concepts/architecture/forms>`_.
Parameters
----------
label : str
A short label explaining to the user what this button is for. This
defaults to ``"Submit"``. The label can optionally contain
GitHub-flavored Markdown of the following types: Bold, Italics,
Strikethroughs, Inline Code, Links, and Images. Images display like
icons, with a max height equal to the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
help : str or None
A tooltip that gets displayed when the button is hovered over. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_click : callable
An optional callback invoked when this button is clicked.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you access the widget's value via
``st.session_state[key]`` (read-only). For more details, see
`Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
type : "primary", "secondary", or "tertiary"
An optional string that specifies the button type. This can be one
of the following:
- ``"primary"``: The button's background is the app's primary color
for additional emphasis.
- ``"secondary"`` (default): The button's background coordinates
with the app's background color for normal emphasis.
- ``"tertiary"``: The button is plain text without a border or
background for subtlety.
icon : str or None
An optional emoji or icon to display next to the button label. If ``icon``
is ``None`` (default), no icon is displayed. If ``icon`` is a
string, the following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
icon_position : "left" or "right"
The position of the icon relative to the button label. This
defaults to ``"left"``.
disabled : bool
Whether to disable the button. If this is ``False`` (default), the
user can interact with the button. If this is ``True``, the button
is grayed-out and can't be clicked.
If the first ``st.form_submit_button`` in the form is disabled,
the form will override submission behavior with
``enter_to_submit=False``.
use_container_width : bool
Whether to expand the button's width to fill its parent container.
If ``use_container_width`` is ``False`` (default), Streamlit sizes
the button to fit its contents. If ``use_container_width`` is
``True``, the width of the button matches its parent container.
In both cases, if the contents of the button are wider than the
parent container, the contents will line wrap.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``. For ``use_container_width=False``, use
``width="content"``.
width : "content", "stretch", or int
The width of the button. This can be one of the following:
- ``"content"`` (default): The width of the button matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the button matches the width of the
parent container.
- An integer specifying the width in pixels: The button has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the button matches the width
of the parent container.
shortcut : str or None
An optional keyboard shortcut that triggers the button. This can be
one of the following strings:
- A single alphanumeric key like ``"K"`` or ``"4"``.
- A function key like ``"F11"``.
- A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
- Any of the above combined with modifiers. For example, you can use
``"Ctrl+K"`` or ``"Cmd+Shift+O"``.
.. important::
The keys ``"C"`` and ``"R"`` are reserved and can't be used,
even with modifiers. Punctuation keys like ``"."`` and ``","``
aren't currently supported.
For a list of supported keys and modifiers, see the documentation
for |st.button|_.
.. |st.button| replace:: ``st.button``
.. _st.button: https://docs.streamlit.io/develop/api-reference/widgets/st.button
Returns
-------
bool
True if the button was clicked.
streamlit.fragment
Python Library Documentation: function fragment in module streamlit.runtime.fragment
fragment(func: 'F | None' = None, *, run_every: 'int | float | timedelta | str | None' = None) -> 'Callable[[F], F] | F'
Decorator to turn a function into a fragment which can rerun independently of the full app.
When a user interacts with an input widget created inside a fragment,
Streamlit only reruns the fragment instead of the full app. If
``run_every`` is set, Streamlit will also rerun the fragment at the
specified interval while the session is active, even if the user is not
interacting with your app.
To trigger an app rerun from inside a fragment, call ``st.rerun()``
directly. To trigger a fragment rerun from within itself, call
``st.rerun(scope="fragment")``. Any values from the fragment that need to
be accessed from the wider app should generally be stored in Session State.
When Streamlit element commands are called directly in a fragment, the
elements are cleared and redrawn on each fragment rerun, just like all
elements are redrawn on each app rerun. The rest of the app is persisted
during a fragment rerun. When a fragment renders elements into externally
created containers, the elements will not be cleared with each fragment
rerun. Instead, elements will accumulate in those containers with each
fragment rerun, until the next app rerun.
Calling ``st.sidebar`` in a fragment is not supported. To write elements to
the sidebar with a fragment, call your fragment function inside a
``with st.sidebar`` context manager.
Fragment code can interact with Session State, imported modules, and
other Streamlit elements created outside the fragment. Note that these
interactions are additive across multiple fragment reruns. You are
responsible for handling any side effects of that behavior.
.. warning::
- Fragments can only contain widgets in their main body. Fragments
can't render widgets to externally created containers.
Parameters
----------
func: callable
The function to turn into a fragment.
run_every: int, float, timedelta, str, or None
The time interval between automatic fragment reruns. This can be one of
the following:
- ``None`` (default).
- An ``int`` or ``float`` specifying the interval in seconds.
- A string specifying the time in a format supported by `Pandas'
Timedelta constructor <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_,
e.g. ``"1d"``, ``"1.5 days"``, or ``"1h23s"``.
- A ``timedelta`` object from `Python's built-in datetime library
<https://docs.python.org/3/library/datetime.html#timedelta-objects>`_,
e.g. ``timedelta(days=1)``.
If ``run_every`` is ``None``, the fragment will only rerun from
user-triggered events.
Examples
--------
The following example demonstrates basic usage of
``@st.fragment``. As an analogy, "inflating balloons" is a slow process that happens
outside of the fragment. "Releasing balloons" is a quick process that happens inside
of the fragment.
>>> import streamlit as st
>>> import time
>>>
>>> @st.fragment
>>> def release_the_balloons():
>>> st.button("Release the balloons", help="Fragment rerun")
>>> st.balloons()
>>>
>>> with st.spinner("Inflating balloons..."):
>>> time.sleep(5)
>>> release_the_balloons()
>>> st.button("Inflate more balloons", help="Full rerun")
.. output::
https://doc-fragment-balloons.streamlit.app/
height: 220px
This next example demonstrates how elements both inside and outside of a
fragement update with each app or fragment rerun. In this app, clicking
"Rerun full app" will increment both counters and update all values
displayed in the app. In contrast, clicking "Rerun fragment" will only
increment the counter within the fragment. In this case, the ``st.write``
command inside the fragment will update the app's frontend, but the two
``st.write`` commands outside the fragment will not update the frontend.
>>> import streamlit as st
>>>
>>> if "app_runs" not in st.session_state:
>>> st.session_state.app_runs = 0
>>> st.session_state.fragment_runs = 0
>>>
>>> @st.fragment
>>> def my_fragment():
>>> st.session_state.fragment_runs += 1
>>> st.button("Rerun fragment")
>>> st.write(f"Fragment says it ran {st.session_state.fragment_runs} times.")
>>>
>>> st.session_state.app_runs += 1
>>> my_fragment()
>>> st.button("Rerun full app")
>>> st.write(f"Full app says it ran {st.session_state.app_runs} times.")
>>> st.write(f"Full app sees that fragment ran {st.session_state.fragment_runs} times.")
.. output::
https://doc-fragment.streamlit.app/
height: 400px
You can also trigger an app rerun from inside a fragment by calling
``st.rerun``.
>>> import streamlit as st
>>>
>>> if "clicks" not in st.session_state:
>>> st.session_state.clicks = 0
>>>
>>> @st.fragment
>>> def count_to_five():
>>> if st.button("Plus one!"):
>>> st.session_state.clicks += 1
>>> if st.session_state.clicks % 5 == 0:
>>> st.rerun()
>>> return
>>>
>>> count_to_five()
>>> st.header(f"Multiples of five clicks: {st.session_state.clicks // 5}")
>>>
>>> if st.button("Check click count"):
>>> st.toast(f"## Total clicks: {st.session_state.clicks}")
.. output::
https://doc-fragment-rerun.streamlit.app/
height: 400px
streamlit.get_option
Python Library Documentation: function get_option in module streamlit.config
get_option(key: 'str') -> 'Any'
Return the current value of a given Streamlit configuration option.
Run ``streamlit config show`` in a terminal to see all available options.
Parameters
----------
key : str
The config option key of the form "section.optionName". To see all
available options, run ``streamlit config show`` in a terminal.
Examples
--------
>>> import streamlit as st
>>>
>>> color = st.get_option("theme.primaryColor")
streamlit.graphviz_chart
Python Library Documentation: method graphviz_chart in module streamlit.delta_generator
graphviz_chart(figure_or_dot: 'FigureOrDot', use_container_width: 'bool | None' = None, *, width: 'Width' = 'content', height: 'Height' = 'content') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a graph using the dagre-d3 library.
.. Important::
You must install ``graphviz>=0.19.0`` to use this command. You can
install all charting dependencies (except Bokeh) as an extra with
Streamlit:
.. code-block:: shell
pip install streamlit[charts]
Parameters
----------
figure_or_dot : graphviz.dot.Graph, graphviz.dot.Digraph, graphviz.sources.Source, str
The Graphlib graph object or dot string to display
use_container_width : bool
Whether to override the figure's native width with the width of
the parent container. If ``use_container_width`` is ``False``
(default), Streamlit sets the width of the chart to fit its contents
according to the plotting library, up to the width of the parent
container. If ``use_container_width`` is ``True``, Streamlit sets
the width of the figure to match the width of the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``. For ``use_container_width=False``, use
``width="content"``.
width : "content", "stretch", or int
The width of the chart element. This can be one of the following:
- ``"content"`` (default): The width of the element matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the element matches the width of the
parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
height : "content", "stretch", or int
The height of the chart element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
Examples
--------
>>> import streamlit as st
>>> import graphviz
>>>
>>> # Create a graphlib graph object
>>> graph = graphviz.Digraph()
>>> graph.edge("run", "intr")
>>> graph.edge("intr", "runbl")
>>> graph.edge("runbl", "run")
>>> graph.edge("run", "kernel")
>>> graph.edge("kernel", "zombie")
>>> graph.edge("kernel", "sleep")
>>> graph.edge("kernel", "runmem")
>>> graph.edge("sleep", "swap")
>>> graph.edge("swap", "runswap")
>>> graph.edge("runswap", "new")
>>> graph.edge("runswap", "runmem")
>>> graph.edge("new", "runmem")
>>> graph.edge("sleep", "runmem")
>>>
>>> st.graphviz_chart(graph)
Or you can render the chart from the graph using GraphViz's Dot
language:
>>> st.graphviz_chart('''
digraph {
run -> intr
intr -> runbl
runbl -> run
run -> kernel
kernel -> zombie
kernel -> sleep
kernel -> runmem
sleep -> swap
swap -> runswap
runswap -> new
runswap -> runmem
new -> runmem
sleep -> runmem
}
''')
.. output::
https://doc-graphviz-chart.streamlit.app/
height: 600px
streamlit.header
Python Library Documentation: method header in module streamlit.delta_generator
header(body: 'SupportsStr', anchor: 'Anchor' = None, *, help: 'str | None' = None, divider: 'Divider' = False, width: 'Width' = 'stretch', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display text in header formatting.
Parameters
----------
body : str
The text to display as GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
anchor : str or False
The anchor name of the header that can be accessed with #anchor
in the URL. If omitted, it generates an anchor using the body.
If False, the anchor is not shown in the UI.
help : str or None
A tooltip that gets displayed next to the header. If this is
``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
divider : bool, "blue", "green", "orange", "red", "violet", "yellow", "gray"/"grey", or "rainbow"
Shows a colored divider below the header. If this is ``True``,
successive headers will cycle through divider colors, except gray
and rainbow. That is, the first header will have a blue line, the
second header will have a green line, and so on. If this is a
string, the color can be set to one of the following: blue, green,
orange, red, violet, yellow, gray/grey, or rainbow.
width : "stretch", "content", or int
The width of the header element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
text_alignment : "left", "center", "right", or "justify"
The horizontal alignment of the text within the element. This can
be one of the following:
- ``"left"`` (default): Text is aligned to the left edge.
- ``"center"``: Text is centered.
- ``"right"``: Text is aligned to the right edge.
- ``"justify"``: Text is justified (stretched to fill the available
width with the last line left-aligned).
.. note::
For text alignment to have a visible effect, the element's
width must be wider than its content. If you use
``width="content"`` with short text, the alignment may not be
noticeable.
Examples
--------
>>> import streamlit as st
>>>
>>> st.header("_Streamlit_ is :blue[cool] :sunglasses:")
>>> st.header("This is a header with a divider", divider="gray")
>>> st.header("These headers have rotating dividers", divider=True)
>>> st.header("One", divider=True)
>>> st.header("Two", divider=True)
>>> st.header("Three", divider=True)
>>> st.header("Four", divider=True)
.. output::
https://doc-header.streamlit.app/
height: 600px
streamlit.help
Python Library Documentation: method help in module streamlit.delta_generator
help(obj: 'Any' = <module 'streamlit' from 'C:\\Users\\Youse\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\streamlit\\__init__.py'>, *, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display help and other information for a given object.
Depending on the type of object that is passed in, this displays the
object's name, type, value, signature, docstring, and member variables,
methods — as well as the values/docstring of members and methods.
Parameters
----------
obj : any
The object whose information should be displayed. If left
unspecified, this call will display help for Streamlit itself.
width : "stretch" or int
The width of the help element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Examples
--------
Don't remember how to initialize a dataframe? Try this:
>>> import streamlit as st
>>> import pandas
>>>
>>> st.help(pandas.DataFrame)
.. output::
https://doc-string.streamlit.app/
height: 700px
Want to quickly check what data type is output by a certain function?
Try:
>>> import streamlit as st
>>>
>>> x = my_poorly_documented_function()
>>> st.help(x)
Want to quickly inspect an object? No sweat:
>>> class Dog:
>>> '''A typical dog.'''
>>>
>>> def __init__(self, breed, color):
>>> self.breed = breed
>>> self.color = color
>>>
>>> def bark(self):
>>> return 'Woof!'
>>>
>>>
>>> fido = Dog("poodle", "white")
>>>
>>> st.help(fido)
.. output::
https://doc-string1.streamlit.app/
height: 300px
And if you're using Magic, you can get help for functions, classes,
and modules without even typing ``st.help``:
>>> import streamlit as st
>>> import pandas
>>>
>>> # Get help for Pandas read_csv:
>>> pandas.read_csv
>>>
>>> # Get help for Streamlit itself:
>>> st
.. output::
https://doc-string2.streamlit.app/
height: 700px
streamlit.html
Python Library Documentation: method html in module streamlit.delta_generator
html(body: 'str | Path | SupportsStr | SupportsReprHtml', *, width: 'Width' = 'stretch', unsafe_allow_javascript: 'bool' = False) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Insert HTML into your app.
Adding custom HTML to your app impacts safety, styling, and
maintainability. We sanitize HTML with `DOMPurify
<https://github.com/cure53/DOMPurify>`_, but inserting HTML remains a
developer risk. Passing untrusted code to ``st.html`` or dynamically
loading external code can increase the risk of vulnerabilities in your
app.
``st.html`` content is **not** iframed. By default, JavaScript is
ignored. To execute JavaScript contained in your HTML, set
``unsafe_allow_javascript=True``. Use this with caution and never pass
untrusted input.
Parameters
----------
body : any
The HTML code to insert. This can be one of the following:
- A string of HTML code.
- A path to a local file with HTML code. The path can be a ``str``
or ``Path`` object. Paths can be absolute or relative to the
working directory (where you execute ``streamlit run``).
- Any object. If ``body`` is not a string or path, Streamlit will
convert the object to a string. ``body._repr_html_()`` takes
precedence over ``str(body)`` when available.
If the resulting HTML content is empty, Streamlit will raise an
error.
If ``body`` is a path to a CSS file, Streamlit will wrap the CSS
content in ``<style>`` tags automatically. When the resulting HTML
content only contains style tags, Streamlit will send the content
to the event container instead of the main container to avoid
taking up space in the app.
width : "stretch", "content", or int
The width of the HTML element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
unsafe_allow_javascript : bool
Whether to execute JavaScript contained in your HTML. If this is
``False`` (default), JavaScript is ignored. If this is ``True``,
JavaScript is executed. Use this with caution and never pass
untrusted input.
Examples
--------
>>> import streamlit as st
>>>
>>> st.html(
... "<p><span style='text-decoration: line-through double red;'>Oops</span>!</p>"
... )
.. output::
https://doc-html.streamlit.app/
height: 300px
streamlit.iframe
Python Library Documentation: method iframe in module streamlit.delta_generator
iframe(src: 'str | Path', *, width: "int | Literal['stretch', 'content']" = 'stretch', height: "int | Literal['stretch', 'content']" = 'content', tab_index: 'int | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Embed content in an iframe.
``st.iframe`` embeds external URLs, HTML content, or local files in an
iframe. It auto-detects the input type and handles it appropriately.
Parameters
----------
src : str or Path
The content to embed. This can be one of the following:
- **Absolute URL**: A URL starting with ``http://``, ``https://``,
or ``data:``. The URL is loaded directly in the iframe.
- **Relative URL**: A path starting with ``/``, such as
``/app/static/report.html``. Useful for referencing files served
via Streamlit's `static file serving
<https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_.
- **Local file path**: A path to a local file, either as a string
or ``Path`` object. HTML files (``.html``, ``.htm``, ``.xhtml``)
are read and embedded directly. Other files (PDF, images, SVG,
etc.) are uploaded to Streamlit's media storage and rendered
using the browser's native viewer.
- **HTML string**: If ``src`` doesn't match any of the above
patterns, it's treated as raw HTML and embedded directly in the
iframe.
width : int, "stretch", or "content"
The width of the iframe. This can be one of the following:
- ``"stretch"`` (default): The iframe fills the width of its
container.
- ``"content"``: The iframe matches the width of its content.
- An ``int``: A fixed width in CSS pixels.
height : int, "stretch", or "content"
The height of the iframe. This can be one of the following:
- ``"content"`` (default): The iframe automatically sizes to match
its content height. For HTML strings and local HTML files,
Streamlit measures the content height. For external URLs and
non-HTML files, this falls back to 400px due to cross-origin
restrictions.
- ``"stretch"``: The iframe fills the available vertical space.
Works best inside containers with defined heights.
- An ``int``: A fixed height in CSS pixels.
tab_index : int or None
Controls keyboard navigation focus. This can be one of the
following:
- ``None`` (default): Browser default behavior.
- ``-1``: Removes from tab order but allows programmatic focus.
- ``0``: Adds to tab order in document position.
- Positive ``int``: Adds to tab order at specified priority.
For more information, see the `tabindex
<https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex>`_
documentation on MDN.
Examples
--------
Embed an external website:
>>> import streamlit as st
>>> st.iframe("https://docs.streamlit.io", height=600)
Embed HTML content directly:
>>> import streamlit as st
>>> st.iframe(
... '''
... <style>body { font-family: sans-serif; padding: 1rem; }</style>
... <p>This is <strong>embedded HTML</strong>.</p>
... ''',
... height=100,
... )
Embed a local HTML file:
>>> import streamlit as st
>>> from pathlib import Path
>>> st.iframe(Path("reports/dashboard.html"), height=800)
streamlit.image
Python Library Documentation: method image in module streamlit.delta_generator
image(image: 'ImageOrImageList', caption: 'str | list[str] | None' = None, width: 'Width' = 'content', use_column_width: 'UseColumnWith' = None, clamp: 'bool' = False, channels: 'Channels' = 'RGB', output_format: 'ImageFormatOrAuto' = 'auto', *, use_container_width: 'bool | None' = None, link: 'str | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display an image or list of images.
Parameters
----------
image : numpy.ndarray, BytesIO, str, Path, or list of these
The image to display. This can be one of the following:
- A URL (string) for a hosted image. Also supports
``/app/static/<asset>`` URLs for files served via
`static file serving <https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_.
- A path to a local image file. The path can be a ``str``
or ``Path`` object. Paths can be absolute or relative to the
working directory (where you execute ``streamlit run``).
- An SVG string like ``<svg xmlns=...</svg>``.
- A byte array defining an image. This includes monochrome images of
shape (w,h) or (w,h,1), color images of shape (w,h,3), or RGBA
images of shape (w,h,4), where w and h are the image width and
height, respectively.
- A list of any of the above. Streamlit displays the list as a
row of images that overflow to additional rows as needed.
caption : str or list of str
Image caption(s). If this is ``None`` (default), no caption is
displayed. If ``image`` is a list of multiple images, ``caption``
must be a list of captions (one caption for each image) or
``None``.
Captions can optionally contain GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
width : "content", "stretch", or int
The width of the image element. This can be one of the following:
- ``"content"`` (default): The width of the element matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the element matches the width of the
parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
When using an SVG image without a default width, use ``"stretch"``
or an integer.
use_column_width : "auto", "always", "never", or bool
If "auto", set the image's width to its natural size,
but do not exceed the width of the column.
If "always" or True, set the image's width to the column width.
If "never" or False, set the image's width to its natural size.
Note: if set, `use_column_width` takes precedence over the `width` parameter.
.. deprecated::
``use_column_width`` is deprecated and will be removed in a future
release. Please use the ``width`` parameter instead.
clamp : bool
Whether to clamp image pixel values to a valid range (0-255 per
channel). This is only used for byte array images; the parameter is
ignored for image URLs and files. If this is ``False`` (default)
and an image has an out-of-range value, a ``RuntimeError`` will be
raised.
channels : "RGB" or "BGR"
The color format when ``image`` is an ``nd.array``. This is ignored
for other image types. If this is ``"RGB"`` (default),
``image[:, :, 0]`` is the red channel, ``image[:, :, 1]`` is the
green channel, and ``image[:, :, 2]`` is the blue channel. For
images coming from libraries like OpenCV, you should set this to
``"BGR"`` instead.
output_format : "JPEG", "PNG", or "auto"
The output format to use when transferring the image data. If this
is ``"auto"`` (default), Streamlit identifies the compression type
based on the type and format of the image. Photos should use the
``"JPEG"`` format for lossy compression while diagrams should use
the ``"PNG"`` format for lossless compression.
use_container_width : bool
Whether to override ``width`` with the width of the parent
container. If ``use_container_width`` is ``False`` (default),
Streamlit sets the image's width according to ``width``. If
``use_container_width`` is ``True``, Streamlit sets the width of
the image to match the width of the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``. For ``use_container_width=False``, use
``width="content"``.
link : str or None
The URL to open when a user clicks on the image. This can be an
external URL like ``"https://streamlit.io"`` or a relative path
like ``"/my_page"``. If ``link`` is ``None`` (default), the
image will not include a hyperlink.
This parameter is only supported when displaying a single image.
Examples
--------
>>> import streamlit as st
>>> st.image("sunrise.jpg", caption="Sunrise by the mountains")
.. output::
https://doc-image.streamlit.app/
height: 710px
streamlit.info
Python Library Documentation: method info in module streamlit.delta_generator
info(body: 'SupportsStr', *, icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', title: 'SupportsStr | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display an informational message.
Parameters
----------
body : str
The text to display as GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
If ``icon`` is ``None``, and ``body`` begins with an emoji or
Material icon shortcode, Streamlit will extract it and display it
slightly enlarged, as if it were passed to ``icon``. If ``body``
contains multiple icons, or you want to override this behavior,
you can insert a null Markdown directive like ``:red[]`` before
your leading icon.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
icon : str or None
An optional emoji or icon to display next to the alert. If ``icon``
is ``None`` (default), Streamlit attempts to extract a leading
emoji or Material icon shortcode from ``body``. If found, the icon
is displayed and removed from the body text. If no leading icon is
found, no icon is displayed. If ``icon`` is a string, it takes
precedence over any icon in the body, and the following options
are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
width : "stretch" or int
The width of the info element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
title : str or None
An optional title to display above the body text. If ``None``
(default), no title is displayed. The title is rendered with bold
styling and can optionally contain GitHub-flavored Markdown of the
following types: Italics, Strikethroughs, Inline Code, Links, and
Images. Images display like icons, with a max height equal to the
font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Display elements are not supported.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
Examples
--------
>>> import streamlit as st
>>>
>>> st.info('This is a purely informational message', icon="ℹ️")
streamlit.json
Python Library Documentation: method json in module streamlit.delta_generator
json(body: 'object', *, expanded: 'bool | int' = True, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display an object or string as a pretty-printed, interactive JSON string.
Parameters
----------
body : object or str
The object to print as JSON. All referenced objects should be
serializable to JSON as well. If object is a string, we assume it
contains serialized JSON.
expanded : bool or int
The initial expansion state of the JSON element. This can be one
of the following:
- ``True`` (default): The element is fully expanded.
- ``False``: The element is fully collapsed.
- An integer: The element is expanded to the depth specified. The
integer must be non-negative. ``expanded=0`` is equivalent to
``expanded=False``.
Regardless of the initial expansion state, users can collapse or
expand any key-value pair to show or hide any part of the object.
width : "stretch" or int
The width of the JSON element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Examples
--------
>>> import streamlit as st
>>>
>>> st.json(
... {
... "foo": "bar",
... "stuff": [
... "stuff 1",
... "stuff 2",
... "stuff 3",
... ],
... "level1": {"level2": {"level3": {"a": "b"}}},
... },
... expanded=2,
... )
.. output::
https://doc-json.streamlit.app/
height: 385px
streamlit.latex
Python Library Documentation: method latex in module streamlit.delta_generator
latex(body: 'SupportsStr | sympy.Expr', *, help: 'str | None' = None, width: 'Width' = 'stretch') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display mathematical expressions formatted as LaTeX.
Supported LaTeX functions are listed at
https://katex.org/docs/supported.html.
Parameters
----------
body : str or SymPy expression
The string or SymPy expression to display as LaTeX. If str, it's
a good idea to use raw Python strings since LaTeX uses backslashes
a lot.
help : str or None
A tooltip that gets displayed next to the LaTeX expression. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
width : "stretch", "content", or int
The width of the LaTeX element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Examples
--------
>>> import streamlit as st
>>>
>>> st.latex(r'''
... a + ar + a r^2 + a r^3 + \cdots + a r^{n-1} =
... \sum_{k=0}^{n-1} ar^k =
... a \left(\frac{1-r^{n}}{1-r}\right)
... ''')
streamlit.line_chart
Python Library Documentation: method line_chart in module streamlit.delta_generator
line_chart(data: 'Data' = None, *, x: 'str | None' = None, y: 'str | Sequence[str] | None' = None, x_label: 'str | None' = None, y_label: 'str | None' = None, color: 'str | Color | list[Color] | None' = None, width: 'Width' = 'stretch', height: 'Height' = 'content', use_container_width: 'bool | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a line chart.
This is syntax-sugar around ``st.altair_chart``. The main difference
is this command uses the data's own column and indices to figure out
the chart's Altair spec. As a result this is easier to use for many
"just plot this" scenarios, while being less customizable.
Parameters
----------
data : Anything supported by st.dataframe
Data to be plotted.
x : str or None
Column name or key associated to the x-axis data. If ``x`` is
``None`` (default), Streamlit uses the data index for the x-axis
values.
y : str, Sequence of str, or None
Column name(s) or key(s) associated to the y-axis data. If this is
``None`` (default), Streamlit draws the data of all remaining
columns as data series. If this is a ``Sequence`` of strings,
Streamlit draws several series on the same chart by melting your
wide-format table into a long-format table behind the scenes.
x_label : str or None
The label for the x-axis. If this is ``None`` (default), Streamlit
will use the column name specified in ``x`` if available, or else
no label will be displayed.
y_label : str or None
The label for the y-axis. If this is ``None`` (default), Streamlit
will use the column name(s) specified in ``y`` if available, or
else no label will be displayed.
color : str, tuple, Sequence of str, Sequence of tuple, or None
The color to use for different lines in this chart.
For a line chart with just one line, this can be:
- None, to use the default color.
- A hex string like "#ffaa00" or "#ffaa0088".
- An RGB or RGBA tuple with the red, green, blue, and alpha
components specified as ints from 0 to 255 or floats from 0.0 to
1.0.
- A built-in color name: "red", "orange", "yellow", "green",
"blue", "violet", "gray"/"grey", or "primary". These map to
theme colors that you can customize using ``theme.<color>Color``
configuration options.
For a line chart with multiple lines, where the dataframe is in
long format (that is, y is None or just one column), this can be:
- None, to use the default colors.
- The name of a column in the dataset. Data points will be grouped
into lines of the same color based on the value of this column.
In addition, if the values in this column match one of the color
formats above (hex string or color tuple), then that color will
be used.
For example: if the dataset has 1000 rows, but this column only
contains the values "adult", "child", and "baby", then those 1000
datapoints will be grouped into three lines whose colors will be
automatically selected from the default palette.
But, if for the same 1000-row dataset, this column contained
the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
datapoints would still be grouped into three lines, but their
colors would be "#ffaa00", "#f0f", "#0000ff" this time around.
For a line chart with multiple lines, where the dataframe is in
wide format (that is, y is a Sequence of columns), this can be:
- None, to use the default colors.
- A list of string colors or color tuples to be used for each of
the lines in the chart. This list should have the same length
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
for three lines). You can also use built-in color names in the
list (e.g. ``color=["red", "blue", "green"]``).
You can set the default colors in the ``theme.chartCategoryColors``
configuration option.
width : "stretch", "content", or int
The width of the chart element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
height : "content", "stretch", or int
The height of the chart element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
use_container_width : bool or None
Whether to override the chart's native width with the width of
the parent container. This can be one of the following:
- ``None`` (default): Streamlit will use the chart's default behavior.
- ``True``: Streamlit sets the width of the chart to match the
width of the parent container.
- ``False``: Streamlit sets the width of the chart to fit its
contents according to the plotting library, up to the width of
the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
Examples
--------
**Example 1: Basic line chart from a dataframe**
If you don't use any of the optional parameters, Streamlit plots each
column as a separate line, uses the index as the x values, and labels
each series with the column name:
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
>>>
>>> st.line_chart(df)
.. output::
https://doc-line-chart.streamlit.app/
height: 440px
**Example 2: Line chart from specific dataframe columns**
You can choose different columns to use for the x and y values. If your
dataframe is in long format (all y-values in one column), you can set
the line colors from another column.
If the column contains color strings, the colors will be applied
directly and the series will be unlabeled. If the column contains other
values, those values will label each line, and the line colors will be
selected from the default color palette. You can configure this color
palette in the ``theme.chartCategoryColors`` configuration option.
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... {
... "col1": list(range(20)) * 3,
... "col2": rng(0).standard_normal(60),
... "col3": ["a"] * 20 + ["b"] * 20 + ["c"] * 20,
... }
... )
>>>
>>> st.line_chart(df, x="col1", y="col2", color="col3")
.. output::
https://doc-line-chart1.streamlit.app/
height: 440px
**Example 3: Line chart from wide-format dataframe**
If your dataframe is in wide format (y-values are in multiple columns),
you can pass a list of columns to the ``y`` parameter. Each column
name becomes a series label. To override the default colors, pass a
list of colors to the ``color`` parameter, one for each series:
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
>>>
>>> st.line_chart(
... df,
... x="a",
... y=["b", "c"],
... color=["#FF0000", "#0000FF"],
... )
.. output::
https://doc-line-chart2.streamlit.app/
height: 440px
streamlit.link_button
Python Library Documentation: method link_button in module streamlit.delta_generator
link_button(label: 'str', url: 'str', *, key: 'Key | None' = None, on_click: "WidgetCallback | Literal['rerun', 'ignore']" = 'ignore', args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, help: 'str | None' = None, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', icon: 'str | None' = None, icon_position: 'IconPosition' = 'left', disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', shortcut: 'str | None' = None) -> 'bool | DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a link button element.
When clicked, a new tab will be opened to the specified URL. This will
create a new session for the user if directed within the app.
Parameters
----------
label : str
A short label explaining to the user what this button is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
url : str
The URL to open on user click.
key : str, int, or None
An optional string to use for giving this element a stable
identity. If this is ``None`` (default), the element's identity
will be determined based on the values of the other parameters.
If ``on_click`` enables widget behavior and ``key`` is provided,
Streamlit will register the key in Session State to store the button state.
The button state is read-only. For more details, see `Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
on_click : callable, "rerun", or "ignore"
How the button should respond to user interaction. This controls
whether or not the button behaves like an input widget. This can
be one of the following values:
- ``"ignore"`` (default): Streamlit opens the link in a new tab
and doesn't rerun the app. The button won't behave like an
input widget.
- ``"rerun"``: Streamlit opens the link in a new tab and reruns
the app. In this case, ``st.link_button`` returns a Boolean value
like ``st.button``.
- A ``callable``: Streamlit opens the link in a new tab, reruns
the app, and executes the callable at the beginning of the rerun.
In this case, ``st.link_button`` returns a Boolean value.
args : list or tuple
An optional list or tuple of args to pass to the callback when
``on_click`` is a callable. If ``on_click`` isn't a callable,
this is ignored.
kwargs : dict
An optional dict of kwargs to pass to the callback when
``on_click`` is a callable. If ``on_click`` isn't a callable,
this is ignored.
help : str or None
A tooltip that gets displayed when the button is hovered over. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
type : "primary", "secondary", or "tertiary"
An optional string that specifies the button type. This can be one
of the following:
- ``"primary"``: The button's background is the app's primary color
for additional emphasis.
- ``"secondary"`` (default): The button's background coordinates
with the app's background color for normal emphasis.
- ``"tertiary"``: The button is plain text without a border or
background for subtlety.
icon : str or None
An optional emoji or icon to display next to the button label. If ``icon``
is ``None`` (default), no icon is displayed. If ``icon`` is a
string, the following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols \
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
icon_position : "left" or "right"
The position of the icon relative to the button label. This
defaults to ``"left"``.
disabled : bool
An optional boolean that disables the link button if set to
``True``. The default is ``False``.
use_container_width : bool
Whether to expand the button's width to fill its parent container.
If ``use_container_width`` is ``False`` (default), Streamlit sizes
the button to fit its contents. If ``use_container_width`` is
``True``, the width of the button matches its parent container.
In both cases, if the contents of the button are wider than the
parent container, the contents will line wrap.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``. For ``use_container_width=False``, use
``width="content"``.
width : "content", "stretch", or int
The width of the link button. This can be one of the following:
- ``"content"`` (default): The width of the button matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the button matches the width of the
parent container.
- An integer specifying the width in pixels: The button has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the button matches the width
of the parent container.
shortcut : str or None
An optional keyboard shortcut that triggers the button. This can be
one of the following strings:
- A single alphanumeric key like ``"K"`` or ``"4"``.
- A function key like ``"F11"``.
- A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
- Any of the above combined with modifiers. For example, you can use
``"Ctrl+K"`` or ``"Cmd+Shift+O"``.
.. important::
The keys ``"C"`` and ``"R"`` are reserved and can't be used,
even with modifiers. Punctuation keys like ``"."`` and ``","``
aren't currently supported.
For a list of supported keys and modifiers, see the documentation
for |st.button|_.
.. |st.button| replace:: ``st.button``
.. _st.button: https://docs.streamlit.io/develop/api-reference/widgets/st.button
Returns
-------
element or bool
If ``on_click`` is ``"ignore"`` (default), this command returns an internal
placeholder for the button element. Otherwise, this command returns a Boolean
value in the same manner as ``st.button``: ``True`` if the button was clicked
on the last rerun and ``False`` if it wasn't.
Examples
--------
>>> import streamlit as st
>>>
>>> st.link_button("Go to gallery", "https://streamlit.io/gallery")
.. output::
https://doc-link-button.streamlit.app/
height: 200px
streamlit.logger
Python Library Documentation: module streamlit.logger in streamlit
NAME
streamlit.logger - Logging module.
FUNCTIONS
get_logger(name: 'str') -> 'logging.Logger'
Return a logger.
Parameters
----------
name : str
The name of the logger to use. You should just pass in __name__.
Returns
-------
Logger
init_uvicorn_logs() -> 'None'
Set Uvicorn and related server log levels.
This function sets up loggers for Uvicorn, websockets, and related components
so they respect Streamlit's logger.level config option.
It does not import any server code, so it's safe to call even when the server
is not running.
set_log_level(level: 'str | int') -> 'None'
Set log level.
setup_formatter(logger: 'logging.Logger') -> 'None'
Set up the console formatter for a given logger.
update_formatter() -> 'None'
DATA
DEFAULT_LOG_MESSAGE = '%(asctime)s %(levelname) -7s %(name)s: %(messag...
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
__annotations__ = {'DEFAULT_LOG_MESSAGE': 'Final', '_loggers': 'dict[s...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\logger.py
streamlit.login
Python Library Documentation: function login in module streamlit.user_info
login(provider: 'str | None' = None) -> 'None'
Initiate the login flow for the given provider.
This command redirects the user to an OpenID Connect (OIDC) provider. After
the user authenticates their identity, they are redirected back to the
home page of your app. Streamlit stores a cookie with the user's identity
information in the user's browser . You can access the identity information
through |st.user|_. Call ``st.logout()`` to remove the cookie
and start a new session.
You can use any OIDC provider, including Google, Microsoft, Okta, and more.
You must configure the provider through secrets management. Although OIDC
is an extension of OAuth 2.0, you can't use generic OAuth providers.
Streamlit parses the user's identity token and surfaces its attributes in
``st.user``. If the provider returns an access token, that
token is ignored unless you explicitly expose it.
For all providers, there are three shared settings, ``redirect_uri``,
``cookie_secret``, and ``expose_tokens``, which you must specify in an
``[auth]`` dictionary in ``secrets.toml``. Other settings must be defined
as described in the ``provider`` parameter.
- ``redirect_uri`` is your app's absolute URL with the pathname
``oauth2callback``. For local development using the default port, this is
``http://localhost:8501/oauth2callback``.
- ``cookie_secret`` should be a strong, randomly generated secret.
- ``expose_tokens`` is a list of token types to expose. The supported token
types are ``"id"`` and ``"access"``. This is an optional setting, and no
tokens are exposed by default. For information and examples about exposing
tokens, see |st.user|_.
In addition to the shared settings, the following settings are required:
- ``client_id``
- ``client_secret``
- ``server_metadata_url``
For a complete list of OIDC parameters, see `OpenID Connect Core
<https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest>`_ and
your provider's documentation. By default, Streamlit sets
``scope="openid profile email"`` and ``prompt="select_account"``. You can
change these and other OIDC parameters by passing a dictionary of settings
to ``client_kwargs``. ``state`` and ``nonce``, which are used for
security, are handled automatically and don't need to be specified. For
more information, see Example 4.
.. Important::
- You must install ``Authlib>=1.3.2`` to use this command. You can
install it as an extra with Streamlit:
.. code-block:: shell
pip install streamlit[auth]
- Your authentication configuration is dependent on your host location.
When you deploy your app, remember to update your ``redirect_uri``
within your app and your provider.
- All URLs declared in the settings must be absolute (i.e., begin with
``http://`` or ``https://``).
- Streamlit automatically enables CORS and XSRF protection when you
configure authentication in ``secrets.toml``. This takes precedence
over configuration options in ``config.toml``.
- If a user is logged into your app and opens a new tab in the same
browser, they will automatically be logged in to the new session with
the same account.
- If a user closes your app without logging out, the identity cookie
will expire after 30 days.
- For security reasons, authentication is not supported for embedded
apps.
.. |st.user| replace:: ``st.user``
.. _st.user: https://docs.streamlit.io/develop/api-reference/user/st.user
Parameters
----------
provider: str or None
The name of your provider configuration to use for login.
If ``provider`` is ``None`` (default), Streamlit will use all settings
in the ``[auth]`` dictionary within your app's ``secrets.toml`` file.
Otherwise, use an ``[auth.{provider}]`` dictionary for the named
provider, as shown in the examples that follow. When you pass a string
to ``provider``, Streamlit will use ``redirect_uri`` and
``cookie_secret``, while ignoring any other values in the ``[auth]``
dictionary.
Due to internal implementation details, Streamlit does not support
using an underscore within ``provider`` at this time.
Examples
--------
**Example 1: Use an unnamed default identity provider**
If you do not specify a name for your provider, specify all settings within
the ``[auth]`` dictionary of your ``secrets.toml`` file. The following
example configures Google as the default provider. For information about
using OIDC with Google, see `Google Identity
<https://developers.google.com/identity/openid-connect/openid-connect>`_.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[auth]
redirect_uri = "http://localhost:8501/oauth2callback"
cookie_secret = "xxx"
client_id = "xxx"
client_secret = "xxx"
server_metadata_url = "https://accounts.google.com/.well-known/openid-configuration" # fmt: skip
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
if not st.user.is_logged_in:
if st.button("Log in"):
st.login()
else:
if st.button("Log out"):
st.logout()
st.write(f"Hello, {st.user.name}!")
**Example 2: Use a named identity provider**
If you specify a name for your provider, save the shared settings in the
``[auth]`` dictionary of your ``secrets.toml`` file, and save the other
settings in an ``[auth.{provider}]`` dictionary, where ``{provider}`` is
the name of your provider. The following example configures Microsoft as
the provider. The example uses ``provider="microsoft"``, but you can use
any name. This name is internal to Streamlit and is used to match the login
command to its configuration. For information about using OIDC with
Microsoft, see `Microsoft Entra ID
<https://learn.microsoft.com/en-us/power-pages/security/authentication/openid-settings>`_.
To configure your ``{tenant}`` value in ``server_metadata_url``, see
`Microsoft identity platform
<https://learn.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc#find-your-apps-openid-configuration-document-uri>`_.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[auth]
redirect_uri = "http://localhost:8501/oauth2callback"
cookie_secret = "xxx"
[auth.microsoft]
client_id = "xxx"
client_secret = "xxx"
server_metadata_url = "https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration"
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
if not st.user.is_logged_in:
st.login("microsoft")
else:
st.write(f"Hello, {st.user.name}!")
**Example 3: Use multiple, named providers**
If you want to give your users a choice of authentication methods,
configure multiple providers and give them each a unique name. The
following example lets users choose between Okta and Microsoft to log in.
Always check with your identity provider to understand the structure of
their identity tokens because the returned fields may differ. Remember to
set ``{tenant}`` and ``{subdomain}`` in ``server_metadata_url`` for
Microsoft and Okta, respectively.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[auth]
redirect_uri = "http://localhost:8501/oauth2callback"
cookie_secret = "xxx"
[auth.microsoft]
client_id = "xxx"
client_secret = "xxx"
server_metadata_url = "https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration"
[auth.okta]
client_id = "xxx"
client_secret = "xxx"
server_metadata_url = "https://{subdomain}.okta.com/.well-known/openid-configuration"
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
if not st.user.is_logged_in:
st.header("Log in:")
if st.button("Microsoft"):
st.login("microsoft")
if st.button("Okta"):
st.login("okta")
else:
if st.button("Log out"):
st.logout()
st.write(f"Hello, {st.user.name}!")
**Example 4: Change the default connection settings**
``prompt="select_account"`` may be treated differently by some
providers when a user is already logged into their account. If a user is
logged into their Google or Microsoft account from a previous session, the
provider will prompt them to select the account they want to use, even if
it's the only one. However, if the user is logged into their Okta or Auth0
account from a previous session, the account will automatically be
selected. ``st.logout()`` does not clear a user's related cookies. To force
users to log in every time, use ``prompt="login"`` as described in Auth0's
`Customize Signup and Login Prompts
<https://auth0.com/docs/customize/login-pages/universal-login/customize-signup-and-login-prompts>`_.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[auth]
redirect_uri = "http://localhost:8501/oauth2callback"
cookie_secret = "xxx"
[auth.auth0]
client_id = "xxx"
client_secret = "xxx"
server_metadata_url = "https://{account}.{region}.auth0.com/.well-known/openid-configuration"
client_kwargs = { "prompt" = "login" }
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
if st.button("Log in"):
st.login("auth0")
if st.user.is_logged_in:
if st.button("Log out"):
st.logout()
st.write(f"Hello, {st.user.name}!)
streamlit.logo
Python Library Documentation: function logo in module streamlit.commands.logo
logo(image: 'AtomicImage | str', *, size: "Literal['small', 'medium', 'large']" = 'medium', link: 'str | None' = None, icon_image: 'AtomicImage | str | None' = None) -> 'None'
Renders a logo in the upper-left corner of your app and its sidebar.
If ``st.logo`` is called multiple times within a page, Streamlit will
render the image passed in the last call. For the most consistent results,
call ``st.logo`` early in your page script and choose an image that works
well in both light and dark mode. Avoid empty margins around your image.
If your logo does not work well for both light and dark mode, consider
setting the theme and hiding the settings menu from users with the
`configuration option <https://docs.streamlit.io/develop/api-reference/configuration/config.toml>`_
``client.toolbarMode="minimal"``.
If a user clicks the logo, they are redirected to your app's home page.
Parameters
----------
image : Anything supported by st.image (except list) or str
The image to display in the upper-left corner of your app and its
sidebar. If ``icon_image`` is also provided, then Streamlit will only
display ``image`` in the sidebar.
``image`` can be any of the types supported by |st.image|_ except
a list. Additionally, the following strings are valid:
- A single-character emoji. For example, you can set ``image="🏠"``
or ``image="🚀"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``image=":material/home:"`` will display the
Home icon. Find additional icons in the `Material Symbols \
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
Streamlit scales the image to a max height set by ``size`` and a max
width to fit within the sidebar.
.. |st.image| replace:: ``st.image``
.. _st.image: https://docs.streamlit.io/develop/api-reference/media/st.image
size : "small", "medium", or "large"
The size of the image displayed in the upper-left corner of the app and its
sidebar. The possible values are as follows:
- ``"small"``: 20px max height
- ``"medium"`` (default): 24px max height
- ``"large"``: 32px max height
link : str or None
The external URL to open when a user clicks on the logo. The URL must
start with "\http://" or "\https://". If ``link`` is ``None`` (default),
the logo will not include a hyperlink.
icon_image : Anything supported by st.image (except list), str, or None
An optional, typically smaller image to replace ``image`` in the
upper-left corner when the sidebar is closed. This can be any of the
types allowed for the ``image`` parameter. If ``icon_image`` is
``None`` (default), Streamlit will always display ``image`` in the
upper-left corner, regardless of whether the sidebar is open or closed.
Otherwise, Streamlit will render ``icon_image`` in the upper-left
corner of the app when the sidebar is closed.
Streamlit scales the image to a max height set by ``size`` and a max
width to fit within the sidebar. If the sidebar is closed, the max
width is retained from when it was last open.
For best results, pass a wide or horizontal image to ``image`` and a
square image to ``icon_image``. Or, pass a square image to ``image``
and leave ``icon_image=None``.
Examples
--------
A common design practice is to use a wider logo in the sidebar, and a
smaller, icon-styled logo in your app's main body.
>>> import streamlit as st
>>>
>>> st.logo(
... LOGO_URL_LARGE,
... link="https://streamlit.io/gallery",
... icon_image=LOGO_URL_SMALL,
... )
Try switching logos around in the following example:
>>> import streamlit as st
>>>
>>> HORIZONTAL_RED = "images/horizontal_red.png"
>>> ICON_RED = "images/icon_red.png"
>>> HORIZONTAL_BLUE = "images/horizontal_blue.png"
>>> ICON_BLUE = "images/icon_blue.png"
>>>
>>> options = [HORIZONTAL_RED, ICON_RED, HORIZONTAL_BLUE, ICON_BLUE]
>>> sidebar_logo = st.selectbox("Sidebar logo", options, 0)
>>> main_body_logo = st.selectbox("Main body logo", options, 1)
>>>
>>> st.logo(sidebar_logo, icon_image=main_body_logo)
>>> st.sidebar.markdown("Hi!")
.. output::
https://doc-logo.streamlit.app/
height: 300px
streamlit.logout
Python Library Documentation: function logout in module streamlit.user_info
logout() -> 'None'
Logout the current user.
This command removes the user's information from ``st.user``,
deletes their identity cookie, and redirects them to perform a proper
logout from the OAuth provider (if available) before returning to your
app's home page. This creates a new session.
If the user has multiple sessions open in the same browser,
``st.user`` will not be cleared in any other session.
``st.user`` only reads from the identity cookie at the start
of a session. After a session is running, you must call ``st.login()`` or
``st.logout()`` within that session to update ``st.user``.
.. Note::
If the OAuth provider supports OIDC end_session_endpoint in their
server metadata, the user will be logged out from the identity provider
as well. If not available, only local logout is performed.
Example
-------
``.streamlit/secrets.toml``:
>>> [auth]
>>> redirect_uri = "http://localhost:8501/oauth2callback"
>>> cookie_secret = "xxx"
>>> client_id = "xxx"
>>> client_secret = "xxx"
>>> server_metadata_url = "https://accounts.google.com/.well-known/openid-configuration" # fmt: skip
Your app code:
>>> import streamlit as st
>>>
>>> if not st.user.is_logged_in:
>>> if st.button("Log in"):
>>> st.login()
>>> else:
>>> if st.button("Log out"):
>>> st.logout()
>>> st.write(f"Hello, {st.user.name}!")
streamlit.map
Python Library Documentation: method map in module streamlit.delta_generator
map(data: 'Data' = None, *, latitude: 'str | None' = None, longitude: 'str | None' = None, color: 'str | Color | None' = None, size: 'str | float | None' = None, zoom: 'int | None' = None, width: 'WidthWithoutContent' = 'stretch', height: 'HeightWithoutContent' = 500, use_container_width: 'bool | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a map with a scatterplot overlaid onto it.
This is a wrapper around ``st.pydeck_chart`` to quickly create
scatterplot charts on top of a map, with auto-centering and auto-zoom.
When using this command, a service called Carto_ provides the map tiles to render
map content. If you're using advanced PyDeck features you may need to obtain
an API key from Carto first. You can do that as
``pydeck.Deck(api_keys={"carto": YOUR_KEY})`` or by setting the CARTO_API_KEY
environment variable. See `PyDeck's documentation`_ for more information.
Another common provider for map tiles is Mapbox_. If you prefer to use that,
you'll need to create an account at https://mapbox.com and specify your Mapbox
key when creating the ``pydeck.Deck`` object. You can do that as
``pydeck.Deck(api_keys={"mapbox": YOUR_KEY})`` or by setting the MAPBOX_API_KEY
environment variable.
.. _Carto: https://carto.com
.. _Mapbox: https://mapbox.com
.. _PyDeck's documentation: https://deckgl.readthedocs.io/en/latest/deck.html
Carto and Mapbox are third-party products and Streamlit accepts no responsibility
or liability of any kind for Carto or Mapbox, or for any content or information
made available by Carto or Mapbox. The use of Carto or Mapbox is governed by
their respective Terms of Use.
Parameters
----------
data : Anything supported by st.dataframe
The data to be plotted.
latitude : str or None
The name of the column containing the latitude coordinates of
the datapoints in the chart.
If None, the latitude data will come from any column named 'lat',
'latitude', 'LAT', or 'LATITUDE'.
longitude : str or None
The name of the column containing the longitude coordinates of
the datapoints in the chart.
If None, the longitude data will come from any column named 'lon',
'longitude', 'LON', or 'LONGITUDE'.
color : str or tuple or None
The color of the circles representing each datapoint.
Can be:
- None, to use the default color.
- A hex string like "#ffaa00" or "#ffaa0088".
- An RGB or RGBA tuple with the red, green, blue, and alpha
components specified as ints from 0 to 255 or floats from 0.0 to
1.0.
- The name of the column to use for the color. Cells in this column
should contain colors represented as a hex string or color tuple,
as described above.
size : str or float or None
The size of the circles representing each point, in meters.
This can be:
- None, to use the default size.
- A number like 100, to specify a single size to use for all
datapoints.
- The name of the column to use for the size. This allows each
datapoint to be represented by a circle of a different size.
zoom : int
Zoom level as specified in
https://wiki.openstreetmap.org/wiki/Zoom_levels.
width : "stretch" or int
The width of the chart element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
height : "stretch" or int
The height of the chart element. This can be one of the following:
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled. This is ``500`` by default.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
use_container_width : bool or None
Whether to override the map's native width with the width of
the parent container. This can be one of the following:
- ``None`` (default): Streamlit will use the map's default behavior.
- ``True``: Streamlit sets the width of the map to match the
width of the parent container.
- ``False``: Streamlit sets the width of the map to fit its
contents according to the plotting library, up to the width of
the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
Examples
--------
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
>>> rng(0).standard_normal((1000, 2)) / [50, 50] + [37.76, -122.4],
>>> columns=["lat", "lon"],
>>> )
>>>
>>> st.map(df)
.. output::
https://doc-map.streamlit.app/
height: 600px
You can also customize the size and color of the datapoints:
>>> st.map(df, size=20, color="#0044ff")
And finally, you can choose different columns to use for the latitude
and longitude components, as well as set size and color of each
datapoint dynamically based on other columns:
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... {
... "col1": rng(0).standard_normal(1000) / 50 + 37.76,
... "col2": rng(1).standard_normal(1000) / 50 + -122.4,
... "col3": rng(2).standard_normal(1000) * 100,
... "col4": rng(3).standard_normal((1000, 4)).tolist(),
... }
... )
>>>
>>> st.map(df, latitude="col1", longitude="col2", size="col3", color="col4")
.. output::
https://doc-map-color.streamlit.app/
height: 600px
streamlit.markdown
Python Library Documentation: method markdown in module streamlit.delta_generator
markdown(body: 'SupportsStr', unsafe_allow_html: 'bool' = False, *, help: 'str | None' = None, width: "Width | Literal['auto']" = 'auto', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display string formatted as Markdown.
Parameters
----------
body : any
The text to display as GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
If anything other than a string is passed, it will be converted
into a string behind the scenes using ``str(body)``.
This also supports:
- Emoji shortcodes, such as ``:+1:`` and ``:sunglasses:``.
For a list of all supported codes,
see https://share.streamlit.io/streamlit/emoji-shortcodes.
- Streamlit logo shortcode. Use ``:streamlit:`` to add a little
Streamlit flair to your text.
- A limited set of typographical symbols. ``"<- -> <-> -- >= <= ~="``
becomes "← → ↔ — ≥ ≤ ≈" when parsed as Markdown.
- Google Material Symbols (rounded style), using the syntax
``:material/icon_name:``, where "icon_name" is the name of the
icon in snake case. For a complete list of icons, see Google's
`Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
must be on their own lines). Supported LaTeX functions are listed
at https://katex.org/docs/supported.html.
- Colored text and background colors for text. There are two ways
to apply colors:
- Streamlit color palette: Use the syntax
``:color[your text]`` and
``:color-background[your text]``, where ``color`` is one of: red,
orange, yellow, green, blue, violet, gray, grey, rainbow, or
primary. For example, ``:orange[your text]`` or
``:blue-background[your text]``. If you use "primary", Streamlit
will use the default primary accent color unless you set the
``theme.primaryColor`` configuration option.
- Custom CSS colors: Use the syntax
``:color[your text]{foreground="..." background="..."}`` with a
valid CSS color value. Both ``foreground`` and ``background`` are
optional. Supported formats include named CSS colors, HEX, RGB(A),
and HSL(A). For example,
``:color[warning]{foreground="#d50000"}`` or
``:color[note]{foreground="rgb(0,100,200)" background="hsl(60,100%,90%)"}``.
.. note::
When using ``:color[...]{}`` with custom CSS colors, a named
color like ``"red"`` refers to the standard CSS named color,
not the Streamlit palette color. RGB and HSL values must use
comma-separated syntax; the modern space-separated syntax
isn't supported. Colors are parsed by `color2k
<https://color2k.com>`_.
- Colored badges, using the syntax ``:color-badge[text in the badge]``.
``color`` must be replaced with any of the following supported
colors: red, orange, yellow, green, blue, violet, gray/grey, or primary.
For example, you can use ``:orange-badge[your text here]`` or
``:blue-badge[your text here]``.
- Shimmer effect for loading or in-progress text, using the syntax
``:shimmer[text to shimmer]``. The text fades in and out to indicate
ongoing activity. This respects the user's reduced motion preferences.
- Small text, using the syntax ``:small[text to show small]``.
unsafe_allow_html : bool
Whether to render HTML within ``body``. If this is ``False``
(default), any HTML tags found in ``body`` will be escaped and
therefore treated as raw text. If this is ``True``, any HTML
expressions within ``body`` will be rendered.
Adding custom HTML to your app impacts safety, styling, and
maintainability.
.. note::
If you only want to insert HTML or CSS without Markdown text,
we recommend using ``st.html`` instead.
help : str or None
A tooltip that gets displayed next to the Markdown. If this is
``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
width : "auto", "stretch", "content", or int
The width of the Markdown element. This can be one of the following:
- ``"auto"`` (default): The width of the element adapts based on
the container flex layout. In vertical containers, the element
uses ``"stretch"`` width. In horizontal containers, the element
uses ``"content"`` width.
- ``"stretch"``: The width of the element matches the width of
the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
text_alignment : "left", "center", "right", or "justify"
The horizontal alignment of the text within the element. This can
be one of the following:
- ``"left"`` (default): Text is aligned to the left edge.
- ``"center"``: Text is centered.
- ``"right"``: Text is aligned to the right edge.
- ``"justify"``: Text is justified (stretched to fill the available
width with the last line left-aligned).
.. note::
For text alignment to have a visible effect, the element's
width must be wider than its content. If you use
``width="content"`` with short text, the alignment may not be
noticeable.
Examples
--------
>>> import streamlit as st
>>>
>>> st.markdown("*Streamlit* is **really** ***cool***.")
>>> st.markdown('''
... :red[Streamlit] :orange[can] :green[write] :blue[text] :violet[in]
... :gray[pretty] :rainbow[colors] and :blue-background[highlight] text.''')
>>> st.markdown("Here's a bouquet —\
... :tulip::cherry_blossom::rose::hibiscus::sunflower::blossom:")
>>>
>>> multi = '''If you end a line with two spaces,
... a soft return is used for the next line.
...
... Two (or more) newline characters in a row will result in a hard return.
... '''
>>> st.markdown(multi)
.. output::
https://doc-markdown.streamlit.app/
height: 350px
streamlit.metric
Python Library Documentation: method metric in module streamlit.delta_generator
metric(label: 'str', value: 'Value', delta: 'Delta' = None, delta_color: 'DeltaColor' = 'normal', *, help: 'str | None' = None, label_visibility: 'LabelVisibility' = 'visible', border: 'bool' = False, width: 'Width' = 'stretch', height: 'Height' = 'content', chart_data: 'OptionSequence[Any] | None' = None, chart_type: "Literal['line', 'bar', 'area']" = 'line', delta_arrow: 'DeltaArrow' = 'auto', format: 'str | NumberFormat | None' = None, delta_description: 'str | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a metric in big bold font, with an optional indicator of how the metric changed.
Parameters
----------
label : str
The header or title for the metric. The label can optionally
contain GitHub-flavored Markdown of the following types: Bold, Italics,
Strikethroughs, Inline Code, Links, and Images. Images display like
icons, with a max height equal to the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
value : int, float, decimal.Decimal, str, or None
Value of the metric. ``None`` is rendered as a long dash.
The value can optionally contain GitHub-flavored Markdown, subject
to the same limitations described in the ``label`` parameter.
delta : int, float, decimal.Decimal, str, or None
Amount or indicator of change in the metric. An arrow is shown next
to the delta, oriented according to its sign:
- If the delta is ``None`` or an empty string, no arrow is shown.
- If the delta is a negative number or starts with a minus sign,
the arrow points down and the delta is red.
- Otherwise, the arrow points up and the delta is green.
You can modify the display, color, and orientation of the arrow
using the ``delta_color`` and ``delta_arrow`` parameters.
The delta can optionally contain GitHub-flavored Markdown, subject
to the same limitations described in the ``label`` parameter.
delta_color : str
The color of the delta and chart. This can be one of the following:
- ``"normal"`` (default): The color is red when the delta is
negative and green otherwise.
- ``"inverse"``: The color is green when the delta is negative and
red otherwise. This is useful when a negative change is
considered good, like a decrease in cost.
- ``"off"``: The color is gray regardless of the delta.
- A named color from the basic palette: The chart and delta are the
specified color regardless of their value. This can be one of the
following: ``"red"``, ``"orange"``, ``"yellow"``, ``"green"``,
``"blue"``, ``"violet"``, ``"gray"``/``"grey"``, or
``"primary"``.
help : str or None
A tooltip that gets displayed next to the metric label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
border : bool
Whether to show a border around the metric container. If this is
``False`` (default), no border is shown. If this is ``True``, a
border is shown.
height : "content", "stretch", or int
The height of the metric element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
width : "stretch", "content", or int
The width of the metric element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
chart_data : Iterable or None
A sequence of numeric values to display as a sparkline chart. If
this is ``None`` (default), no chart is displayed. The sequence can
be anything supported by ``st.dataframe``, including a ``list`` or
``set``. If the sequence is dataframe-like, the first column will
be used. Each value will be cast to ``float`` internally by
default.
The chart uses the color of the delta indicator, which can be
modified using the ``delta_color`` parameter.
chart_type : "line", "bar", or "area"
The type of sparkline chart to display. This can be one of the
following:
- ``"line"`` (default): A simple sparkline.
- ``"area"``: A sparkline with area shading.
- ``"bar"``: A bar chart.
delta_arrow : "auto", "up", "down", or "off"
Controls the direction of the delta indicator arrow. This can be
one of the following strings:
- ``"auto"`` (default): The arrow direction follows the sign of
``delta``.
- ``"up"`` or ``"down"``: The arrow is forced to point in the
specified direction.
- ``"off"``: No arrow is shown, but the delta value remains
visible.
format : str or None
A format string controlling how numbers are displayed for ``value``
and ``delta``. The format is only applied if the value or delta is
numeric. If the value or delta is a string with non-numeric
characters, the format is ignored. The format can be one of the
following values:
- ``None`` (default): No formatting is applied.
- ``"plain"``: Show the full number without any formatting (e.g. "1234.567").
- ``"localized"``: Show the number in the default locale format (e.g. "1,234.567").
- ``"percent"``: Show the number as a percentage (e.g. "123456.70%").
- ``"dollar"``: Show the number as a dollar amount (e.g. "$1,234.57").
- ``"euro"``: Show the number as a euro amount (e.g. "€1,234.57").
- ``"yen"``: Show the number as a yen amount (e.g. "¥1,235").
- ``"accounting"``: Show the number in an accounting format (e.g. "1,234.00").
- ``"bytes"``: Show the number in a byte format (e.g. "1.2KB").
- ``"compact"``: Show the number in a compact format (e.g. "1.2K").
- ``"scientific"``: Show the number in scientific notation (e.g. "1.235E3").
- ``"engineering"``: Show the number in engineering notation (e.g. "1.235E3").
- printf-style format string: Format the number with a printf
specifier, like ``"%d"`` to show a signed integer (e.g. "1234") or
``"%.2f"`` to show a float with 2 decimal places. Use ``,`` for
thousand separators (e.g. ``"%,d"`` yields ``"1,234"``).
delta_description : str or None
A short description displayed next to the delta value, such as
``"month over month"`` or ``"vs. last quarter"``. If this is ``None``
(default), no description is shown. The description is displayed
in a smaller, muted font style similar to ``st.caption``.
Examples
--------
**Example 1: Show a metric**
>>> import streamlit as st
>>>
>>> st.metric(label="Temperature", value="70 °F", delta="1.2 °F")
.. output::
https://doc-metric-example1.streamlit.app/
height: 210px
**Example 2: Create a row of metrics**
``st.metric`` looks especially nice in combination with ``st.columns``.
>>> import streamlit as st
>>>
>>> col1, col2, col3 = st.columns(3)
>>> col1.metric("Temperature", "70 °F", "1.2 °F")
>>> col2.metric("Wind", "9 mph", "-8%")
>>> col3.metric("Humidity", "86%", "4%")
.. output::
https://doc-metric-example2.streamlit.app/
height: 210px
**Example 3: Modify the delta indicator**
The delta indicator color can also be inverted or turned off.
>>> import streamlit as st
>>>
>>> st.metric(
... label="Gas price", value=4, delta=-0.5, delta_color="inverse"
... )
>>>
>>> st.metric(
... label="Active developers",
... value=123,
... delta=123,
... delta_color="off",
... )
.. output::
https://doc-metric-example3.streamlit.app/
height: 320px
**Example 4: Create a grid of metric cards**
Add borders to your metrics to create a dashboard look.
>>> import streamlit as st
>>>
>>> a, b = st.columns(2)
>>> c, d = st.columns(2)
>>>
>>> a.metric("Temperature", "30°F", "-9°F", border=True)
>>> b.metric("Wind", "4 mph", "2 mph", border=True)
>>>
>>> c.metric("Humidity", "77%", "5%", border=True)
>>> d.metric("Pressure", "30.34 inHg", "-2 inHg", border=True)
.. output::
https://doc-metric-example4.streamlit.app/
height: 350px
**Example 5: Show sparklines**
To show trends over time, add sparklines.
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> changes = list(rng(4).standard_normal(20))
>>> data = [sum(changes[:i]) for i in range(20)]
>>> delta = round(data[-1], 2)
>>>
>>> row = st.container(horizontal=True)
>>> with row:
>>> st.metric(
... "Line", 10, delta, chart_data=data, chart_type="line", border=True
... )
>>> st.metric(
... "Area", 10, delta, chart_data=data, chart_type="area", border=True
... )
>>> st.metric(
... "Bar", 10, delta, chart_data=data, chart_type="bar", border=True
... )
.. output::
https://doc-metric-example5.streamlit.app/
height: 300px
streamlit.multiselect
Python Library Documentation: method multiselect in module streamlit.delta_generator
multiselect(label: 'str', options: 'OptionSequence[T]', default: 'Any | None' = None, format_func: 'Callable[[Any], str]' = <class 'str'>, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, max_selections: 'int | None' = None, placeholder: 'str | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', accept_new_options: 'bool' = False, filter_mode: 'SelectWidgetFilterMode' = 'fuzzy', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'list[T] | list[T | str]' method of streamlit.delta_generator.DeltaGenerator instance
Display a multiselect widget.
The multiselect widget starts as empty.
Parameters
----------
label : str
A short label explaining to the user what this select widget is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
options : Iterable
Labels for the select options in an ``Iterable``. This can be a
``list``, ``set``, or anything supported by ``st.dataframe``. If
``options`` is dataframe-like, the first column will be used. Each
label will be cast to ``str`` internally by default.
default : Iterable of V, V, or None
List of default values. Can also be a single value.
format_func : function
Function to modify the display of the options. It receives
the raw option as an argument and should output the label to be
shown for that option. This has no impact on the return value of
the command.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``max_selections`` or ``accept_new_options``
resets the widget even when a key is provided.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this widget's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
max_selections : int or None
The max selections that can be selected at a time. If this is
``None`` (default), there is no limit on the number of selections.
If this is an integer, it must be positive.
placeholder : str or None
A string to display when no options are selected.
If this is ``None`` (default), the widget displays placeholder text
based on the widget's configuration:
- "Choose options" is displayed when options are available and
``accept_new_options=False``.
- "Choose or add options" is displayed when options are available
and ``accept_new_options=True``.
- "Add options" is displayed when no options are available and
``accept_new_options=True``.
- "No options to select" is displayed when no options are available
and ``accept_new_options=False``. The widget is also disabled in
this case.
disabled : bool
An optional boolean that disables the multiselect widget if set
to ``True``. The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
accept_new_options : bool
Whether the user can add selections that aren't included in ``options``.
If this is ``False`` (default), the user can only select from the
items in ``options``. If this is ``True``, the user can enter new
items that don't exist in ``options``.
When a user enters and selects a new item, it is included in the
widget's returned list as a string. The new item is not added to
the widget's drop-down menu. Streamlit will use a case-insensitive
match from ``options`` before adding a new item, and a new item
can't be added if a case-insensitive match is already selected. The
``max_selections`` argument is still enforced.
filter_mode : "fuzzy", "contains", "prefix", or None
The matching mode used to filter options while the user types.
If this is ``"fuzzy"`` (default), options are matched by in-order
subsequence and sorted by match score. If this is ``"contains"``,
options are matched by case-insensitive substring. If this is
``"prefix"``, options are matched by case-insensitive prefix. If
this is ``None``, typing is disabled and the options are not
filtered.
``filter_mode=None`` is incompatible with
``accept_new_options=True``.
width : "stretch" or int
The width of the multiselect widget. This can be one of the
following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
An empty query parameter (e.g., ``?tags=``) clears the
widget. Invalid query parameter values are ignored and
removed from the URL. Multiple selections use repeated
parameters (e.g., ``?tags=Red&tags=Blue``). Duplicates are
deduplicated. If ``max_selections`` is set, excess values
are truncated. When ``accept_new_options`` is ``True``, any
value is accepted.
Returns
-------
list
A list of the selected options.
The list contains copies of the selected options, not the originals.
Examples
--------
**Example 1: Use a basic multiselect widget**
You can declare one or more initial selections with the ``default``
parameter.
>>> import streamlit as st
>>>
>>> options = st.multiselect(
... "What are your favorite colors?",
... ["Green", "Yellow", "Red", "Blue"],
... default=["Yellow", "Red"],
... )
>>>
>>> st.write("You selected:", options)
.. output::
https://doc-multiselect.streamlit.app/
height: 350px
**Example 2: Let users to add new options**
To allow users to enter and select new options that aren't included in
the ``options`` list, use the ``accept_new_options`` parameter. To
prevent users from adding an unbounded number of new options, use the
``max_selections`` parameter.
>>> import streamlit as st
>>>
>>> options = st.multiselect(
... "What are your favorite cat names?",
... ["Jellybeans", "Fish Biscuit", "Madam President"],
... max_selections=5,
... accept_new_options=True,
... )
>>>
>>> st.write("You selected:", options)
.. output::
https://doc-multiselect-accept-new-options.streamlit.app/
height: 350px
streamlit.net_util
Python Library Documentation: module streamlit.net_util in streamlit
NAME
streamlit.net_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUNCTIONS
get_external_ip() -> 'str | None'
Get the *external* IP address of the current machine.
Returns
-------
string
The external IPv4 address of the current machine.
get_internal_ip() -> 'str | None'
Get the *local* IP address of the current machine.
From: https://stackoverflow.com/a/28950776
Returns
-------
string
The local IPv4 address of the current machine.
DATA
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
__annotations__ = {'_AWS_CHECK_IP': 'Final', '_AWS_CHECK_IP_HTTPS': 'F...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\net_util.py
streamlit.number_input
Python Library Documentation: method number_input in module streamlit.delta_generator
number_input(label: 'str', min_value: 'Number | None' = None, max_value: 'Number | None' = None, value: "Number | Literal['min'] | None" = 'min', step: 'Number | None' = None, format: 'str | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, placeholder: 'str | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'Number | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a numeric input widget.
.. note::
Integer values exceeding +/- ``(1<<53) - 1`` cannot be accurately
stored or returned by the widget due to serialization constraints
between the Python server and JavaScript client. You must handle
such numbers as floats, leading to a loss in precision.
Parameters
----------
label : str
A short label explaining to the user what this input is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
min_value : int, float, or None
The minimum permitted value.
If this is ``None`` (default), there will be no minimum for float
values and a minimum of ``- (1<<53) + 1`` for integer values.
max_value : int, float, or None
The maximum permitted value.
If this is ``None`` (default), there will be no maximum for float
values and a maximum of ``(1<<53) - 1`` for integer values.
value : int, float, "min" or None
The value of this widget when it first renders. If this is
``"min"`` (default), the initial value is ``min_value`` unless
``min_value`` is ``None``. If ``min_value`` is ``None``, the widget
initializes with a value of ``0.0`` or ``0``.
If ``value`` is ``None``, the widget will initialize with no value
and return ``None`` until the user provides input.
step : int, float, or None
The stepping interval.
Defaults to 1 if the value is an int, 0.01 otherwise.
If the value is not specified, the format parameter will be used.
format : str or None
A printf-style format string controlling how the interface should
display numbers. The output must be purely numeric. This does not
impact the return value of the widget. For more information about
the formatting specification, see `sprintf.js
<https://github.com/alexei/sprintf.js?tab=readme-ov-file#format-specification>`_.
For example, ``format="%0.1f"`` adjusts the displayed decimal
precision to only show one digit after the decimal.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this number_input's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
placeholder : str or None
An optional string displayed when the number input is empty.
If None, no placeholder is displayed.
disabled : bool
An optional boolean that disables the number input if set to
``True``. The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
icon : str, None
An optional emoji or icon to display within the input field to the
left of the value. If ``icon`` is ``None`` (default), no icon is
displayed. If ``icon`` is a string, the following options are
valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols \
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
width : "stretch" or int
The width of the number input widget. This can be one of the
following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Invalid query parameter values are ignored and removed
from the URL. If ``value`` is ``None``, an empty query
parameter (e.g., ``?my_key=``) clears the widget.
Returns
-------
int or float or None
The current value of the numeric input widget or ``None`` if the widget
is empty. The return type will match the data type of the value parameter.
Examples
--------
>>> import streamlit as st
>>>
>>> number = st.number_input("Insert a number")
>>> st.write("The current number is ", number)
.. output::
https://doc-number-input.streamlit.app/
height: 260px
To initialize an empty number input, use ``None`` as the value:
>>> import streamlit as st
>>>
>>> number = st.number_input(
... "Insert a number", value=None, placeholder="Type a number..."
... )
>>> st.write("The current number is ", number)
.. output::
https://doc-number-input-empty.streamlit.app/
height: 260px
streamlit.page_link
Python Library Documentation: method page_link in module streamlit.delta_generator
page_link(page: 'str | Path | StreamlitPage', *, label: 'str | None' = None, icon: 'str | None' = None, icon_position: 'IconPosition' = 'left', help: 'str | None' = None, disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', query_params: 'QueryParamsInput | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a link to another page in a multipage app or to an external page.
If another page in a multipage app is specified, clicking ``st.page_link``
stops the current page execution and runs the specified page as if the
user clicked on it in the sidebar navigation.
If an external page is specified, clicking ``st.page_link`` opens a new
tab to the specified page. The current script run will continue if not
complete.
Parameters
----------
page : str, Path, or StreamlitPage
The page to switch to on user click. This can be one of the
following values:
- Path to a Python file: The path can be a string or
``pathlib.Path`` object. It can be absolute or relative to the
entrypoint file. The Python file must be the source of a page in
``st.navigation``.
If you are using the ``pages/`` directory instead of
``st.navigation``, the Python file must be your entrypoint file
or a file in the ``pages/`` directory.
- ``StreamlitPage``: The source of the ``StreamlitPage`` and its
``url_path`` must match a page defined in ``st.navigation``.
Use ``st.Page`` to create a ``StreamlitPage`` object.
- URL: The URL must contain an HTTP or HTTPS scheme, like
``"https://docs.streamlit.io"``. When a user clicks a
URL-defined page link, the URL opens in a new tab and the app
doesn't rerun. If the page link is defined by a URL, then the
``label`` parameter is required.
To link to a page defined by a ``callable``, you must use a
``StreamlitPage`` object.
label : str
The label for the page link. Labels are required for external pages.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
icon : str or None
An optional emoji or icon to display next to the link label. If
``icon`` is ``None`` (default), the icon is inferred from the
``StreamlitPage`` object or no icon is displayed. If ``icon`` is a
string, the following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols \
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
icon_position : "left" or "right"
The position of the icon relative to the link label. This
defaults to ``"left"``.
help : str or None
A tooltip that gets displayed when the link is hovered over. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
disabled : bool
An optional boolean that disables the page link if set to ``True``.
The default is ``False``.
use_container_width : bool
Whether to expand the link's width to fill its parent container.
The default is ``True`` for page links in the sidebar and ``False``
for those in the main app.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``. For ``use_container_width=False``, use
``width="content"``.
width : "content", "stretch", or int
The width of the page-link button. This can be one of the following:
- ``"content"`` (default): The width of the button matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the button matches the width of the
parent container.
- An integer specifying the width in pixels: The button has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the button matches the width
of the parent container.
query_params : dict, list of tuples, or None
Query parameters to apply when navigating to the target page.
This can be a dictionary or an iterable of key-value tuples. Values can
be strings or iterables of strings (for repeated keys). When this is
``None`` (default), all non-embed query parameters are cleared during
navigation.
Examples
--------
**Example 1: Basic usage**
The following example shows how to create page links in a multipage app
that uses the ``pages/`` directory:
.. code-block:: text
your-repository/
├── pages/
│ ├── page_1.py
│ └── page_2.py
└── your_app.py
>>> import streamlit as st
>>>
>>> st.page_link("your_app.py", label="Home", icon="🏠")
>>> st.page_link("pages/page_1.py", label="Page 1", icon="1️⃣")
>>> st.page_link("pages/page_2.py", label="Page 2", icon="2️⃣", disabled=True)
>>> st.page_link("http://www.google.com", label="Google", icon="🌎")
The default navigation is shown here for comparison, but you can hide
the default navigation using the |client.showSidebarNavigation|_
configuration option. This allows you to create custom, dynamic
navigation menus for your apps!
.. |client.showSidebarNavigation| replace:: ``client.showSidebarNavigation``
.. _client.showSidebarNavigation: https://docs.streamlit.io/develop/api-reference/configuration/config.toml#client
.. output::
https://doc-page-link.streamlit.app/
height: 350px
**Example 2: Passing query parameters**
The following example shows how to pass query parameters when creating a
page link in a multipage app:
.. code-block:: text
your-repository/
├── page_2.py
└── your_app.py
>>> import streamlit as st
>>>
>>> def page_1():
>>> st.title("Page 1")
>>> st.page_link("page_2.py", query_params={"utm_source": "page_1"})
>>>
>>> pg = st.navigation([page_1, "page_2.py"])
>>> pg.run()
.. output::
https://doc-page-link-query-params.streamlit.app/
height: 350px
streamlit.path_security
Python Library Documentation: module streamlit.path_security in streamlit
NAME
streamlit.path_security - Shared path security utilities for preventing path traversal and SSRF attacks.
DESCRIPTION
This module provides a centralized implementation for path validation that is
used by multiple parts of the codebase. Having a single implementation ensures
consistent security checks and avoids divergent behavior between components.
Security Context
----------------
These checks are designed to run BEFORE any filesystem operations (like
``os.path.realpath()``) to prevent Windows from triggering SMB connections
to attacker-controlled servers when resolving UNC paths. This prevents
SSRF attacks and NTLM hash disclosure.
FUNCTIONS
is_unsafe_path_pattern(path: 'str') -> 'bool'
Return True if path contains UNC, absolute, drive, or traversal patterns.
This function checks for dangerous path patterns that could lead to:
- SSRF attacks via Windows UNC path resolution
- NTLM hash disclosure via SMB connections
- Path traversal outside intended directories
- Path truncation via null bytes
IMPORTANT: This check must run BEFORE any ``os.path.realpath()`` calls
to prevent Windows from triggering SMB connections to attacker-controlled
servers.
Parameters
----------
path : str
The path string to validate.
Returns
-------
bool
True if the path contains unsafe patterns, False if it appears safe
for further processing.
Examples
--------
>>> is_unsafe_path_pattern("subdir/file.js")
False
>>> is_unsafe_path_pattern("\\\\server\\share")
True
>>> is_unsafe_path_pattern("../../../etc/passwd")
True
>>> is_unsafe_path_pattern("C:\\Windows\\system32")
True
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\path_security.py
streamlit.pdf
Python Library Documentation: method pdf in module streamlit.delta_generator
pdf(data: 'PdfData', *, height: 'HeightWithoutContent' = 500, key: 'str | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a PDF viewer.
.. Important::
You must install |streamlit-pdf|_ to use this command. You can
install it as an extra with Streamlit:
.. code-block:: shell
pip install streamlit[pdf]
.. |streamlit-pdf| replace:: ``streamlit-pdf``
.. _streamlit-pdf: https://github.com/streamlit/streamlit-pdf
Parameters
----------
data : str, Path, BytesIO, or bytes
The PDF file to show. This can be one of the following:
- A URL (string) for a hosted PDF file.
- A path to a local PDF file. If you use a relative path, it must
be relative to the current working directory.
- A file-like object. For example, this can be an ``UploadedFile``
from ``st.file_uploader``, or this can be a local file opened
with ``open()``.
- Raw bytes data.
height : int or "stretch"
The height of the PDF viewer. This can be one of the following:
- An integer specifying the height in pixels: The viewer has a
fixed height. If the content is larger than the specified
height, scrolling is enabled. This is ``500`` by default.
- ``"stretch"``: The height of the viewer matches the height of
its content or the height of the parent container, whichever is
larger. If the viewer is not in a parent container, the height
of the viewer matches the height of its content.
Examples
--------
>>> st.pdf("https://example.com/sample.pdf")
>>> st.pdf("https://example.com/sample.pdf", height=600)
streamlit.pills
Python Library Documentation: method pills in module streamlit.delta_generator
pills(label: 'str', options: 'OptionSequence[V]', *, selection_mode: "Literal['single', 'multi']" = 'single', default: 'Sequence[V] | V | None' = None, required: 'bool' = False, format_func: 'Callable[[Any], str] | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'list[V] | V | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a pills widget.
A pills widget is similar to a ``st.selectbox`` or ``st.multiselect``
where the ``options`` are displayed as pill-buttons instead of a
drop-down list.
Parameters
----------
label : str
A short label explaining to the user what this widget is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
options : Iterable of V
Labels for the select options in an ``Iterable``. This can be a
``list``, ``set``, or anything supported by ``st.dataframe``. If
``options`` is dataframe-like, the first column will be used. Each
label will be cast to ``str`` internally by default and can
optionally contain GitHub-flavored Markdown, including the Markdown
directives described in the ``body`` parameter of ``st.markdown``.
selection_mode : "single" or "multi"
The selection mode for the widget. If this is ``"single"``
(default), only one option can be selected. If this is ``"multi"``,
multiple options can be selected.
default : Iterable of V, V, or None
The value of the widget when it first renders. If the
``selection_mode`` is ``multi``, this can be a list of values, a
single value, or ``None``. If the ``selection_mode`` is
``"single"``, this can be a single value or ``None``.
required : bool
Whether a selection is required. If this is ``True`` and
``selection_mode="single"``, users cannot deselect an option once
one is selected. Clicking an already-selected option does nothing.
The default is ``False``.
If ``required=True`` is used with ``selection_mode="multi"``, an
exception is raised.
format_func : function
Function to modify the display of the options. It receives
the raw option as an argument and should output the label to be
shown for that option. This has no impact on the return value of
the command. The output can optionally contain GitHub-flavored
Markdown, including the Markdown directives described in the
``body`` parameter of ``st.markdown``.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``selection_mode`` resets the widget even when a
key is provided.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this widget's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the widget if set to ``True``.
The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "content", "stretch", or int
The width of the pills widget. This can be one of the following:
- ``"content"`` (default): The width of the widget matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the widget matches the width of the
parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
An empty query parameter (e.g., ``?tags=``) clears the
widget. Invalid query parameter values are ignored and removed from
the URL. For ``selection_mode="multi"``, multiple selections use
repeated parameters (e.g., ``?tags=Red&tags=Blue``) and duplicates
are deduplicated.
Returns
-------
list of V, V, or None
If the ``selection_mode`` is ``multi``, this is a list of selected
options or an empty list. If the ``selection_mode`` is
``"single"``, this is a selected option or ``None``.
This contains copies of the selected options, not the originals.
Examples
--------
**Example 1: Multi-select pills**
Display a multi-select pills widget, and show the selection:
>>> import streamlit as st
>>>
>>> options = ["North", "East", "South", "West"]
>>> selection = st.pills("Directions", options, selection_mode="multi")
>>> st.markdown(f"Your selected options: {selection}.")
.. output::
https://doc-pills-multi.streamlit.app/
height: 200px
**Example 2: Single-select pills with icons**
Display a single-select pills widget with icons:
>>> import streamlit as st
>>>
>>> option_map = {
... 0: ":material/add:",
... 1: ":material/zoom_in:",
... 2: ":material/zoom_out:",
... 3: ":material/zoom_out_map:",
... }
>>> selection = st.pills(
... "Tool",
... options=option_map.keys(),
... format_func=lambda option: option_map[option],
... selection_mode="single",
... )
>>> st.write(
... "Your selected option: "
... f"{None if selection is None else option_map[selection]}"
... )
.. output::
https://doc-pills-single.streamlit.app/
height: 200px
streamlit.plotly_chart
Python Library Documentation: method plotly_chart in module streamlit.delta_generator
plotly_chart(figure_or_data: 'FigureOrData', use_container_width: 'bool | None' = None, *, width: 'Width' = 'stretch', height: 'Height' = 'content', theme: "Literal['streamlit'] | None" = 'streamlit', key: 'Key | None' = None, on_select: "Literal['rerun', 'ignore'] | WidgetCallback" = 'ignore', selection_mode: 'SelectionMode | Iterable[SelectionMode]' = ('points', 'box', 'lasso'), config: 'dict[str, Any] | None' = None) -> 'DeltaGenerator | PlotlyState' method of streamlit.delta_generator.DeltaGenerator instance
Display an interactive Plotly chart.
`Plotly <https://plot.ly/python>`_ is a charting library for Python.
To show Plotly charts in Streamlit, pass a Plotly ``Figure`` or
``Data`` object to ``st.plotly_chart``.
.. Important::
You must install ``plotly>=4.0.0`` to use this command. Your app's
performance may be enhanced by installing ``orjson`` as well. You
can install all charting dependencies (except Bokeh) as an extra
with Streamlit:
.. code-block:: shell
pip install streamlit[charts]
Parameters
----------
figure_or_data : plotly.graph_objs.Figure, plotly.graph_objs.Data, or dict/list of plotly.graph_objs.Figure/Data
The Plotly ``Figure`` or ``Data`` object to render. See
https://plot.ly/python/ for examples of graph descriptions.
.. note::
If your chart contains more than 1000 data points, Plotly will
use a WebGL renderer to display the chart. Different browsers
have different limits on the number of WebGL contexts per page.
If you have multiple WebGL contexts on a page, you may need to
switch to SVG rendering mode. You can do this by setting
``render_mode="svg"`` within the figure. For example, the
following code defines a Plotly Express line chart that will
render in SVG mode when passed to ``st.plotly_chart``:
``px.line(df, x="x", y="y", render_mode="svg")``.
width : "stretch", "content", or int
The width of the chart element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
height : "content", "stretch", or int
The height of the chart element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
use_container_width : bool or None
Whether to override the figure's native width with the width of
the parent container. This can be one of the following:
- ``None`` (default): Streamlit will use the value of ``width``.
- ``True``: Streamlit sets the width of the figure to match the
width of the parent container.
- ``False``: Streamlit sets the width of the figure to fit its
contents according to the plotting library, up to the width of
the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
theme : "streamlit" or None
The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
Streamlit uses its own design default. If ``theme`` is ``None``,
Streamlit falls back to the default behavior of the library.
The ``"streamlit"`` theme can be partially customized through the
configuration options ``theme.chartCategoricalColors`` and
``theme.chartSequentialColors``. Font configuration options are
also applied.
key : str, int, or None
An optional string to use for giving this element a stable
identity. If this is ``None`` (default), the element's identity
will be determined based on the values of the other parameters.
If selections are activated and ``key`` is provided,
Streamlit will register the key in Session State to store the
selection state. The selection state is read-only. For more
details, see `Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
on_select : "ignore" or "rerun" or callable
How the figure should respond to user selection events. This
controls whether or not the figure behaves like an input widget.
``on_select`` can be one of the following:
- ``"ignore"`` (default): Streamlit will not react to any selection
events in the chart. The figure will not behave like an input
widget.
- ``"rerun"``: Streamlit will rerun the app when the user selects
data in the chart. In this case, ``st.plotly_chart`` will return
the selection data as a dictionary.
- A ``callable``: Streamlit will rerun the app and execute the
``callable`` as a callback function before the rest of the app.
In this case, ``st.plotly_chart`` will return the selection data
as a dictionary.
selection_mode : "points", "box", "lasso" or an Iterable of these
The selection mode of the chart. This can be one of the following:
- ``"points"``: The chart will allow selections based on individual
data points.
- ``"box"``: The chart will allow selections based on rectangular
areas.
- ``"lasso"``: The chart will allow selections based on freeform
areas.
- An ``Iterable`` of the above options: The chart will allow
selections based on the modes specified.
All selections modes are activated by default.
config : dict or None
A dictionary of Plotly configuration options. This is passed to
Plotly's ``show()`` function. For more information about Plotly
configuration options, see Plotly's documentation on `Configuration
in Python <https://plotly.com/python/configuration-options/>`_.
Returns
-------
element or dict
If ``on_select`` is ``"ignore"`` (default), this command returns an
internal placeholder for the chart element. Otherwise, this command
returns a dictionary-like object that supports both key and
attribute notation. The attributes are described by the
``PlotlyState`` dictionary schema.
Examples
--------
**Example 1: Basic Plotly chart**
The example below comes from the examples at https://plot.ly/python.
Note that ``plotly.figure_factory`` requires ``scipy`` to run.
>>> import plotly.figure_factory as ff
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> hist_data = [
... rng(0).standard_normal(200) - 2,
... rng(1).standard_normal(200),
... rng(2).standard_normal(200) + 2,
... ]
>>> group_labels = ["Group 1", "Group 2", "Group 3"]
>>>
>>> fig = ff.create_distplot(
... hist_data, group_labels, bin_size=[0.1, 0.25, 0.5]
... )
>>>
>>> st.plotly_chart(fig)
.. output::
https://doc-plotly-chart.streamlit.app/
height: 550px
**Example 2: Plotly Chart with configuration**
By default, Plotly charts have scroll zoom enabled. If you have a
longer page and want to avoid conflicts between page scrolling and
zooming, you can use Plotly's configuration options to disable scroll
zoom. In the following example, scroll zoom is disabled, but the zoom
buttons are still enabled in the modebar.
>>> import plotly.graph_objects as go
>>> import streamlit as st
>>>
>>> fig = go.Figure()
>>> fig.add_trace(
... go.Scatter(
... x=[1, 2, 3, 4, 5],
... y=[1, 3, 2, 5, 4]
... )
... )
>>>
>>> st.plotly_chart(fig, config = {'scrollZoom': False})
.. output::
https://doc-plotly-chart-config.streamlit.app/
height: 550px
streamlit.popover
Python Library Documentation: method popover in module streamlit.delta_generator
popover(label: 'str', *, type: "Literal['primary', 'secondary', 'tertiary']" = 'secondary', help: 'str | None' = None, icon: 'str | None' = None, disabled: 'bool' = False, use_container_width: 'bool | None' = None, width: 'Width' = 'content', key: 'Key | None' = None, on_change: "Literal['ignore', 'rerun'] | WidgetCallback" = 'ignore', args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None) -> 'PopoverContainer' method of streamlit.delta_generator.DeltaGenerator instance
Insert a popover container.
Inserts a multi-element container as a popover. It consists of a button-like
element and a container that opens when the button is clicked.
To add elements to the returned container, you can use the "with"
notation (preferred) or just call methods directly on the returned object.
See examples below.
Interacting with widgets inside of an open popover will rerun the app
while keeping the popover open. Clicking outside of the popover will
close it.
By default, all content within the popover is computed and sent to the
frontend, and the app doesn't rerun when the popover is opened or
closed. To enable lazy execution where content only runs when the
popover is open, use ``on_change="rerun"`` or pass a callable to
``on_change``. The ``.open`` property indicates whether the popover is
currently open, letting you conditionally render expensive content.
.. note::
To follow best design practices, don't nest popovers.
Parameters
----------
label : str
The label of the button that opens the popover container.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
help : str or None
A tooltip that gets displayed when the popover button is hovered
over. If this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
type : "primary", "secondary", or "tertiary"
An optional string that specifies the button type. This can be one
of the following:
- ``"primary"``: The button's background is the app's primary color
for additional emphasis.
- ``"secondary"`` (default): The button's background coordinates
with the app's background color for normal emphasis.
- ``"tertiary"``: The button is plain text without a border or
background for subtlety.
icon : str
An optional emoji or icon to display next to the button label. If ``icon``
is ``None`` (default), no icon is displayed. If ``icon`` is a
string, the following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols \
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
disabled : bool
An optional boolean that disables the popover button if set to
``True``. The default is ``False``.
use_container_width : bool
Whether to expand the button's width to fill its parent container.
If ``use_container_width`` is ``False`` (default), Streamlit sizes
the button to fit its content. If ``use_container_width`` is
``True``, the width of the button matches its parent container.
In both cases, if the content of the button is wider than the
parent container, the content will line wrap.
The popover container's minimum width matches the width of its
button. The popover container may be wider than its button to fit
the container's content.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``. For ``use_container_width=False``, use
``width="content"``.
width : int, "stretch", or "content"
The width of the button. This can be one of the following:
- ``"content"`` (default): The width of the button matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the button matches the width of the
parent container.
- An integer specifying the width in pixels: The button has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the button matches the width
of the parent container.
The popover container's minimum width matches the width of its
button. The popover container may be wider than its button to fit
the container's contents.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key.
When ``on_change`` is set to ``"rerun"`` or a callable, setting a
key lets you read or update the open/closed state via
``st.session_state[key]``. For more details, see `Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
on_change : "ignore", "rerun", or callable
How the popover should respond when the user opens or closes it.
This controls whether the popover tracks state and triggers
reruns. ``on_change`` can be one of the following values:
- ``"ignore"`` (default): The popover doesn't track state. All
popover content runs regardless of whether the popover is open or
closed. The ``.open`` attribute of the popover container returns
``None``.
- ``"rerun"``: The popover tracks state. Streamlit reruns the app
when the user opens or closes the popover. The ``.open``
attribute of the popover container returns the current state,
which is ``True`` if the popover is open and ``False`` if it's
closed. This lets you skip expensive work when the popover is
closed.
- A callable: The popover tracks state. Streamlit executes the
callable as a callback function and reruns the app when the user
opens or closes the popover. The ``.open`` attribute of the
popover container returns its state like when
``on_change="rerun"``. If you need to access the current state
inside your callback, fetch it through Session State.
When the popover tracks state, it can't be used inside Streamlit
cache-decorated functions.
args : list or tuple or None
An optional list or tuple of args to pass to the ``on_change``
callback.
kwargs : dict or None
An optional dict of kwargs to pass to the ``on_change`` callback.
Returns
-------
PopoverContainer
A ``PopoverContainer`` object with an ``.open`` property to return
the current state of the popover if the popover tracks state.
Examples
--------
**Example 1: Use context management**
You can use the ``with`` notation to insert any element into a popover:
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
with st.popover("Open popover"):
st.markdown("Hello World 👋")
name = st.text_input("What's your name?")
st.write("Your name:", name)
.. output::
https://doc-popover.streamlit.app/
height: 400px
**Example 2: Call methods directly**
You can call methods directly on the returned object:
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
popover = st.popover("Filter items")
red = popover.checkbox("Show red items.", True)
blue = popover.checkbox("Show blue items.", True)
if red:
st.write(":red[This is a red item.]")
if blue:
st.write(":blue[This is a blue item.]")
.. output::
https://doc-popover2.streamlit.app/
height: 400px
**Example 3: Programmatically control the popover state**
You can use a key to programmatically control the popover state or
access the state in callbacks. You must set the ``on_change`` parameter
for the popover to track state.
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
def toggle_popover():
st.session_state.drawer = not st.session_state.drawer
def on_popover_change():
if st.session_state.drawer:
st.toast("You opened the popover.")
else:
st.toast("You closed the popover.")
with st.popover("Open popover", on_change=on_popover_change, key="drawer"):
st.write("This is the popover")
st.button("Close popover", on_click=toggle_popover)
st.button("Open popover", on_click=toggle_popover)
.. output::
https://doc-popover-callback.streamlit.app/
height: 300px
streamlit.progress
Python Library Documentation: method progress in module streamlit.delta_generator
progress(value: 'FloatOrInt', text: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a progress bar.
Parameters
----------
value : int or float
0 <= value <= 100 for int
0.0 <= value <= 1.0 for float
text : str or None
A message to display above the progress bar. The text can optionally
contain GitHub-flavored Markdown of the following types: Bold, Italics,
Strikethroughs, Inline Code, Links, and Images. Images display like
icons, with a max height equal to the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
width : "stretch" or int
The width of the progress element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Examples
--------
Here is an example of a progress bar increasing over time and disappearing when it reaches completion:
>>> import streamlit as st
>>> import time
>>>
>>> progress_text = "Operation in progress. Please wait."
>>> my_bar = st.progress(0, text=progress_text)
>>>
>>> for percent_complete in range(100):
... time.sleep(0.01)
... my_bar.progress(percent_complete + 1, text=progress_text)
>>> time.sleep(1)
>>> my_bar.empty()
>>>
>>> st.button("Rerun")
.. output::
https://doc-status-progress.streamlit.app/
height: 220px
streamlit.proto
Python Library Documentation: package streamlit.proto in streamlit
NAME
streamlit.proto
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PACKAGE CONTENTS
Alert_pb2
AppPage_pb2
ArrowData_pb2
ArrowNamedDataSet_pb2
AudioInput_pb2
Audio_pb2
AuthRedirect_pb2
AutoRerun_pb2
BackMsg_pb2
Balloons_pb2
BidiComponent_pb2
Block_pb2
ButtonGroup_pb2
ButtonLikeIconPosition_pb2
Button_pb2
CameraInput_pb2
ChatInput_pb2
Checkbox_pb2
ClientState_pb2
Code_pb2
ColorPicker_pb2
Common_pb2
Components_pb2
Dataframe_pb2
DateInput_pb2
DateTimeInput_pb2
DeckGlJsonChart_pb2
Delta_pb2
DownloadButton_pb2
Element_pb2
Empty_pb2
Exception_pb2
Favicon_pb2
Feedback_pb2
FileUploader_pb2
ForwardMsg_pb2
GapSize_pb2
GitInfo_pb2
GraphVizChart_pb2
Heading_pb2
HeightConfig_pb2
Help_pb2
Html_pb2
IFrame_pb2
Image_pb2
Json_pb2
LabelVisibility_pb2
LinkButton_pb2
Logo_pb2
Markdown_pb2
MenuButton_pb2
Metric_pb2
MetricsEvent_pb2
MultiSelect_pb2
Navigation_pb2
NewSession_pb2
NumberInput_pb2
PageConfig_pb2
PageInfo_pb2
PageLink_pb2
PageNotFound_pb2
PageProfile_pb2
ParentMessage_pb2
PlotlyChart_pb2
Progress_pb2
Radio_pb2
RootContainer_pb2
SelectWidgetFilterMode_pb2
Selectbox_pb2
SessionEvent_pb2
SessionStatus_pb2
Skeleton_pb2
Slider_pb2
Snow_pb2
Space_pb2
Spinner_pb2
Table_pb2
TextAlignmentConfig_pb2
TextArea_pb2
TextInput_pb2
Text_pb2
TimeInput_pb2
Toast_pb2
Transient_pb2
VegaLiteChart_pb2
Video_pb2
WidgetStates_pb2
WidthConfig_pb2
openmetrics_data_model_pb2
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\proto\__init__.py
streamlit.pydeck_chart
Python Library Documentation: method pydeck_chart in module streamlit.delta_generator
pydeck_chart(pydeck_obj: 'Deck | None' = None, *, width: 'WidthWithoutContent' = 'stretch', use_container_width: 'bool | None' = None, height: 'HeightWithoutContent' = 500, selection_mode: 'SelectionMode' = 'single-object', on_select: "Literal['rerun', 'ignore'] | WidgetCallback" = 'ignore', key: 'Key | None' = None) -> 'DeltaGenerator | PydeckState' method of streamlit.delta_generator.DeltaGenerator instance
Draw a chart using the PyDeck library.
This supports 3D maps, point clouds, and more! More info about PyDeck
at https://deckgl.readthedocs.io/en/latest/.
These docs are also quite useful:
- DeckGL docs: https://github.com/uber/deck.gl/tree/master/docs
- DeckGL JSON docs: https://github.com/uber/deck.gl/tree/master/modules/json
When using this command, a service called Carto_ provides the map tiles to render
map content. If you're using advanced PyDeck features you may need to obtain
an API key from Carto first. You can do that as
``pydeck.Deck(api_keys={"carto": YOUR_KEY})`` or by setting the CARTO_API_KEY
environment variable. See `PyDeck's documentation`_ for more information.
Another common provider for map tiles is Mapbox_. If you prefer to use that,
you'll need to create an account at https://mapbox.com and specify your Mapbox
key when creating the ``pydeck.Deck`` object. You can do that as
``pydeck.Deck(api_keys={"mapbox": YOUR_KEY})`` or by setting the MAPBOX_API_KEY
environment variable.
.. _Carto: https://carto.com
.. _Mapbox: https://mapbox.com
.. _PyDeck's documentation: https://deckgl.readthedocs.io/en/latest/deck.html
Carto and Mapbox are third-party products and Streamlit accepts no responsibility
or liability of any kind for Carto or Mapbox, or for any content or information
made available by Carto or Mapbox. The use of Carto or Mapbox is governed by
their respective Terms of Use.
.. note::
Pydeck uses two WebGL contexts per chart, and different browsers
have different limits on the number of WebGL contexts per page.
If you exceed this limit, the oldest contexts will be dropped to
make room for the new ones. To avoid this limitation in most
browsers, don't display more than eight Pydeck charts on a single
page.
Parameters
----------
pydeck_obj : pydeck.Deck or None
Object specifying the PyDeck chart to draw.
width : "stretch" or int
The width of the chart element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
use_container_width : bool or None
Whether to override the chart's native width with the width of
the parent container. This can be one of the following:
- ``None`` (default): Streamlit will use the chart's default behavior.
- ``True``: Streamlit sets the width of the chart to match the
width of the parent container.
- ``False``: Streamlit sets the width of the chart to fit its
contents according to the plotting library, up to the width of
the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
height : "stretch" or int
The height of the chart element. This can be one of the following:
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled. This is ``500`` by default.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
on_select : "ignore" or "rerun" or callable
How the figure should respond to user selection events. This controls
whether or not the chart behaves like an input widget.
``on_select`` can be one of the following:
- ``"ignore"`` (default): Streamlit will not react to any selection
events in the chart. The figure will not behave like an
input widget.
- ``"rerun"``: Streamlit will rerun the app when the user selects
data in the chart. In this case, ``st.pydeck_chart`` will return
the selection data as a dictionary.
- A ``callable``: Streamlit will rerun the app and execute the callable
as a callback function before the rest of the app. In this case,
``st.pydeck_chart`` will return the selection data as a
dictionary.
If ``on_select`` is not ``"ignore"``, all layers must have a
declared ``id`` to keep the chart stateful across reruns.
selection_mode : "single-object" or "multi-object"
The selection mode of the chart. This can be one of the following:
- ``"single-object"`` (default): Only one object can be selected at
a time.
- ``"multi-object"``: Multiple objects can be selected at a time.
key : str, int, or None
An optional string to use for giving this element a stable
identity. If this is ``None`` (default), the element's identity
will be determined based on the values of the other parameters.
If selections are activated and ``key`` is provided,
Streamlit will register the key in Session State to store the
selection state. The selection state is read-only. For more
details, see `Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
Returns
-------
element or dict
If ``on_select`` is ``"ignore"`` (default), this command returns an
internal placeholder for the chart element. Otherwise, this method
returns a dictionary-like object that supports both key and
attribute notation. The attributes are described by the
``PydeckState`` dictionary schema.
Examples
--------
Here's a chart using a HexagonLayer and a ScatterplotLayer. It uses either the
light or dark map style, based on which Streamlit theme is currently active:
>>> import pandas as pd
>>> import pydeck as pdk
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... rng(0).standard_normal((1000, 2)) / [50, 50] + [37.76, -122.4],
... columns=["lat", "lon"],
... )
>>>
>>> st.pydeck_chart(
... pdk.Deck(
... map_style=None, # Use Streamlit theme to pick map style
... initial_view_state=pdk.ViewState(
... latitude=37.76,
... longitude=-122.4,
... zoom=11,
... pitch=50,
... ),
... layers=[
... pdk.Layer(
... "HexagonLayer",
... data=df,
... get_position="[lon, lat]",
... radius=200,
... elevation_scale=4,
... elevation_range=[0, 1000],
... pickable=True,
... extruded=True,
... ),
... pdk.Layer(
... "ScatterplotLayer",
... data=df,
... get_position="[lon, lat]",
... get_color="[200, 30, 0, 160]",
... get_radius=200,
... ),
... ],
... )
... )
.. output::
https://doc-pydeck-chart.streamlit.app/
height: 530px
.. note::
To make the PyDeck chart's style consistent with Streamlit's theme,
you can set ``map_style=None`` in the ``pydeck.Deck`` object.
streamlit.pyplot
Python Library Documentation: method pyplot in module streamlit.delta_generator
pyplot(fig: 'Figure | None' = None, clear_figure: 'bool | None' = None, *, width: 'Width' = 'stretch', use_container_width: 'bool | None' = None, **kwargs: 'Any') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a matplotlib.pyplot figure.
.. Important::
You must install ``matplotlib>=3.0.0`` to use this command. You can
install all charting dependencies (except Bokeh) as an extra with
Streamlit:
.. code-block:: shell
pip install streamlit[charts]
Parameters
----------
fig : Matplotlib Figure
The Matplotlib ``Figure`` object to render. See
https://matplotlib.org/stable/gallery/index.html for examples.
.. note::
When this argument isn't specified, this function will render the global
Matplotlib figure object. However, this feature is deprecated and
will be removed in a later version.
clear_figure : bool
If True, the figure will be cleared after being rendered.
If False, the figure will not be cleared after being rendered.
If left unspecified, we pick a default based on the value of ``fig``.
- If ``fig`` is set, defaults to ``False``.
- If ``fig`` is not set, defaults to ``True``. This simulates Jupyter's
approach to matplotlib rendering.
width : "stretch", "content", or int
The width of the chart element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the
width of its content, but doesn't exceed the width of the parent
container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
use_container_width : bool
Whether to override the figure's native width with the width of
the parent container. If ``use_container_width`` is ``True``
(default), Streamlit sets the width of the figure to match the
width of the parent container. If ``use_container_width`` is
``False``, Streamlit sets the width of the chart to fit its
contents according to the plotting library, up to the width of the
parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``. For ``use_container_width=False``, use
``width="content"``.
**kwargs : any
Arguments to pass to Matplotlib's savefig function.
Examples
--------
>>> import matplotlib.pyplot as plt
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> arr = rng(0).normal(1, 1, size=100)
>>> fig, ax = plt.subplots()
>>> ax.hist(arr, bins=20)
>>>
>>> st.pyplot(fig)
.. output::
https://doc-pyplot.streamlit.app/
height: 630px
Matplotlib supports several types of "backends". If you're getting an
error using Matplotlib with Streamlit, try setting your backend to "TkAgg"::
echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc
For more information, see https://matplotlib.org/faq/usage_faq.html.
streamlit.query_params
Python Library Documentation: QueryParamsProxy in module streamlit.runtime.state.query_params_proxy object
class QueryParamsProxy(collections.abc.MutableMapping)
| A stateless singleton that proxies ``st.query_params`` interactions
| to the current script thread's QueryParams instance.
|
| Method resolution order:
| QueryParamsProxy
| collections.abc.MutableMapping
| collections.abc.Mapping
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| __delattr__(self, key: 'str') -> 'None'
| Implement delattr(self, name).
|
| __delitem__(self, key: 'str') -> 'None'
|
| __getattr__(self, key: 'str') -> 'str'
|
| __getitem__(self, key: 'str') -> 'str'
|
| __iter__(self) -> 'Iterator[str]'
|
| __len__(self) -> 'int'
|
| __setattr__(self, key: 'str', value: 'Any') -> 'None'
| Implement setattr(self, name, value).
|
| __setitem__(self, key: 'str', value: 'Any') -> 'None'
|
| __str__(self) -> 'str'
| Return str(self).
|
| clear(self) -> 'None'
| Clear all query parameters from the URL of the app.
|
| from_dict(self, params: 'SupportsKeysAndGetItem[str, str | Iterable[str]] | Iterable[tuple[str, str | Iterable[str]]]') -> 'None'
| Set all of the query parameters from a dictionary or dictionary-like object.
|
| This method primarily exists for advanced users who want to control
| multiple query parameters in a single update. To set individual query
| parameters, use key or attribute notation instead.
|
| This method inherits limitations from ``st.query_params`` and can't be
| used to set embedding options as described in `Embed your app <https://docs.streamlit.io/deploy/streamlit-community-cloud/share-your-app/embed-your-app#embed-options>`_.
|
| To handle repeated keys, the value in a key-value pair should be a list.
|
| .. note::
| ``.from_dict()`` is not a direct inverse of ``.to_dict()`` if
| you are working with repeated keys. A true inverse operation is
| ``{key: st.query_params.get_all(key) for key in st.query_params}``.
|
| Parameters
| ----------
| params: dict
| A dictionary used to replace the current query parameters.
|
| Examples
| --------
| >>> import streamlit as st
| >>>
| >>> st.query_params.from_dict({"foo": "bar", "baz": [1, "two"]})
|
| get_all(self, key: 'str') -> 'list[str]'
| Get a list of all query parameter values associated to a given key.
|
| When a key is repeated as a query parameter within the URL, this method
| allows all values to be obtained. In contrast, dict-like methods only
| retrieve the last value when a key is repeated in the URL.
|
| Parameters
| ----------
| key: str
| The label of the query parameter in the URL.
|
| Returns
| -------
| List[str]
| A list of values associated to the given key. May return zero, one,
| or multiple values.
|
| to_dict(self) -> 'dict[str, str]'
| Get all query parameters as a dictionary.
|
| This method primarily exists for internal use and is not needed for
| most cases. ``st.query_params`` returns an object that inherits from
| ``dict`` by default.
|
| When a key is repeated as a query parameter within the URL, this method
| will return only the last value of each unique key.
|
| Returns
| -------
| Dict[str,str]
| A dictionary of the current query parameters in the app's URL.
|
| update(self, params=(), /, **kwds) -> 'None'
| Update one or more values in query_params at once from a dictionary or
| dictionary-like object.
|
| See `Mapping.update()` from Python's `collections` library.
|
| Parameters
| ----------
| other: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]]
| A dictionary or mapping of strings to strings.
| **kwds: str
| Additional key/value pairs to update passed as keyword arguments.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| missing_attr_error_message(key: 'str') -> 'str'
| Returns a formatted error message for missing attributes.
|
| missing_key_error_message(key: 'str') -> 'str'
| Returns a formatted error message for missing keys.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __orig_bases__ = (collections.abc.MutableMapping[str, str],)
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.MutableMapping:
|
| pop(self, key, default=<object object at 0x000001E9463681F0>)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
| If key is not found, d is returned if given, otherwise KeyError is raised.
|
| popitem(self)
| D.popitem() -> (k, v), remove and return some (key, value) pair
| as a 2-tuple; but raise KeyError if D is empty.
|
| setdefault(self, key, default=None)
| D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Mapping:
|
| __contains__(self, key)
|
| __eq__(self, other)
| Return self==value.
|
| get(self, key, default=None)
| D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
|
| items(self)
| D.items() -> a set-like object providing a view on D's items
|
| keys(self)
| D.keys() -> a set-like object providing a view on D's keys
|
| values(self)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from collections.abc.Mapping:
|
| __hash__ = None
|
| __reversed__ = None
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Collection:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
streamlit.radio
Python Library Documentation: method radio in module streamlit.delta_generator
radio(label: 'str', options: 'OptionSequence[T]', index: 'int | None' = 0, format_func: 'Callable[[Any], Any]' = <class 'str'>, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, horizontal: 'bool' = False, captions: 'Sequence[str] | None' = None, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'T | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a radio button widget.
Parameters
----------
label : str
A short label explaining to the user what this radio group is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
options : Iterable
Labels for the select options in an ``Iterable``. This can be a
``list``, ``set``, or anything supported by ``st.dataframe``. If
``options`` is dataframe-like, the first column will be used. Each
label will be cast to ``str`` internally by default.
Labels can include markdown as described in the ``label`` parameter.
index : int or None
The index of the preselected option on first render. If ``None``,
will initialize empty and return ``None`` until the user selects an option.
Defaults to 0 (the first option).
format_func : function
Function to modify the display of radio options. It receives
the raw option as an argument and should output the label to be
shown for that option. This has no impact on the return value of
the radio.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this radio's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the radio button if set to
``True``. The default is ``False``.
horizontal : bool
An optional boolean, which orients the radio group horizontally.
The default is false (vertical buttons).
captions : iterable of str or None
A list of captions to show below each radio button. If None (default),
no captions are shown.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "content", "stretch", or int
The width of the radio button widget. This can be one of the
following:
- ``"content"`` (default): The width of the widget matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the widget matches the width of the
parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Invalid query parameter values are ignored and removed
from the URL. If ``index`` is ``None``, an empty query
parameter (e.g., ``?my_key=``) clears the widget.
Returns
-------
any
The selected option or ``None`` if no option is selected.
This is a copy of the selected option, not the original.
Examples
--------
>>> import streamlit as st
>>>
>>> genre = st.radio(
... "What's your favorite movie genre",
... [":rainbow[Comedy]", "***Drama***", "Documentary :movie_camera:"],
... captions=[
... "Laugh out loud.",
... "Get the popcorn.",
... "Never stop learning.",
... ],
... )
>>>
>>> if genre == ":rainbow[Comedy]":
... st.write("You selected comedy.")
... else:
... st.write("You didn't select comedy.")
.. output::
https://doc-radio.streamlit.app/
height: 300px
To initialize an empty radio widget, use ``None`` as the index value:
>>> import streamlit as st
>>>
>>> genre = st.radio(
... "What's your favorite movie genre",
... [":rainbow[Comedy]", "***Drama***", "Documentary :movie_camera:"],
... index=None,
... )
>>>
>>> st.write("You selected:", genre)
.. output::
https://doc-radio-empty.streamlit.app/
height: 300px
streamlit.rerun
Python Library Documentation: function rerun in module streamlit.commands.execution_control
rerun(*, scope: "Literal['app', 'fragment']" = 'app') -> 'NoReturn'
Rerun the script immediately.
When ``st.rerun()`` is called, Streamlit halts the current script run and
executes no further statements. Streamlit immediately queues the script to
rerun.
When using ``st.rerun`` in a fragment, you can scope the rerun to the
fragment. However, if a fragment is running as part of a full-app rerun,
a fragment-scoped rerun is not allowed.
Parameters
----------
scope : "app" or "fragment"
Specifies what part of the app should rerun. If ``scope`` is ``"app"``
(default), the full app reruns. If ``scope`` is ``"fragment"``,
Streamlit only reruns the fragment from which this command is called.
Setting ``scope="fragment"`` is only valid inside a fragment during a
fragment rerun. If ``st.rerun(scope="fragment")`` is called during a
full-app rerun or outside of a fragment, Streamlit will raise a
``StreamlitAPIException``.
streamlit.runtime
Python Library Documentation: package streamlit.runtime in streamlit
NAME
streamlit.runtime
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PACKAGE CONTENTS
app_session
caching (package)
connection_factory
context
context_util
credentials
download_data_util
forward_msg_cache
forward_msg_queue
fragment
media_file_manager
media_file_storage
memory_media_file_storage
memory_session_storage
memory_uploaded_file_manager
metrics_util
pages_manager
runtime
runtime_util
script_data
scriptrunner (package)
scriptrunner_utils (package)
secrets
session_manager
state (package)
stats
theme_util
uploaded_file_manager
websocket_session_manager
CLASSES
builtins.Exception(builtins.BaseException)
streamlit.runtime.session_manager.SessionClientDisconnectedError
builtins.object
streamlit.runtime.runtime.Runtime
streamlit.runtime.runtime.RuntimeConfig
enum.Enum(builtins.object)
streamlit.runtime.runtime.RuntimeState
typing.Protocol(typing.Generic)
streamlit.runtime.session_manager.SessionClient
class Runtime(builtins.object)
| Runtime(config: 'RuntimeConfig') -> 'None'
|
| Methods defined here:
|
| __init__(self, config: 'RuntimeConfig') -> 'None'
| Create a Runtime instance. It won't be started yet.
|
| Runtime is *not* thread-safe. Its public methods are generally
| safe to call only on the same thread that its event loop runs on.
|
| Parameters
| ----------
| config
| Config options.
|
| clear_user_info_for_session(self, session_id: 'str') -> 'None'
| Clear the user_info for the given session_id.
|
| Notes
| -----
| Threading: SAFE. May be called on any thread.
|
| close_session(self, session_id: 'str') -> 'None'
| Close and completely shut down a session.
|
| This differs from disconnect_session in that it always completely shuts down a
| session, permanently losing any associated state (session state, uploaded files,
| etc.).
|
| This function may be called multiple times for the same session,
| which is not an error. (Subsequent calls just no-op.)
|
| Parameters
| ----------
| session_id
| The session's unique ID.
|
| Notes
| -----
| Threading: UNSAFE. Must be called on the eventloop thread.
|
| connect_session(self, client: 'SessionClient', user_info: 'UserInfoType', existing_session_id: 'str | None' = None, session_id_override: 'str | None' = None) -> 'str'
| Create a new session (or connect to an existing one) and return its unique ID.
|
| Parameters
| ----------
| client
| A concrete SessionClient implementation for communicating with
| the session's client.
| user_info
| A dict that contains information about the session's user. For now,
| it only (optionally) contains the user's email address.
|
| {
| "email": "example@example.com"
| }
| existing_session_id
| The ID of an existing session to reconnect to. If one is not provided, a new
| session is created. Note that whether the Runtime's SessionManager supports
| reconnecting to an existing session depends on the SessionManager that this
| runtime is configured with.
| session_id_override
| The ID to assign to a new session being created with this method. Setting
| this can be useful when the service that a Streamlit Runtime is running in
| wants to tie the lifecycle of a Streamlit session to some other session-like
| object that it manages. Only one of existing_session_id and
| session_id_override should be set.
|
| Returns
| -------
| str
| The session's unique string ID.
|
| Notes
| -----
| Threading: UNSAFE. Must be called on the eventloop thread.
|
| create_session(self, client: 'SessionClient', user_info: 'UserInfoType', existing_session_id: 'str | None' = None, session_id_override: 'str | None' = None) -> 'str'
| Create a new session (or connect to an existing one) and return its unique ID.
|
| Notes
| -----
| This method is simply an alias for connect_session added for backwards
| compatibility.
|
| disconnect_session(self, session_id: 'str') -> 'None'
| Disconnect a session. It will stop producing ForwardMsgs.
|
| Differs from close_session because disconnected sessions can be reconnected to
| for a brief window (depending on the SessionManager/SessionStorage
| implementations used by the runtime).
|
| This function may be called multiple times for the same session,
| which is not an error. (Subsequent calls just no-op.)
|
| Parameters
| ----------
| session_id
| The session's unique ID.
|
| Notes
| -----
| Threading: UNSAFE. Must be called on the eventloop thread.
|
| async does_script_run_without_error(self) -> 'tuple[bool, str]'
| Load and execute the app's script to verify it runs without an error.
|
| Returns
| -------
| (True, "ok") if the script completes without error, or (False, err_msg)
| if the script raises an exception.
|
| Notes
| -----
| Threading: UNSAFE. Must be called on the eventloop thread.
|
| get_client(self, session_id: 'str') -> 'SessionClient | None'
| Get the SessionClient for the given session_id, or None
| if no such session exists.
|
| Notes
| -----
| Threading: SAFE. May be called on any thread.
|
| handle_backmsg(self, session_id: 'str', msg: 'BackMsg') -> 'None'
| Send a BackMsg to an active session.
|
| Parameters
| ----------
| session_id
| The session's unique ID.
| msg
| The BackMsg to deliver to the session.
|
| Notes
| -----
| Threading: UNSAFE. Must be called on the eventloop thread.
|
| handle_backmsg_deserialization_exception(self, session_id: 'str', exc: 'BaseException') -> 'None'
| Handle an Exception raised during deserialization of a BackMsg.
|
| Parameters
| ----------
| session_id
| The session's unique ID.
| exc
| The Exception.
|
| Notes
| -----
| Threading: UNSAFE. Must be called on the eventloop thread.
|
| is_active_session(self, session_id: 'str') -> 'bool'
| True if the session_id belongs to an active session.
|
| Notes
| -----
| Threading: SAFE. May be called on any thread.
|
| async start(self) -> 'None'
| Start the runtime. This must be called only once, before
| any other functions are called.
|
| When this coroutine returns, Streamlit is ready to accept new sessions.
|
| Notes
| -----
| Threading: UNSAFE. Must be called on the eventloop thread.
|
| stop(self) -> 'None'
| Request that Streamlit close all sessions and stop running.
| Note that Streamlit won't stop running immediately.
|
| Notes
| -----
| Threading: SAFE. May be called from any thread.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| exists() -> 'bool'
| True if the singleton Runtime instance has been created.
|
| When a Streamlit app is running in "raw mode" - that is, when the
| app is run via `python app.py` instead of `streamlit run app.py` -
| the Runtime will not exist, and various Streamlit functions need
| to adapt.
|
| instance() -> 'Runtime'
| Return the singleton Runtime instance. Raise an Error if the
| Runtime hasn't been created yet.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| bidi_component_registry
|
| cache_storage_manager
|
| component_registry
|
| is_ready_for_browser_connection
|
| media_file_mgr
|
| state
|
| stats_mgr
|
| stopped
| A Future that completes when the Runtime's run loop has exited.
|
| uploaded_file_mgr
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'_instance': 'Runtime | None'}
class RuntimeConfig(builtins.object)
| RuntimeConfig(script_path: 'str', media_file_storage: 'MediaFileStorage', uploaded_file_manager: 'UploadedFileManager', cache_storage_manager: 'CacheStorageManager' = <factory>, component_registry: 'BaseComponentRegistry' = <factory>, bidi_component_registry: 'BidiComponentManager' = <factory>, session_manager_class: 'type[SessionManager]' = <class 'streamlit.runtime.websocket_session_manager.WebsocketSessionManager'>, session_storage: 'SessionStorage' = <factory>, is_hello: 'bool' = False) -> None
|
| Config options for StreamlitRuntime.
|
| Methods defined here:
|
| __delattr__(self, name)
| Implement delattr(self, name).
|
| __eq__(self, other)
| Return self==value.
|
| __hash__(self)
| Return hash(self).
|
| __init__(self, script_path: 'str', media_file_storage: 'MediaFileStorage', uploaded_file_manager: 'UploadedFileManager', cache_storage_manager: 'CacheStorageManager' = <factory>, component_registry: 'BaseComponentRegistry' = <factory>, bidi_component_registry: 'BidiComponentManager' = <factory>, session_manager_class: 'type[SessionManager]' = <class 'streamlit.runtime.websocket_session_manager.WebsocketSessionManager'>, session_storage: 'SessionStorage' = <factory>, is_hello: 'bool' = False) -> None
| Initialize self. See help(type(self)) for accurate signature.
|
| __repr__(self)
| Return repr(self).
|
| __setattr__(self, name, value)
| Implement setattr(self, name, value).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'bidi_component_registry': 'BidiComponentManager', ...
|
| __dataclass_fields__ = {'bidi_component_registry': Field(name='bidi_co...
|
| __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,or...
|
| __match_args__ = ('script_path', 'media_file_storage', 'uploaded_file_...
|
| is_hello = False
|
| session_manager_class = <class 'streamlit.runtime.websocket_session_ma...
| A SessionManager used to manage sessions with lifecycles tied to those of a
| browser tab's websocket connection.
|
| WebsocketSessionManagers differentiate between "active" and "inactive" sessions.
| Active sessions are those with a currently active websocket connection. Inactive
| sessions are sessions without. Eventual cleanup of inactive sessions is a detail left
| to the specific SessionStorage that a WebsocketSessionManager is instantiated with.
class RuntimeState(enum.Enum)
| RuntimeState(*values)
|
| Method resolution order:
| RuntimeState
| enum.Enum
| builtins.object
|
| Data and other attributes defined here:
|
| INITIAL = <RuntimeState.INITIAL: 'INITIAL'>
|
| NO_SESSIONS_CONNECTED = <RuntimeState.NO_SESSIONS_CONNECTED: 'NO_SESSI...
|
| ONE_OR_MORE_SESSIONS_CONNECTED = <RuntimeState.ONE_OR_MORE_SESSIONS_CO...
|
| STOPPED = <RuntimeState.STOPPED: 'STOPPED'>
|
| STOPPING = <RuntimeState.STOPPING: 'STOPPING'>
|
| ----------------------------------------------------------------------
| Data descriptors inherited from enum.Enum:
|
| name
| The name of the Enum member.
|
| value
| The value of the Enum member.
|
| ----------------------------------------------------------------------
| Static methods inherited from enum.EnumType:
|
| __contains__(value)
| Return True if `value` is in `cls`.
|
| `value` is in `cls` if:
| 1) `value` is a member of `cls`, or
| 2) `value` is the value of one of the `cls`'s members.
|
| __getitem__(name)
| Return the member matching `name`.
|
| __iter__()
| Return members in definition order.
|
| __len__()
| Return the number of members (no aliases)
|
| ----------------------------------------------------------------------
| Readonly properties inherited from enum.EnumType:
|
| __members__
| Returns a mapping of member name->value.
|
| This mapping lists all enum members, including aliases. Note that this
| is a read-only view of the internal mapping.
class SessionClient(typing.Protocol)
| SessionClient(*args, **kwargs)
|
| Interface for sending data to a session's client.
|
| Method resolution order:
| SessionClient
| typing.Protocol
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__ = _no_init_or_replace_init(self, *args, **kwargs) from typing
|
| write_forward_msg(self, msg: 'ForwardMsg') -> 'None'
| Deliver a ForwardMsg to the client.
|
| If the SessionClient has been disconnected, it should raise a
| SessionClientDisconnectedError.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __subclasshook__ = _proto_hook(other) from typing
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| client_context
| The client's connection context (headers, cookies, IP).
|
| Returns None if request context information is not available.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset({'write_forward_msg'})
|
| __annotations__ = {}
|
| __parameters__ = ()
|
| __protocol_attrs__ = {'client_context', 'write_forward_msg'}
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Protocol:
|
| __init_subclass__(*args, **kwargs)
| Function to initialize subclasses.
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
class SessionClientDisconnectedError(builtins.Exception)
| Raised by operations on a disconnected SessionClient.
|
| Method resolution order:
| SessionClientDisconnectedError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
FUNCTIONS
exists() -> 'bool'
True if the singleton Runtime instance has been created.
When a Streamlit app is running in "raw mode" - that is, when the
app is run via `python app.py` instead of `streamlit run app.py` -
the Runtime will not exist, and various Streamlit functions need
to adapt.
get_instance() -> 'Runtime'
Return the singleton Runtime instance. Raise an Error if the
Runtime hasn't been created yet.
DATA
__all__ = ['Runtime', 'RuntimeConfig', 'RuntimeState', 'SessionClient'...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\runtime\__init__.py
streamlit.scatter_chart
Python Library Documentation: method scatter_chart in module streamlit.delta_generator
scatter_chart(data: 'Data' = None, *, x: 'str | None' = None, y: 'str | Sequence[str] | None' = None, x_label: 'str | None' = None, y_label: 'str | None' = None, color: 'str | Color | list[Color] | None' = None, size: 'str | float | int | None' = None, width: 'Width' = 'stretch', height: 'Height' = 'content', use_container_width: 'bool | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a scatterplot chart.
This is syntax-sugar around ``st.altair_chart``. The main difference
is this command uses the data's own column and indices to figure out
the chart's Altair spec. As a result this is easier to use for many
"just plot this" scenarios, while being less customizable.
Parameters
----------
data : Anything supported by st.dataframe
Data to be plotted.
x : str or None
Column name or key associated to the x-axis data. If ``x`` is
``None`` (default), Streamlit uses the data index for the x-axis
values.
y : str, Sequence of str, or None
Column name(s) or key(s) associated to the y-axis data. If this is
``None`` (default), Streamlit draws the data of all remaining
columns as data series. If this is a ``Sequence`` of strings,
Streamlit draws several series on the same chart by melting your
wide-format table into a long-format table behind the scenes.
x_label : str or None
The label for the x-axis. If this is ``None`` (default), Streamlit
will use the column name specified in ``x`` if available, or else
no label will be displayed.
y_label : str or None
The label for the y-axis. If this is ``None`` (default), Streamlit
will use the column name(s) specified in ``y`` if available, or
else no label will be displayed.
color : str, tuple, Sequence of str, Sequence of tuple, or None
The color of the circles representing each datapoint.
This can be:
- None, to use the default color.
- A hex string like "#ffaa00" or "#ffaa0088".
- An RGB or RGBA tuple with the red, green, blue, and alpha
components specified as ints from 0 to 255 or floats from 0.0 to
1.0.
- A built-in color name: "red", "orange", "yellow", "green",
"blue", "violet", "gray"/"grey", or "primary". These map to
theme colors that you can customize using ``theme.<color>Color``
configuration options.
- The name of a column in the dataset where the color of that
datapoint will come from.
If the values in this column are in one of the color formats
above (hex string or color tuple), then that color will be used.
Otherwise, the color will be automatically picked from the
default palette.
For example: if the dataset has 1000 rows, but this column only
contains the values "adult", "child", and "baby", then those 1000
datapoints be shown using three colors from the default palette.
But if this column only contains floats or ints, then those
1000 datapoints will be shown using a colors from a continuous
color gradient.
Finally, if this column only contains the values "#ffaa00",
"#f0f", "#0000ff", then then each of those 1000 datapoints will
be assigned "#ffaa00", "#f0f", or "#0000ff" as appropriate.
If the dataframe is in wide format (that is, y is a Sequence of
columns), this can also be:
- A list of string colors or color tuples to be used for each of
the series in the chart. This list should have the same length
as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
for three series). You can also use built-in color names in the
list (e.g. ``color=["red", "blue", "green"]``).
size : str, float, int, or None
The size of the circles representing each point.
This can be:
- A number like 100, to specify a single size to use for all
datapoints.
- The name of the column to use for the size. This allows each
datapoint to be represented by a circle of a different size.
width : "stretch", "content", or int
The width of the chart element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
height : "stretch", "content", or int
The height of the chart element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
use_container_width : bool or None
Whether to override the chart's native width with the width of
the parent container. This can be one of the following:
- ``None`` (default): Streamlit will use the chart's default behavior.
- ``True``: Streamlit sets the width of the chart to match the
width of the parent container.
- ``False``: Streamlit sets the width of the chart to fit its
contents according to the plotting library, up to the width of
the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
Examples
--------
**Example 1: Basic scatter chart from a dataframe**
If you don't use any of the optional parameters, Streamlit plots each
column as a color-coded group of points, uses the index as the x
values, and labels each group with the column name:
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(rng(0).standard_normal((20, 3)), columns=["a", "b", "c"])
>>>
>>> st.scatter_chart(df)
.. output::
https://doc-scatter-chart.streamlit.app/
height: 440px
**Example 2: Scatter chart from specific dataframe columns**
You can choose different columns to use for the x and y values. If your
dataframe is in long format (all y-values in one column), you can set
the scatter point colors from another column.
If the column contains color strings, the colors will be applied
directly and each color group will be unlabeled. If the column contains
other values, those values will label each group, and the scatter point
colors will be selected from the default color palette. You can
configure this color palette in the ``theme.chartCategoryColors``
configuration option.
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... rng(0).standard_normal((20, 3)), columns=["col1", "col2", "col3"]
... )
>>> df["col4"] = rng(0).choice(["a", "b", "c"], 20)
>>>
>>> st.scatter_chart(
... df,
... x="col1",
... y="col2",
... color="col4",
... size="col3",
... )
.. output::
https://doc-scatter-chart1.streamlit.app/
height: 440px
**Example 3: Scatter chart from wide-format dataframe**
If your dataframe is in wide format (y-values are in multiple columns),
you can pass a list of columns to the ``y`` parameter. Each column
name becomes a group label. To override the default colors, pass a
list of colors to the ``color`` parameter, one for each group:
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(
... rng(0).standard_normal((20, 4)),
... columns=["col1", "col2", "col3", "col4"],
... )
>>>
>>> st.scatter_chart(
... df,
... x="col1",
... y=["col2", "col3"],
... size="col4",
... color=["#FF0000", "#0000FF"],
... )
.. output::
https://doc-scatter-chart2.streamlit.app/
height: 440px
streamlit.secrets
Python Library Documentation: Secrets in module streamlit.runtime.secrets object class Secrets(collections.abc.Mapping) | Secrets() -> 'None' | | A dict-like class that stores secrets. | Parses secrets.toml on-demand. Cannot be externally mutated. | | Safe to use from multiple threads. | | Method resolution order: | Secrets | collections.abc.Mapping | collections.abc.Collection | collections.abc.Sized | collections.abc.Iterable | collections.abc.Container | builtins.object | | Methods defined here: | | __contains__(self, key: 'Any') -> 'bool' | True if the given key is in the dict. Thread-safe. | | __getattr__(self, key: 'str') -> 'Any' | Return the value with the given key. If no such key | exists, raise an AttributeError. | | Thread-safe. | | __getitem__(self, key: 'str') -> 'Any' | Return the value with the given key. If no such key | exists, raise a KeyError. | | Thread-safe. | | __init__(self) -> 'None' | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self) -> 'Iterator[str]' | An iterator over the keys in the dict. Thread-safe. | | __len__(self) -> 'int' | The number of entries in the dict. Thread-safe. | | __repr__(self) -> 'str' | A string representation of the contents of the dict. Thread-safe. | | __setattr__(self, key: 'str', value: 'Any') -> 'None' | Implement setattr(self, name, value). | | has_key(self, k: 'str') -> 'bool' | True if the given key is in the dict. Thread-safe. | | items(self) -> 'ItemsView[str, Any]' | A view of the key-value items in the dict. Thread-safe. | | keys(self) -> 'KeysView[str]' | A view of the keys in the dict. Thread-safe. | | load_if_toml_exists(self) -> 'bool' | Load secrets.toml files from disk if they exists. If none exist, | no exception will be raised. (If a file exists but is malformed, | an exception *will* be raised.). | | Returns True if a secrets.toml file was successfully parsed, False otherwise. | | Thread-safe. | | merge_programmatic_secrets(self, programmatic_secrets: 'Mapping[str, SecretsValue]') -> 'None' | Merge programmatic secrets into the secrets store. | | Programmatic secrets are shallow-merged with file-based secrets at the | top level: entire top-level keys are replaced, not individual nested keys. | | Parameters | ---------- | programmatic_secrets | A dictionary of secrets to merge. Supported value types are: | ``str``, ``int``, ``float``, ``bool``, and nested ``dict``. | | Raises | ------ | TypeError | If any value in the dictionary has an unsupported type. | | Notes | ----- | This method is intended to be called once during application startup, | after file-based secrets have been loaded. It is thread-safe. | | Top-level ``str``, ``int``, and ``float`` values are promoted to | ``os.environ`` (as strings), matching the behavior of file-based secrets. | | set_suppress_print_error_on_exception(self, suppress_print_error_on_exception: 'bool') -> 'None' | Left in place for compatibility with integrations until integration | code can be updated. | | to_dict(self) -> 'dict[str, Any]' | Converts the secrets store into a nested dictionary, where nested AttrDict objects are | also converted into dictionaries. | | values(self) -> 'ValuesView[Any]' | A view of the values in the dict. Thread-safe. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __abstractmethods__ = frozenset() | | __orig_bases__ = (collections.abc.Mapping[str, typing.Any],) | | ---------------------------------------------------------------------- | Methods inherited from collections.abc.Mapping: | | __eq__(self, other) | Return self==value. | | get(self, key, default=None) | D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. | | ---------------------------------------------------------------------- | Data and other attributes inherited from collections.abc.Mapping: | | __hash__ = None | | __reversed__ = None | | ---------------------------------------------------------------------- | Class methods inherited from collections.abc.Collection: | | __subclasshook__(C) | Abstract classes can override this to customize issubclass(). | | This is invoked early on by abc.ABCMeta.__subclasscheck__(). | It should return True, False or NotImplemented. If it returns | NotImplemented, the normal algorithm is used. Otherwise, it | overrides the normal algorithm (and the outcome is cached). | | ---------------------------------------------------------------------- | Class methods inherited from collections.abc.Iterable: | | __class_getitem__ = GenericAlias(...) | Represent a PEP 585 generic type | | E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
streamlit.segmented_control
Python Library Documentation: method segmented_control in module streamlit.delta_generator
segmented_control(label: 'str', options: 'OptionSequence[V]', *, selection_mode: "Literal['single', 'multi']" = 'single', default: 'Sequence[V] | V | None' = None, required: 'bool' = False, format_func: 'Callable[[Any], str] | None' = None, key: 'str | int | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'list[V] | V | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a segmented control widget.
A segmented control widget is a linear set of segments where each of
the passed ``options`` functions like a toggle button.
Parameters
----------
label : str
A short label explaining to the user what this widget is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
options : Iterable of V
Labels for the select options in an ``Iterable``. This can be a
``list``, ``set``, or anything supported by ``st.dataframe``. If
``options`` is dataframe-like, the first column will be used. Each
label will be cast to ``str`` internally by default and can
optionally contain GitHub-flavored Markdown, including the Markdown
directives described in the ``body`` parameter of ``st.markdown``.
selection_mode : "single" or "multi"
The selection mode for the widget. If this is ``"single"``
(default), only one option can be selected. If this is ``"multi"``,
multiple options can be selected.
default : Iterable of V, V, or None
The value of the widget when it first renders. If the
``selection_mode`` is ``multi``, this can be a list of values, a
single value, or ``None``. If the ``selection_mode`` is
``"single"``, this can be a single value or ``None``.
required : bool
Whether a selection is required. If this is ``True`` and
``selection_mode="single"``, users cannot deselect an option once
one is selected. Clicking an already-selected option does nothing.
The default is ``False``.
If ``required=True`` is used with ``selection_mode="multi"``, an
exception is raised.
format_func : function
Function to modify the display of the options. It receives
the raw option as an argument and should output the label to be
shown for that option. This has no impact on the return value of
the command. The output can optionally contain GitHub-flavored
Markdown, including the Markdown directives described in the
``body`` parameter of ``st.markdown``.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``selection_mode`` resets the widget even when a
key is provided.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this widget's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the widget if set to ``True``.
The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "content", "stretch", or int
The width of the segmented control widget. This can be one of the
following:
- ``"content"`` (default): The width of the widget matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the widget matches the width of the
parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
An empty query parameter (e.g., ``?tags=``) clears the
widget. Invalid query parameter values are ignored and removed from
the URL. For ``selection_mode="multi"``, multiple selections use
repeated parameters (e.g., ``?tags=Red&tags=Blue``) and duplicates
are deduplicated.
Returns
-------
list of V, V, or None
If the ``selection_mode`` is ``multi``, this is a list of selected
options or an empty list. If the ``selection_mode`` is
``"single"``, this is a selected option or ``None``.
This contains copies of the selected options, not the originals.
Examples
--------
**Example 1: Multi-select segmented control**
Display a multi-select segmented control widget, and show the
selection:
>>> import streamlit as st
>>>
>>> options = ["North", "East", "South", "West"]
>>> selection = st.segmented_control(
... "Directions", options, selection_mode="multi"
... )
>>> st.markdown(f"Your selected options: {selection}.")
.. output::
https://doc-segmented-control-multi.streamlit.app/
height: 200px
**Example 2: Single-select segmented control with icons**
Display a single-select segmented control widget with icons:
>>> import streamlit as st
>>>
>>> option_map = {
... 0: ":material/add:",
... 1: ":material/zoom_in:",
... 2: ":material/zoom_out:",
... 3: ":material/zoom_out_map:",
... }
>>> selection = st.segmented_control(
... "Tool",
... options=option_map.keys(),
... format_func=lambda option: option_map[option],
... selection_mode="single",
... )
>>> st.write(
... "Your selected option: "
... f"{None if selection is None else option_map[selection]}"
... )
.. output::
https://doc-segmented-control-single.streamlit.app/
height: 200px
streamlit.select_slider
Python Library Documentation: method select_slider in module streamlit.delta_generator
select_slider(label: 'str', options: 'OptionSequence[T]' = (), value: 'T | Sequence[T] | None' = None, format_func: 'Callable[[Any], Any]' = <class 'str'>, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'T | tuple[T, T]' method of streamlit.delta_generator.DeltaGenerator instance
Display a slider widget to select items from a list.
This also allows you to render a range slider by passing a two-element
tuple or list as the ``value``.
The difference between ``st.select_slider`` and ``st.slider`` is that
``select_slider`` accepts any datatype and takes an iterable set of
options, while ``st.slider`` only accepts numerical or date/time data and
takes a range as input.
Parameters
----------
label : str
A short label explaining to the user what this slider is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
options : Iterable
Labels for the select options in an ``Iterable``. This can be a
``list``, ``set``, or anything supported by ``st.dataframe``. If
``options`` is dataframe-like, the first column will be used. Each
label will be cast to ``str`` internally by default.
Each item in the iterable can optionally contain GitHub-flavored
Markdown, subject to the same limitations described in the
``label`` parameter.
value : a supported type or a tuple/list of supported types or None
The value of the slider when it first renders. If a tuple/list
of two values is passed here, then a range slider with those lower
and upper bounds is rendered. For example, if set to `(1, 10)` the
slider will have a selectable range between 1 and 10.
Defaults to first option.
format_func : function
Function to modify the display of the labels from the options.
argument. It receives the option as an argument and its output
will be cast to str.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this select_slider's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the select slider if set to
``True``. The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "stretch" or int
The width of the slider widget. This can be one of the
following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Invalid query parameter values are ignored and removed
from the URL. Range select sliders use repeated parameters
(e.g., ``?color=red&color=blue``).
Returns
-------
any value or tuple of any value
The current value of the slider widget. The return type will match
the data type of the value parameter.
This contains copies of the selected options, not the originals.
Examples
--------
>>> import streamlit as st
>>>
>>> color = st.select_slider(
... "Select a color of the rainbow",
... options=[
... "red",
... "orange",
... "yellow",
... "green",
... "blue",
... "indigo",
... "violet",
... ],
... )
>>> st.write("My favorite color is", color)
And here's an example of a range select slider:
>>> import streamlit as st
>>>
>>> start_color, end_color = st.select_slider(
... "Select a range of color wavelength",
... options=[
... "red",
... "orange",
... "yellow",
... "green",
... "blue",
... "indigo",
... "violet",
... ],
... value=("red", "blue"),
... )
>>> st.write("You selected wavelengths between", start_color, "and", end_color)
.. output::
https://doc-select-slider.streamlit.app/
height: 450px
streamlit.selectbox
Python Library Documentation: method selectbox in module streamlit.delta_generator
selectbox(label: 'str', options: 'OptionSequence[T]', index: 'int | None' = 0, format_func: 'Callable[[Any], str]' = <class 'str'>, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, placeholder: 'str | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', accept_new_options: 'bool' = False, filter_mode: 'SelectWidgetFilterMode' = 'fuzzy', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'T | str | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a select widget.
Parameters
----------
label : str
A short label explaining to the user what this select widget is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
options : Iterable
Labels for the select options in an ``Iterable``. This can be a
``list``, ``set``, or anything supported by ``st.dataframe``. If
``options`` is dataframe-like, the first column will be used. Each
label will be cast to ``str`` internally by default.
index : int or None
The index of the preselected option on first render. If ``None``,
will initialize empty and return ``None`` until the user selects an option.
Defaults to 0 (the first option).
format_func : function
Function to modify the display of the options. It receives
the raw option as an argument and should output the label to be
shown for that option. This has no impact on the return value of
the command.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``accept_new_options`` resets the widget even when
a key is provided.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this selectbox's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
placeholder : str or None
A string to display when no options are selected.
If this is ``None`` (default), the widget displays placeholder text
based on the widget's configuration:
- "Choose an option" is displayed when options are available and
``accept_new_options=False``.
- "Choose or add an option" is displayed when options are available
and ``accept_new_options=True``.
- "Add an option" is displayed when no options are available and
``accept_new_options=True``.
- "No options to select" is displayed when no options are available
and ``accept_new_options=False``. The widget is also disabled in
this case.
disabled : bool
An optional boolean that disables the selectbox if set to ``True``.
The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
accept_new_options : bool
Whether the user can add a selection that isn't included in ``options``.
If this is ``False`` (default), the user can only select from the
items in ``options``. If this is ``True``, the user can enter a new
item that doesn't exist in ``options``.
When a user enters a new item, it is returned by the widget as a
string. The new item is not added to the widget's drop-down menu.
Streamlit will use a case-insensitive match from ``options`` before
adding a new item.
filter_mode : "fuzzy", "contains", "prefix", or None
The matching mode used to filter options while the user types.
If this is ``"fuzzy"`` (default), options are matched by in-order
subsequence and sorted by match score. If this is ``"contains"``,
options are matched by case-insensitive substring. If this is
``"prefix"``, options are matched by case-insensitive prefix. If
this is ``None``, typing is disabled and the options are not
filtered.
``filter_mode=None`` is incompatible with
``accept_new_options=True``.
width : "stretch" or int
The width of the selectbox widget. This can be one of the
following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Invalid query parameter values are ignored and removed
from the URL. If ``index`` is ``None``, an empty query
parameter (e.g., ``?my_key=``) clears the widget.
Returns
-------
any
The selected option or ``None`` if no option is selected.
This is a copy of the selected option, not the original.
Examples
--------
**Example 1: Use a basic selectbox widget**
If no index is provided, the first option is selected by default.
>>> import streamlit as st
>>>
>>> option = st.selectbox(
... "How would you like to be contacted?",
... ("Email", "Home phone", "Mobile phone"),
... )
>>>
>>> st.write("You selected:", option)
.. output::
https://doc-selectbox.streamlit.app/
height: 320px
**Example 2: Use a selectbox widget with no initial selection**
To initialize an empty selectbox, use ``None`` as the index value.
>>> import streamlit as st
>>>
>>> option = st.selectbox(
... "How would you like to be contacted?",
... ("Email", "Home phone", "Mobile phone"),
... index=None,
... placeholder="Select contact method...",
... )
>>>
>>> st.write("You selected:", option)
.. output::
https://doc-selectbox-empty.streamlit.app/
height: 320px
**Example 3: Let users add a new option**
To allow users to add a new option that isn't included in the
``options`` list, use the ``accept_new_options=True`` parameter. You
can also customize the placeholder text.
>>> import streamlit as st
>>>
>>> option = st.selectbox(
... "Default email",
... ["foo@example.com", "bar@example.com", "baz@example.com"],
... index=None,
... placeholder="Select a saved email or enter a new one",
... accept_new_options=True,
... )
>>>
>>> st.write("You selected:", option)
.. output::
https://doc-selectbox-accept-new-options.streamlit.app/
height: 320px
streamlit.session_state
Python Library Documentation: SessionStateProxy in module streamlit.runtime.state.session_state_proxy object class SessionStateProxy(collections.abc.MutableMapping) | A stateless singleton that proxies `st.session_state` interactions | to the current script thread's SessionState instance. | | The proxy API differs slightly from SessionState: it does not allow | callers to get, set, or iterate over "keyless" widgets (that is, widgets | that were created without a user_key, and have autogenerated keys). | | Method resolution order: | SessionStateProxy | collections.abc.MutableMapping | collections.abc.Mapping | collections.abc.Collection | collections.abc.Sized | collections.abc.Iterable | collections.abc.Container | builtins.object | | Methods defined here: | | __delattr__(self, key: 'str') -> 'None' | Implement delattr(self, name). | | __delitem__(self, key: 'Key') -> 'None' | Delete the value with the given key. | | Raises | ------ | StreamlitAPIException | If the key is not a valid SessionState user key. | | __getattr__(self, key: 'str') -> 'Any' | | __getitem__(self, key: 'Key') -> 'Any' | Return the state or widget value with the given key. | | Raises | ------ | StreamlitAPIException | If the key is not a valid SessionState user key. | | __iter__(self) -> 'Iterator[Any]' | Iterator over user state and keyed widget values. | | __len__(self) -> 'int' | Number of user state and keyed widget values in session_state. | | __setattr__(self, key: 'str', value: 'Any') -> 'None' | Implement setattr(self, name, value). | | __setitem__(self, key: 'Key', value: 'Any') -> 'None' | Set the value of the given key. | | Raises | ------ | StreamlitAPIException | If the key is not a valid SessionState user key. | | __str__(self) -> 'str' | String representation of user state and keyed widget values. | | to_dict(self) -> 'dict[str, Any]' | Return a dict containing all session_state and keyed widget values. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __abstractmethods__ = frozenset() | | __orig_bases__ = (collections.abc.MutableMapping[str | int, typing.Any... | | ---------------------------------------------------------------------- | Methods inherited from collections.abc.MutableMapping: | | clear(self) | D.clear() -> None. Remove all items from D. | | pop(self, key, default=<object object at 0x000001E9463681F0>) | D.pop(k[,d]) -> v, remove specified key and return the corresponding value. | If key is not found, d is returned if given, otherwise KeyError is raised. | | popitem(self) | D.popitem() -> (k, v), remove and return some (key, value) pair | as a 2-tuple; but raise KeyError if D is empty. | | setdefault(self, key, default=None) | D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D | | update(self, other=(), /, **kwds) | D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. | If E present and has a .keys() method, does: for k in E: D[k] = E[k] | If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v | In either case, this is followed by: for k, v in F.items(): D[k] = v | | ---------------------------------------------------------------------- | Methods inherited from collections.abc.Mapping: | | __contains__(self, key) | | __eq__(self, other) | Return self==value. | | get(self, key, default=None) | D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. | | items(self) | D.items() -> a set-like object providing a view on D's items | | keys(self) | D.keys() -> a set-like object providing a view on D's keys | | values(self) | D.values() -> an object providing a view on D's values | | ---------------------------------------------------------------------- | Data and other attributes inherited from collections.abc.Mapping: | | __hash__ = None | | __reversed__ = None | | ---------------------------------------------------------------------- | Class methods inherited from collections.abc.Collection: | | __subclasshook__(C) | Abstract classes can override this to customize issubclass(). | | This is invoked early on by abc.ABCMeta.__subclasscheck__(). | It should return True, False or NotImplemented. If it returns | NotImplemented, the normal algorithm is used. Otherwise, it | overrides the normal algorithm (and the outcome is cached). | | ---------------------------------------------------------------------- | Class methods inherited from collections.abc.Iterable: | | __class_getitem__ = GenericAlias(...) | Represent a PEP 585 generic type | | E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
streamlit.set_option
Python Library Documentation: function set_user_option in module streamlit.config
set_user_option(key: 'str', value: 'Any') -> 'None'
Set a configuration option.
Currently, only ``client`` configuration options can be set within the
script itself:
- ``client.showErrorDetails``
- ``client.showSidebarNavigation``
- ``client.toolbarMode``
Calling ``st.set_option`` with any other option will raise a
``StreamlitAPIException``. When changing a configuration option in a
running app, you may need to trigger a rerun after changing the option to
see the effects.
Run ``streamlit config show`` in a terminal to see all available options.
Parameters
----------
key : str
The config option key of the form "section.optionName". To see all
available options, run ``streamlit config show`` in a terminal.
value
The new value to assign to this config option.
Examples
--------
>>> import streamlit as st
>>>
>>> st.set_option("client.showErrorDetails", True)
streamlit.set_page_config
Python Library Documentation: function set_page_config in module streamlit.commands.page_config
set_page_config(page_title: 'str | None' = None, page_icon: 'PageIcon | None' = None, layout: 'Layout | None' = None, initial_sidebar_state: 'InitialSideBarState | None' = None, menu_items: 'MenuItems | None' = None) -> 'None'
Configure the default settings of the page.
This command can be called multiple times in a script run to dynamically
change the page configuration. The calls are additive, with each successive
call overriding only the parameters that are specified.
Parameters
----------
page_title: str or None
The page title, shown in the browser tab. If this is ``None``
(default), the page title is inherited from the previous call of
``st.set_page_config``. If this is ``None`` and no previous call
exists, the page title is inferred from the page source.
If a page source is a Python file, its inferred title is derived from
the filename. If a page source is a callable object, its inferred title
is derived from the callable's name.
page_icon : Anything supported by st.image (except list), str, or None
The page favicon. If ``page_icon`` is ``None`` (default), the page icon
is inherited from the previous call of ``st.set_page_config``. If this
is ``None`` and no previous call exists, the favicon is a monochrome
Streamlit logo.
In addition to the types supported by |st.image|_ (except list), the
following strings are valid:
- A single-character emoji. For example, you can set ``page_icon="🦈"``.
- An emoji short code. For example, you can set ``page_icon=":shark:"``.
For a list of all supported codes, see
https://share.streamlit.io/streamlit/emoji-shortcodes.
- The string literal, ``"random"``. You can set ``page_icon="random"``
to set a random emoji from the supported list above.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``page_icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
.. note::
Colors are not supported for Material icons. When you use a
Material icon for favicon, it will be black, regardless of browser
theme.
.. |st.image| replace:: ``st.image``
.. _st.image: https://docs.streamlit.io/develop/api-reference/media/st.image
layout: "centered", "wide", or None
Layout of the page content. The following layouts are supported:
- ``None`` (default): The page layout is inherited from the previous
call of ``st.set_page_config``. If no previous call exists, the page
layout is ``"centered"``.
- ``"centered"``: Page elements are constrained to a centered column of
fixed width.
- ``"wide"``: Page elements use the entire screen width.
initial_sidebar_state: "auto", "expanded", "collapsed", int, or None
Initial state of the sidebar. The following states are supported:
- ``None`` (default): The sidebar state is inherited from the previous
call of ``st.set_page_config``. If no previous call exists, the
sidebar state is ``"auto"``.
- ``"auto"``: The sidebar is hidden on small devices and shown
otherwise.
- ``"expanded"``: The sidebar is shown initially.
- ``"collapsed"``: The sidebar is hidden initially.
- ``int``: The sidebar will use ``"auto"`` behavior but start with the
specified width in pixels. The width must be between 200 and 600
pixels, inclusive.
In most cases, ``"auto"`` provides the best user experience across
devices of different sizes.
menu_items: dict
Configure the menu that appears on the top-right side of this app.
The keys in this dict denote the menu item to configure. The following
keys can have string or ``None`` values:
- "Get help": The URL this menu item should point to.
- "Report a Bug": The URL this menu item should point to.
- "About": A markdown string to show in the About dialog.
A URL may also refer to an email address e.g. ``mailto:john@example.com``.
If you do not include a key, its menu item will be hidden (unless it
was set by a previous call to ``st.set_page_config``). To remove an
item that was specified in a previous call to ``st.set_page_config``,
set its value to ``None`` in the dictionary.
Examples
--------
>>> import streamlit as st
>>>
>>> st.set_page_config(
... page_title="Ex-stream-ly Cool App",
... page_icon="🧊",
... layout="wide",
... initial_sidebar_state="expanded",
... menu_items={
... 'Get Help': 'https://www.extremelycoolapp.com/help',
... 'Report a bug': "https://www.extremelycoolapp.com/bug",
... 'About': "# This is a header. This is an *extremely* cool app!"
... }
... )
streamlit.sidebar
Python Library Documentation: DeltaGenerator in module streamlit.delta_generator wrapper(*args: 'Any', **kwargs: 'Any') -> 'NoReturn'
streamlit.slider
Python Library Documentation: method slider in module streamlit.delta_generator
slider(label: 'str', min_value: 'SliderScalar | None' = None, max_value: 'SliderScalar | None' = None, value: 'SliderValue | None' = None, step: 'SliderStep | None' = None, format: 'str | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'Any' method of streamlit.delta_generator.DeltaGenerator instance
Display a slider widget.
This supports int, float, date, time, and datetime types.
This also allows you to render a range slider by passing a two-element
tuple or list as the ``value``.
The difference between ``st.slider`` and ``st.select_slider`` is that
``slider`` only accepts numerical or date/time data and takes a range as
input, while ``select_slider`` accepts any datatype and takes an iterable
set of options.
.. note::
Integer values exceeding +/- ``(1<<53) - 1`` cannot be accurately
stored or returned by the widget due to serialization constraints
between the Python server and JavaScript client. You must handle
such numbers as floats, leading to a loss in precision.
Parameters
----------
label : str
A short label explaining to the user what this slider is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
min_value : a supported type or None
The minimum permitted value.
If this is ``None`` (default), the minimum value depends on the
type as follows:
- integer: ``0``
- float: ``0.0``
- date or datetime: ``value - timedelta(days=14)``
- time: ``time.min``
max_value : a supported type or None
The maximum permitted value.
If this is ``None`` (default), the maximum value depends on the
type as follows:
- integer: ``100``
- float: ``1.0``
- date or datetime: ``value + timedelta(days=14)``
- time: ``time.max``
value : a supported type or a tuple/list of supported types or None
The value of the slider when it first renders. If a tuple/list
of two values is passed here, then a range slider with those lower
and upper bounds is rendered. For example, if set to `(1, 10)` the
slider will have a selectable range between 1 and 10.
This defaults to ``min_value``. If the type is not otherwise
specified in any of the numeric parameters, the widget will have an
integer value.
step : int, float, timedelta, or None
The stepping interval.
Defaults to 1 if the value is an int, 0.01 if a float,
timedelta(days=1) if a date/datetime, timedelta(minutes=15) if a time
(or if max_value - min_value < 1 day)
format : str or None
A printf-style format string or a predefined format name controlling
how the interface should display values. This does not impact the
return value.
For integers and floats, you can use a printf-style format string
or one of the following predefined formats:
- ``"plain"``: Show the full number without formatting (e.g. ``1234.567``).
- ``"localized"``: Show the number in the user's locale format (e.g. ``1,234.567``).
- ``"percent"``: Show as a percentage (e.g. ``50%`` from ``0.5``).
- ``"dollar"``: Show as US dollars (e.g. ``$1,234.57``).
- ``"euro"``: Show as euros (e.g. ``€1,234.57``).
- ``"yen"``: Show as Japanese yen (e.g. ``¥1,235``).
- ``"compact"``: Show in compact notation (e.g. ``1.2K``).
- ``"scientific"``: Show in scientific notation (e.g. ``1.235E3``).
- ``"engineering"``: Show in engineering notation (e.g. ``1.235E3``).
- ``"accounting"``: Show in accounting format with parentheses for negatives.
- ``"bytes"``: Show in byte units (e.g. ``1.2KB``).
For information about printf-style format strings, see
`sprintf.js
<https://github.com/alexei/sprintf.js?tab=readme-ov-file#format-specification>`_.
For example, ``format="%0.1f"`` adjusts the displayed decimal
precision to only show one digit after the decimal. Use ``,`` for
thousand separators (e.g. ``"%,d"`` yields ``"1,234"``).
For datetimes, dates, and times, you can use a momentJS format string
or one of the following predefined formats:
- ``"localized"``: Show in the user's locale format.
- ``"distance"``: Show as relative time (e.g. ``"2 hours ago"``).
- ``"calendar"``: Show as calendar time (e.g. ``"Tomorrow 12:00"``).
Works best with datetime values. For date-only values, displays
relative day names (e.g. ``"Yesterday"``). For time-only values,
this format may produce unexpected results.
- ``"iso8601"``: Show in ISO 8601 format.
For information about momentJS format strings, see
`momentJS <https://momentjs.com/docs/#/displaying/format/>`_.
For example, ``format="ddd ha"`` adjusts the displayed datetime to
show the day of the week and the hour ("Tue 8pm").
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``min_value``, ``max_value``, or ``step`` resets
the widget even when a key is provided, because those
parameters constrain valid values.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this slider's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the slider if set to ``True``.
The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "stretch" or int
The width of the slider widget. This can be one of the
following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Invalid query parameter values are ignored and removed
from the URL. Range sliders use repeated parameters (e.g.,
``?price=10&price=90``).
Returns
-------
int/float/date/time/datetime or tuple of int/float/date/time/datetime
The current value of the slider widget. The return type will match
the data type of the value parameter.
Examples
--------
>>> import streamlit as st
>>>
>>> age = st.slider("How old are you?", 0, 130, 25)
>>> st.write("I'm ", age, "years old")
And here's an example of a range slider:
>>> import streamlit as st
>>>
>>> values = st.slider("Select a range of values", 0.0, 100.0, (25.0, 75.0))
>>> st.write("Values:", values)
This is a range time slider:
>>> import streamlit as st
>>> from datetime import time
>>>
>>> appointment = st.slider(
... "Schedule your appointment:", value=(time(11, 30), time(12, 45))
... )
>>> st.write("You're scheduled for:", appointment)
Finally, a datetime slider:
>>> import streamlit as st
>>> from datetime import datetime
>>>
>>> start_time = st.slider(
... "When do you start?",
... value=datetime(2020, 1, 1, 9, 30),
... format="MM/DD/YY - hh:mm",
... )
>>> st.write("Start time:", start_time)
.. output::
https://doc-slider.streamlit.app/
height: 300px
streamlit.snow
Python Library Documentation: method snow in module streamlit.delta_generator
snow() -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Draw celebratory snowfall.
Examples
--------
>>> import streamlit as st
>>>
>>> st.snow()
...then watch your app and get ready for a cool celebration!
streamlit.source_util
Python Library Documentation: module streamlit.source_util in streamlit
NAME
streamlit.source_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CLASSES
builtins.dict(builtins.object)
PageInfo
class PageInfo(builtins.dict)
| Method resolution order:
| PageInfo
| builtins.dict
| builtins.object
|
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'icon': ForwardRef('NotRequired[Icon]', module='str...
|
| __optional_keys__ = frozenset()
|
| __orig_bases__ = (<function TypedDict>,)
|
| __required_keys__ = frozenset({'icon', 'page_name', 'page_script_hash'...
|
| __total__ = True
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.dict:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| D.clear() -> None. Remove all items from D.
|
| copy(...)
| D.copy() -> a shallow copy of D
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| pop(...)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(...)
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods inherited from builtins.dict:
|
| __class_getitem__(...)
| See PEP 585
|
| fromkeys(iterable, value=None, /)
| Create a new dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.dict:
|
| __new__(*args, **kwargs) class method of builtins.dict
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from builtins.dict:
|
| __hash__ = None
FUNCTIONS
open_python_file(filename: 'str') -> 'TextIO'
Open a read-only Python file taking proper care of its encoding.
In Python 3, we would like all files to be opened with utf-8 encoding.
However, some author like to specify PEP263 headers in their source files
with their own encodings. In that case, we should respect the author's
encoding.
page_icon_and_name(script_path: 'Path') -> 'tuple[str, str]'
Compute the icon and name of a page from its script path.
This is *almost* the page name displayed in the nav UI, but it has
underscores instead of spaces. The reason we do this is because having
spaces in URLs both looks bad and is hard to deal with due to the need to
URL-encode them. To solve this, we only swap the underscores for spaces
right before we render page names.
page_sort_key(script_path: 'Path') -> 'tuple[float, str]'
DATA
NotRequired = typing.NotRequired
Special typing construct to mark a TypedDict key as potentially missing.
For example::
class Movie(TypedDict):
title: str
year: NotRequired[int]
m = Movie(
title='The Matrix', # typechecker error if key is omitted
year=1999,
)
PAGE_FILENAME_REGEX = re.compile('([0-9]*)[_ -]*(.*)\\.py')
TYPE_CHECKING = False
TypeAlias = typing.TypeAlias
Special form for marking type aliases.
Use TypeAlias to indicate that an assignment should
be recognized as a proper type alias definition by type
checkers.
For example::
Predicate: TypeAlias = Callable[..., bool]
It's invalid when used anywhere except as in the example above.
__annotations__ = {'Icon': 'TypeAlias', 'PageHash': 'TypeAlias', 'Page...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\source_util.py
streamlit.space
Python Library Documentation: method space in module streamlit.delta_generator
space(size: 'SpaceSize' = 'small') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Add vertical or horizontal space.
This command adds space in the direction of its parent container. In
a vertical layout, it adds vertical space. In a horizontal layout, it
adds horizontal space.
Parameters
----------
size : "xxsmall", "xsmall", "small", "medium", "large", "xlarge", "xxlarge", "stretch", or int
The size of the space. This can be one of the following values:
- ``"xxsmall"``: 0.25rem, matching the ``"xxsmall"`` gap in
``st.container`` and ``st.columns``.
- ``"xsmall"``: 0.5rem, matching the ``"xsmall"`` gap in
``st.container`` and ``st.columns``.
- ``"small"`` (default): 0.75rem, which is the height of a widget
label. This is useful for aligning buttons with labeled widgets.
- ``"medium"``: 2.5rem, which is the height of a button or
(unlabeled) input field.
- ``"large"``: 4.25rem, which is the height of a labeled input
field or unlabeled media widget, like ``st.file_uploader``.
- ``"xlarge"``: 6rem, matching the ``"xlarge"`` gap in
``st.container`` and ``st.columns``.
- ``"xxlarge"``: 8rem, matching the ``"xxlarge"`` gap in
``st.container`` and ``st.columns``.
- ``"stretch"``: Expands to fill remaining space in the container.
- An integer: Fixed size in pixels.
Examples
--------
**Example 1: Use vertical space to align elements**
Use small spaces to replace label heights. Use medium spaces to replace
two label heights or a button.
>>> import streamlit as st
>>>
>>> left, middle, right = st.columns(3)
>>>
>>> left.space("medium")
>>> left.button("Left button", width="stretch")
>>>
>>> middle.space("small")
>>> middle.text_input("Middle input")
>>>
>>> right.audio_input("Right uploader")
.. output::
https://doc-space-vertical.streamlit.app/
height: 260px
**Example 2: Add horizontal space in a container**
Use stretch space to float elements left and right.
>>> import streamlit as st
>>>
>>> with st.container(horizontal=True):
... st.button("Left")
... st.space("stretch")
... st.button("Right")
.. output::
https://doc-space-horizontal.streamlit.app/
height: 200px
streamlit.spinner
Python Library Documentation: method spinner in module streamlit.delta_generator
spinner(text: 'str' = 'In progress...', *, show_time: 'bool' = False, _cache: 'bool' = False, width: 'Width' = 'content') -> 'Iterator[None]' method of streamlit.delta_generator.DeltaGenerator instance
Display a loading spinner while executing a block of code.
Parameters
----------
text : str
The text to display next to the spinner. This defaults to
``"In progress..."``.
The text can optionally contain GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional, supported
Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
show_time : bool
Whether to show the elapsed time next to the spinner text. If this is
``False`` (default), no time is displayed. If this is ``True``,
elapsed time is displayed with a precision of 0.1 seconds. The time
format is not configurable.
width : "content", "stretch", or int
The width of the spinner element. This can be one of the following:
- ``"content"`` (default): The width of the element matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the element matches the width of the
parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Examples
--------
>>> import streamlit as st
>>> import time
>>>
>>> with st.spinner("Wait for it...", show_time=True):
>>> time.sleep(5)
>>> st.success("Done!")
>>> st.button("Rerun")
.. output::
https://doc-spinner.streamlit.app/
height: 210px
streamlit.starlette
Python Library Documentation: module streamlit.starlette in streamlit
NAME
streamlit.starlette - Starlette integration for Streamlit.
DESCRIPTION
This module provides the ASGI-compatible App class for running Streamlit
applications with any ASGI server (uvicorn, hypercorn, etc.).
Example
-------
>>> from streamlit.starlette import App
>>> app = App("main.py")
Run with uvicorn:
.. code-block:: bash
uvicorn myapp:app --host 0.0.0.0 --port 8501
CLASSES
builtins.object
streamlit.web.server.starlette.starlette_app.App
class App(builtins.object)
| App(script_path: 'str | Path', *, secrets: 'Mapping[str, SecretsValue] | None' = None, lifespan: 'Callable[[App], AbstractAsyncContextManager[dict[str, Any] | None]] | None' = None, routes: 'Sequence[BaseRoute] | None' = None, middleware: 'Sequence[Middleware] | None' = None, exception_handlers: 'Mapping[Any, ExceptionHandler] | None' = None, debug: 'bool' = False) -> 'None'
|
| ASGI-compatible Streamlit application.
|
| .. warning::
| This feature is experimental and may change or be removed in future
| versions without warning. Use at your own risk.
|
| This class provides a way to configure and run Streamlit applications
| with custom routes, middleware, lifespan hooks, and exception handlers.
|
| Parameters
| ----------
| script_path : str | Path
| Path to the main Streamlit script. Can be absolute or relative. Relative
| paths are resolved based on context: when started via ``streamlit run``,
| they resolve relative to the main script; when started directly via uvicorn
| or another ASGI server, they resolve relative to the current working directory.
| secrets : Mapping[str, SecretsValue] | None
| A dictionary of secrets to make available via ``st.secrets``. Supported
| value types are: ``str``, ``int``, ``float``, ``bool``, and nested ``dict``.
| When provided, these secrets are shallow-merged with file-based secrets
| (programmatic secrets override file-based secrets at the top level).
| Unsupported types raise ``TypeError`` at construction.
| lifespan : Callable[[App], AbstractAsyncContextManager[dict[str, Any] | None]] | None
| Async context manager for startup/shutdown logic. The context manager
| receives the App instance and can yield a dictionary of state that will
| be accessible via ``app.state``.
| routes : Sequence[BaseRoute] | None
| Additional routes to mount alongside Streamlit. User routes are checked
| against reserved Streamlit routes and will raise ValueError if they conflict.
| middleware : Sequence[Middleware] | None
| Middleware stack to apply to all requests. User middleware runs before
| Streamlit's internal middleware.
| exception_handlers : Mapping[Any, ExceptionHandler] | None
| Custom exception handlers for user routes.
| debug : bool
| Enable debug mode for the underlying Starlette application.
|
| Examples
| --------
| Basic usage:
|
| >>> from streamlit.web.server.starlette import App
| >>> app = App("main.py")
|
| With lifespan hooks:
|
| >>> from contextlib import asynccontextmanager
| >>> from streamlit.web.server.starlette import App
| >>>
| >>> @asynccontextmanager
| ... async def lifespan(app):
| ... print("Starting up...")
| ... yield {"model": "loaded"}
| ... print("Shutting down...")
| >>>
| >>> app = App("main.py", lifespan=lifespan)
|
| With custom routes:
|
| >>> from starlette.routing import Route
| >>> from starlette.responses import JSONResponse
| >>> from streamlit.web.server.starlette import App
| >>>
| >>> async def health(request):
| ... return JSONResponse({"status": "ok"})
| >>>
| >>> app = App("main.py", routes=[Route("/health", health)])
|
| With programmatic secrets:
|
| >>> import os
| >>> from streamlit.web.server.starlette import App
| >>>
| >>> app = App(
| ... "main.py",
| ... secrets={
| ... "database": {
| ... "host": os.environ["DB_HOST"],
| ... "password": os.environ["DB_PASSWORD"],
| ... }
| ... },
| ... )
|
| Methods defined here:
|
| async __call__(self, scope: 'Scope', receive: 'Receive', send: 'Send') -> 'None'
| ASGI interface.
|
| When mounted on another ASGI framework without using the lifespan() method,
| the runtime will be auto-started on the first HTTP/WebSocket request.
|
| __init__(self, script_path: 'str | Path', *, secrets: 'Mapping[str, SecretsValue] | None' = None, lifespan: 'Callable[[App], AbstractAsyncContextManager[dict[str, Any] | None]] | None' = None, routes: 'Sequence[BaseRoute] | None' = None, middleware: 'Sequence[Middleware] | None' = None, exception_handlers: 'Mapping[Any, ExceptionHandler] | None' = None, debug: 'bool' = False) -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| lifespan(self) -> 'Callable[[Any], AbstractAsyncContextManager[None]]'
| Get a lifespan context manager for mounting on external ASGI frameworks.
|
| Use this when mounting st.App as a sub-application on another framework
| like FastAPI. The Streamlit runtime lifecycle will be managed by the
| parent framework's lifespan instead of st.App's internal lifespan.
|
| Returns
| -------
| Callable[[Any], AbstractAsyncContextManager[None]]
| A lifespan context manager compatible with Starlette/FastAPI.
|
| Examples
| --------
| Mount st.App on FastAPI:
|
| >>> from fastapi import FastAPI
| >>> from streamlit.starlette import App
| >>>
| >>> streamlit_app = App("dashboard.py")
| >>> fastapi_app = FastAPI(lifespan=streamlit_app.lifespan())
| >>> fastapi_app.mount("/dashboard", streamlit_app)
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| script_path
| The entry point script path.
|
| state
| Application state, populated by lifespan context manager.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
DATA
__all__ = ['App']
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\starlette.py
streamlit.status
Python Library Documentation: method status in module streamlit.delta_generator
status(label: 'str', *, expanded: 'bool' = False, state: "Literal['running', 'complete', 'error']" = 'running', width: 'WidthWithoutContent' = 'stretch') -> 'StatusContainer' method of streamlit.delta_generator.DeltaGenerator instance
Insert a status container to display output from long-running tasks.
Inserts a container into your app that is typically used to show the status and
details of a process or task. The container can hold multiple elements and can
be expanded or collapsed by the user similar to ``st.expander``.
When collapsed, all that is visible is the status icon and label.
The label, state, and expanded state can all be updated by calling ``.update()``
on the returned object. To add elements to the returned container, you can
use ``with`` notation (preferred) or just call methods directly on the returned
object.
By default, ``st.status()`` initializes in the "running" state. When called using
``with`` notation, it automatically updates to the "complete" state at the end
of the "with" block. See examples below for more details.
.. note::
All content within the status container is computed and sent to the
frontend, even if the status container is closed.
To follow best design practices and maintain a good appearance on
all screen sizes, don't nest status containers.
Parameters
----------
label : str
The initial label of the status container. The label can optionally
contain GitHub-flavored Markdown of the following types: Bold, Italics,
Strikethroughs, Inline Code, Links, and Images. Images display like
icons, with a max height equal to the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
expanded : bool
If True, initializes the status container in "expanded" state. Defaults to
False (collapsed).
state : "running", "complete", or "error"
The initial state of the status container which determines which icon is
shown:
- ``running`` (default): A spinner icon is shown.
- ``complete``: A checkmark icon is shown.
- ``error``: An error icon is shown.
width : "stretch" or int
The width of the status container. This can be one of the following:
- ``"stretch"`` (default): The width of the container matches the
width of the parent container.
- An integer specifying the width in pixels: The container has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the container matches the width
of the parent container.
Returns
-------
StatusContainer
A mutable status container that can hold multiple elements. The label, state,
and expanded state can be updated after creation via ``.update()``.
Examples
--------
You can use the ``with`` notation to insert any element into an status container:
>>> import time
>>> import streamlit as st
>>>
>>> with st.status("Downloading data..."):
... st.write("Searching for data...")
... time.sleep(2)
... st.write("Found URL.")
... time.sleep(1)
... st.write("Downloading data...")
... time.sleep(1)
>>>
>>> st.button("Rerun")
.. output::
https://doc-status.streamlit.app/
height: 300px
You can also use ``.update()`` on the container to change the label, state,
or expanded state:
>>> import time
>>> import streamlit as st
>>>
>>> with st.status("Downloading data...", expanded=True) as status:
... st.write("Searching for data...")
... time.sleep(2)
... st.write("Found URL.")
... time.sleep(1)
... st.write("Downloading data...")
... time.sleep(1)
... status.update(
... label="Download complete!", state="complete", expanded=False
... )
>>>
>>> st.button("Rerun")
.. output::
https://doc-status-update.streamlit.app/
height: 300px
streamlit.stop
Python Library Documentation: function stop in module streamlit.commands.execution_control
stop() -> 'NoReturn'
Stops execution immediately.
Streamlit will not run any statements after `st.stop()`.
We recommend rendering a message to explain why the script has stopped.
Example
-------
>>> import streamlit as st
>>>
>>> name = st.text_input("Name")
>>> if not name:
>>> st.warning('Please input a name.')
>>> st.stop()
>>> st.success("Thank you for inputting a name.")
streamlit.streamlit
Python Library Documentation: package streamlit
NAME
streamlit - Streamlit.
DESCRIPTION
How to use Streamlit in 3 seconds:
1. Write an app
>>> import streamlit as st
>>> st.write(anything_you_want)
2. Run your app
$ streamlit run my_script.py
3. Use your app
A new tab will open on your browser. That's your Streamlit app!
4. Modify your code, save it, and watch changes live on your browser.
Take a look at the other commands in this module to find out what else
Streamlit can do:
>>> dir(streamlit)
Or try running our "Hello World":
$ streamlit hello
For more detailed info, see https://docs.streamlit.io.
PACKAGE CONTENTS
__main__
auth_util
cli_util
column_config
commands (package)
components (package)
config
config_option
config_util
connections (package)
cursor
dataframe_util
delta_generator
delta_generator_singletons
deprecation_util
development
elements (package)
emojis
env_util
error_util
errors
external (package)
file_util
git_util
hello (package)
logger
material_icon_names
navigation (package)
net_util
path_security
platform
proto (package)
runtime (package)
source_util
starlette
string_util
temporary_directory
testing (package)
time_util
type_util
url_util
user_info
util
vendor (package)
version
watcher (package)
web (package)
SUBMODULES
_column_config
_config
_logger
DATA
__annotations__ = {'_bottom': <class 'streamlit.delta_generator.DeltaG...
bottom = <streamlit.elements.bottom.BottomContainerProxy object>
cache_data = <streamlit.runtime.caching.cache_data_api.CacheDataAPI ob...
cache_resource = <streamlit.runtime.caching.cache_resource_api.CacheRe...
context = <streamlit.runtime.context.ContextProxy object>
query_params = <streamlit.runtime.state.query_params_proxy.QueryParams...
secrets = Secrets
session_state = <streamlit.runtime.state.session_state_proxy.SessionSt...
sidebar = DeltaGenerator(_root_container=1, _parent=DeltaGenerator())
user = <streamlit.user_info.UserInfoProxy object>
VERSION
1.57.0
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\__init__.py
streamlit.string_util
Python Library Documentation: module streamlit.string_util in streamlit
NAME
streamlit.string_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUNCTIONS
clean_text(text: 'SupportsStr') -> 'str'
Convert an object to text, dedent it, and strip whitespace.
extract_leading_emoji(text: 'str') -> 'tuple[str, str]'
Return a tuple containing the first emoji found in the given string and
the rest of the string (minus an optional separator between the two).
extract_leading_icon(text: 'str') -> 'tuple[str, str]'
Extract a leading emoji or material icon from text.
Returns a tuple of (icon, remaining_text) where icon is either an emoji,
a validated material icon string (e.g., ":material/thumb_up:"), or an
empty string if no icon was found. The remaining_text has the icon and
any separator whitespace removed.
This function is used to auto-detect icons at the start of text content,
allowing users to include an icon inline rather than via a separate parameter.
Examples
--------
>>> extract_leading_icon("🚨 Error occurred")
('🚨', 'Error occurred')
>>> extract_leading_icon(":material/warning: Caution")
(':material/warning:', 'Caution')
>>> extract_leading_icon("No icon here")
('', 'No icon here')
from_number(value: 'AnyNumber') -> 'str'
Render a real numeric type as a string for display.
Parameters
----------
value : AnyNumber
The numeric value to convert to a string. Can be an ``int``, ``float``,
any ``numbers.Number`` (e.g., ``decimal.Decimal``), or a NumPy numeric type
with an ``item()`` method.
Returns
-------
str
String representation of the numeric value.
Raises
------
TypeError
If the value is not of an accepted numeric type.
is_binary_string(inp: 'bytes') -> 'bool'
Guess if an input bytesarray can be encoded as a string.
is_emoji(text: 'str') -> 'bool'
Check if input string is a valid emoji.
is_material_icon(maybe_icon: 'str') -> 'bool'
Check if input string is a valid Material icon.
is_mem_address_str(string: 'str') -> 'bool'
Returns True if the string looks like <foo blarg at 0x15ee6f9a0>.
max_char_sequence(string: 'str', char: 'str') -> 'int'
Returns the count of the max sequence of a given char in a string.
simplify_number(num: 'int') -> 'str'
Simplifies number into Human readable format, returns str.
to_snake_case(camel_case_str: 'str') -> 'str'
Converts UpperCamelCase and lowerCamelCase to snake_case.
Examples
--------
fooBar -> foo_bar
BazBang -> baz_bang
validate_emoji(maybe_emoji: 'str | None') -> 'str'
validate_icon_or_emoji(icon: 'str | None') -> 'str'
Validate an icon or emoji and return it in normalized format if valid.
validate_material_icon(maybe_material_icon: 'str | None') -> 'str'
Validate a Material icon shortcode and return the icon in
normalized format if valid.
DATA
AnyNumber = typing.Union[ForwardRef('np.integer[Any]'), Forw...fractio...
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
TEXTCHARS = bytearray(b'\x07\x08\t\n\x0c\r\x1b !"#$%&\'()*+,...xf4\xf5...
TYPE_CHECKING = False
TypeAlias = typing.TypeAlias
Special form for marking type aliases.
Use TypeAlias to indicate that an assignment should
be recognized as a proper type alias definition by type
checkers.
For example::
Predicate: TypeAlias = Callable[..., bool]
It's invalid when used anywhere except as in the example above.
Union = typing.Union
Union type; Union[X, Y] means either X or Y.
On Python 3.10 and higher, the | operator
can also be used to denote unions;
X | Y means the same thing to the type checker as Union[X, Y].
To define a union, use e.g. Union[int, str]. Details:
- The arguments must be types and there must be at least one.
- None as an argument is a special case and is replaced by
type(None).
- Unions of unions are flattened, e.g.::
assert Union[Union[int, str], float] == Union[int, str, float]
- Unions of a single argument vanish, e.g.::
assert Union[int] == int # The constructor actually returns int
- Redundant arguments are skipped, e.g.::
assert Union[int, str, int] == Union[int, str]
- When comparing unions, the argument order is ignored, e.g.::
assert Union[int, str] == Union[str, int]
- You cannot subclass or instantiate a union.
- You can use Optional[X] as a shorthand for Union[X, None].
__annotations__ = {'AnyNumber': 'TypeAlias', 'TEXTCHARS': 'Final', '_A...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\string_util.py
streamlit.subheader
Python Library Documentation: method subheader in module streamlit.delta_generator
subheader(body: 'SupportsStr', anchor: 'Anchor' = None, *, help: 'str | None' = None, divider: 'Divider' = False, width: 'Width' = 'stretch', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display text in subheader formatting.
Parameters
----------
body : str
The text to display as GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
anchor : str or False
The anchor name of the header that can be accessed with #anchor
in the URL. If omitted, it generates an anchor using the body.
If False, the anchor is not shown in the UI.
help : str or None
A tooltip that gets displayed next to the subheader. If this is
``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
divider : bool, "blue", "green", "orange", "red", "violet", "yellow", "gray"/"grey", or "rainbow"
Shows a colored divider below the header. If this is ``True``,
successive headers will cycle through divider colors, except gray
and rainbow. That is, the first header will have a blue line, the
second header will have a green line, and so on. If this is a
string, the color can be set to one of the following: blue, green,
orange, red, violet, yellow, gray/grey, or rainbow.
width : "stretch", "content", or int
The width of the subheader element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
text_alignment : "left", "center", "right", or "justify"
The horizontal alignment of the text within the element. This can
be one of the following:
- ``"left"`` (default): Text is aligned to the left edge.
- ``"center"``: Text is centered.
- ``"right"``: Text is aligned to the right edge.
- ``"justify"``: Text is justified (stretched to fill the available
width with the last line left-aligned).
.. note::
For text alignment to have a visible effect, the element's
width must be wider than its content. If you use
``width="content"`` with short text, the alignment may not be
noticeable.
Examples
--------
>>> import streamlit as st
>>>
>>> st.subheader("_Streamlit_ is :blue[cool] :sunglasses:")
>>> st.subheader("This is a subheader with a divider", divider="gray")
>>> st.subheader("These subheaders have rotating dividers", divider=True)
>>> st.subheader("One", divider=True)
>>> st.subheader("Two", divider=True)
>>> st.subheader("Three", divider=True)
>>> st.subheader("Four", divider=True)
.. output::
https://doc-subheader.streamlit.app/
height: 500px
streamlit.success
Python Library Documentation: method success in module streamlit.delta_generator
success(body: 'SupportsStr', *, icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', title: 'SupportsStr | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a success message.
Parameters
----------
body : str
The text to display as GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
If ``icon`` is ``None``, and ``body`` begins with an emoji or
Material icon shortcode, Streamlit will extract it and display it
slightly enlarged, as if it were passed to ``icon``. If ``body``
contains multiple icons, or you want to override this behavior,
you can insert a null Markdown directive like ``:red[]`` before
your leading icon.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
icon : str or None
An optional emoji or icon to display next to the alert. If ``icon``
is ``None`` (default), Streamlit attempts to extract a leading
emoji or Material icon shortcode from ``body``. If found, the icon
is displayed and removed from the body text. If no leading icon is
found, no icon is displayed. If ``icon`` is a string, it takes
precedence over any icon in the body, and the following options
are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
width : "stretch" or int
The width of the success element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
title : str or None
An optional title to display above the body text. If ``None``
(default), no title is displayed. The title is rendered with bold
styling and can optionally contain GitHub-flavored Markdown of the
following types: Italics, Strikethroughs, Inline Code, Links, and
Images. Images display like icons, with a max height equal to the
font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Display elements are not supported.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
Examples
--------
>>> import streamlit as st
>>>
>>> st.success('This is a success message!', icon="✅")
streamlit.switch_page
Python Library Documentation: function switch_page in module streamlit.commands.execution_control
switch_page(page: 'str | Path | StreamlitPage', *, query_params: 'QueryParamsInput | None' = None) -> 'NoReturn'
Programmatically switch the current page in a multipage app.
When ``st.switch_page`` is called, the current page execution stops and
the specified page runs as if the user clicked on it in the navigation
menu. The specified page must be recognized by Streamlit's multipage
architecture. Arbitrary Python scripts and URLs can't be passed to
``st.switch_page``.
Parameters
----------
page : str, Path, or StreamlitPage
The page to switch to. This can be one of the following values:
- Path to a Python file: The path can be a string or ``pathlib.Path``
object. It can be absolute or relative to the entrypoint file. The
Python file must be the source of a page in ``st.navigation``.
If you are using the ``pages/`` directory instead of
``st.navigation``, the Python file must be your entrypoint file or
a file in the ``pages/`` directory.
- ``StreamlitPage``: The source of the ``StreamlitPage`` and its
``url_path`` must match a page defined in ``st.navigation``. The
``StreamlitPage`` must be internal and can't be defined by a URL.
Use ``st.Page`` to create a ``StreamlitPage`` object.
To switch to a page defined by a ``callable``, you must use a
``StreamlitPage`` object.
query_params : dict, list of tuples, or None
Query parameters to apply when navigating to the target page.
This can be a dictionary or an iterable of key-value tuples. Values can
be strings or iterables of strings (for repeated keys). When this is
``None`` (default), all non-embed query parameters are cleared during
navigation.
Examples
--------
**Example 1: Basic usage**
The following example shows how to switch to a different page in a
multipage app that uses the ``pages/`` directory:
.. code-block:: text
your-repository/
├── pages/
│ ├── page_1.py
│ └── page_2.py
└── your_app.py
>>> import streamlit as st
>>>
>>> if st.button("Home"):
>>> st.switch_page("your_app.py")
>>> if st.button("Page 1"):
>>> st.switch_page("pages/page_1.py")
>>> if st.button("Page 2"):
>>> st.switch_page("pages/page_2.py")
.. output::
https://doc-switch-page.streamlit.app/
height: 350px
**Example 2: Passing query parameters**
The following example shows how to pass query parameters when switching to a
different page. This example uses ``st.navigation`` to create a multipage app.
.. code-block:: text
your-repository/
├── page_2.py
└── your_app.py
>>> import streamlit as st
>>>
>>> def page_1():
>>> st.title("Page 1")
>>> if st.button("Switch to Page 2"):
>>> st.switch_page("page_2.py", query_params={"utm_source": "page_1"})
>>>
>>> pg = st.navigation([page_1, "page_2.py"])
>>> pg.run()
.. output::
https://doc-switch-page-query-params.streamlit.app/
height: 350px
streamlit.table
Python Library Documentation: method table in module streamlit.delta_generator
table(data: 'Data' = None, *, border: "bool | Literal['horizontal']" = True, width: 'Width' = 'stretch', height: 'Height' = 'content', hide_index: 'bool | None' = None, hide_header: 'bool | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a static table.
While ``st.dataframe`` is geared towards large datasets and interactive
data exploration, ``st.table`` is useful for displaying small, styled
tables without sorting or scrolling. For example, ``st.table`` may be
the preferred way to display a confusion matrix or leaderboard.
Additionally, ``st.table`` supports Markdown.
Parameters
----------
data : Anything supported by st.dataframe
The table data.
All cells including the index and column headers can optionally
contain GitHub-flavored Markdown. Syntax information can be found
at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
border : bool or "horizontal"
Whether to show borders around the table and between cells. This can be one
of the following:
- ``True`` (default): Show borders around the table and between cells.
- ``False``: Don't show any borders.
- ``"horizontal"``: Show only horizontal borders between rows.
width : "stretch", "content", or int
The width of the table element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Row index columns are sticky only when the content overflows a
specified integer width. Otherwise, they aren't sticky.
height : "stretch", "content", or int
The height of the table element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content, showing all rows.
- ``"stretch"``: The height of the element expands to fill the
available vertical space in its parent container. When multiple
elements with stretch height are in the same container, they
share the available vertical space evenly.
- An integer specifying the height in pixels: The element has a
fixed height. If the table content exceeds this height,
scrolling is enabled with sticky headers.
hide_index : bool or None
Whether to hide the index column. This can be one of the following
values:
- ``None`` (default): Hide the index column if it's a default
``RangeIndex``. Show custom indices.
- ``True``: Always hide the index column.
- ``False``: Always show the index column.
hide_header : bool or None
Whether to hide the column header row. This can be one of the
following values:
- ``None`` (default): Auto-hide headers for data formats without
user-defined column names, like ``dict``, ``list``, and
``numpy.ndarray``. Show headers for data with explicit column
names, like ``pandas.DataFrame``.
- ``True``: Always hide the column header row, including all levels
of ``MultiIndex`` headers.
- ``False``: Always show the column header row.
Examples
--------
**Example 1: Display a confusion matrix as a static table**
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
confusion_matrix = pd.DataFrame(
{
"Predicted Cat": [85, 3, 2, 1],
"Predicted Dog": [2, 78, 4, 0],
"Predicted Bird": [1, 5, 72, 3],
"Predicted Fish": [0, 2, 1, 89],
},
index=["Actual Cat", "Actual Dog", "Actual Bird", "Actual Fish"],
)
st.table(confusion_matrix)
.. output::
https://doc-table-confusion.streamlit.app/
height: 250px
**Example 2: Display a product leaderboard with Markdown and horizontal borders**
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
product_data = {
"Product": [
":material/devices: Widget Pro",
":material/smart_toy: Smart Device",
":material/inventory: Premium Kit",
],
"Category": [":blue[Electronics]", ":green[IoT]", ":violet[Bundle]"],
"Stock": ["🟢 Full", "🟡 Low", "🔴 Empty"],
"Units sold": [1247, 892, 654],
"Revenue": [125000, 89000, 98000],
}
st.table(product_data, border="horizontal")
.. output::
https://doc-table-horizontal-border.streamlit.app/
height: 200px
**Example 3: Display a scrollable table with fixed height**
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
from numpy.random import default_rng as rng
df = pd.DataFrame(
rng(0).standard_normal((50, 5)), columns=["A", "B", "C", "D", "E"]
)
st.table(df, height=300)
**Example 4: Display key-value data**
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
st.table(
{
":material/folder: Project": "**Streamlit** - The fastest way to build data apps",
":material/code: Repository": "[github.com/streamlit/streamlit](https://github.com/streamlit/streamlit)",
":material/new_releases: Version": ":gray-badge[1.45.0]",
":material/license: License": ":green-badge[Apache 2.0]",
":material/group: Maintainers": ":blue-badge[Core Team] :violet-badge[Community]",
},
border="horizontal",
width="content",
)
.. output::
https://doc-table-auto-header.streamlit.app/
height: 250px
**Example 5: Display a minimal table without index and headers**
.. code-block:: python
:filename: streamlit_app.py
import pandas as pd
import streamlit as st
df = pd.DataFrame({"Name": ["Alice", "Bob"], "Age": [25, 30]})
st.table(df, hide_index=True, hide_header=True)
.. output::
https://doc-table-hide-header-and-index.streamlit.app/
height: 200px
streamlit.tabs
Python Library Documentation: method tabs in module streamlit.delta_generator
tabs(tabs: 'Sequence[str]', *, width: 'WidthWithoutContent' = 'stretch', default: 'str | None' = None, key: 'Key | None' = None, on_change: "Literal['ignore', 'rerun'] | WidgetCallback" = 'ignore', args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None) -> 'Sequence[TabContainer]' method of streamlit.delta_generator.DeltaGenerator instance
Insert containers separated into tabs.
Inserts a number of multi-element containers as tabs.
Tabs are a navigational element that allows users to easily
move between groups of related content.
To add elements to the returned containers, you can use the ``with`` notation
(preferred) or just call methods directly on the returned object. See
the examples below.
By default, all tab content is computed and sent to the frontend
regardless of which tab is selected. To enable lazy execution where
only the selected tab's content runs, use ``on_change="rerun"`` or
pass a callable to ``on_change``. Each tab's ``.open`` property
indicates whether it is the currently selected tab, letting you
conditionally render expensive content.
Parameters
----------
tabs : list of str
Creates a tab for each string in the list. The first tab is selected
by default. The string is used as the name of the tab and can
optionally contain GitHub-flavored Markdown of the following types:
Bold, Italics, Strikethroughs, Inline Code, Links, and Images.
Images display like icons, with a max height equal to the font
height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
width : "stretch" or int
The width of the tab container. This can be one of the following:
- ``"stretch"`` (default): The width of the container matches the
width of the parent container.
- An integer specifying the width in pixels: The container has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the container matches the width
of the parent container.
default : str or None
The default tab to select. If this is ``None`` (default), the first
tab is selected. If this is a string, it must be one of the tab
labels. If two tabs have the same label as ``default``, the first
one is selected.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key.
When ``on_change`` is set to ``"rerun"`` or a callable, setting a
key lets you read or update the active tab label via
``st.session_state[key]``. For more details, see `Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
on_change : "ignore", "rerun", callable, or None
How the tabs should respond when the user switches tabs. This
controls whether tabs track state and trigger reruns. ``on_change``
can be one of the following values:
- ``"ignore"`` (default): The tabs don't track state. All tab content
runs regardless of which tab is selected. The ``.open`` attribute
of each tab container returns ``None`` for all tabs.
- ``"rerun"``: The tabs track state. Streamlit reruns the app when
the user switches tabs. The ``.open`` attribute of each tab
container returns its current state, which is ``True`` if it is
selected and ``False`` if it isn't selected. This lets you skip
expensive work in hidden tabs.
- A callable: The tabs track state. Streamlit executes the callable
as a callback function and reruns the app when the user switches
tabs. The ``.open`` attribute of each tab container returns its
state like when ``on_change="rerun"``. If you need to access
label of the current tab inside your callback, fetch it through
Session State.
When the tabs track state, they can't be used inside
Streamlit cache-decorated functions.
args : list or tuple or None
An optional list or tuple of args to pass to the ``on_change``
callback.
kwargs : dict or None
An optional dict of kwargs to pass to the ``on_change`` callback.
Returns
-------
Sequence of TabContainers
A sequence of ``TabContainer`` objects with ``.open`` properties to
return the current state of the tabs if the tabs track state.
Examples
--------
*Example 1: Use context management*
You can use ``with`` notation to insert any element into a tab:
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
tab1, tab2, tab3 = st.tabs(["Cat", "Dog", "Owl"])
with tab1:
st.header("A cat")
st.image("https://static.streamlit.io/examples/cat.jpg", width=200)
with tab2:
st.header("A dog")
st.image("https://static.streamlit.io/examples/dog.jpg", width=200)
with tab3:
st.header("An owl")
st.image("https://static.streamlit.io/examples/owl.jpg", width=200)
.. output::
https://doc-tabs1.streamlit.app/
height: 620px
*Example 2: Call methods directly*
You can call methods directly on the returned objects:
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
from numpy.random import default_rng as rng
df = rng(0).standard_normal((10, 1))
tab1, tab2 = st.tabs(["📈 Chart", "🗃 Data"])
tab1.subheader("A tab with a chart")
tab1.line_chart(df)
tab2.subheader("A tab with the data")
tab2.write(df)
.. output::
https://doc-tabs2.streamlit.app/
height: 700px
*Example 3: Set the default tab and style the tab labels*
Use the ``default`` parameter to set the default tab. You can also use
Markdown in the tab labels.
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
tab1, tab2, tab3 = st.tabs(
[":cat: Cat", ":dog: Dog", ":rainbow[Owl]"], default=":rainbow[Owl]"
)
with tab1:
st.header("A cat")
st.image("https://static.streamlit.io/examples/cat.jpg", width=200)
with tab2:
st.header("A dog")
st.image("https://static.streamlit.io/examples/dog.jpg", width=200)
with tab3:
st.header("An owl")
st.image("https://static.streamlit.io/examples/owl.jpg", width=200)
.. output::
https://doc-tabs3.streamlit.app/
height: 620px
**Example 4: Programmatically control the tab state**
You can use a key to programmatically control the tab state or access
the state in callbacks. You must set the ``on_change`` parameter for
the tabs to track state.
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
def switch_tab(tab):
st.session_state.animal = tab
def on_tab_change():
st.toast(f"You opened the {st.session_state.animal} tab.")
cat, dog, owl = st.tabs(
["Cat", "Dog", "Owl"], on_change=on_tab_change, key="animal"
)
if cat.open:
with cat:
st.write("This is the cat")
if dog.open:
with dog:
st.write("This is the dog")
if owl.open:
with owl:
st.write("This is the owl")
with st.container(horizontal=True):
st.button("Cat", on_click=switch_tab, args=("Cat",))
st.button("Dog", on_click=switch_tab, args=("Dog",))
st.button("Owl", on_click=switch_tab, args=("Owl",))
.. output::
https://doc-tabs-callback.streamlit.app/
height: 300px
streamlit.text
Python Library Documentation: method text in module streamlit.delta_generator
text(body: 'SupportsStr', *, help: 'str | None' = None, width: 'Width' = 'content', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Write text without Markdown or HTML parsing.
For monospace text, use |st.code|_.
.. |st.code| replace:: ``st.code``
.. _st.code: https://docs.streamlit.io/develop/api-reference/text/st.code
Parameters
----------
body : str
The string to display.
help : str or None
A tooltip that gets displayed next to the text. If this is ``None``
(default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
width : "content", "stretch", or int
The width of the text element. This can be one of the following:
- ``"content"`` (default): The width of the element matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the element matches the width of the
parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
text_alignment : "left", "center", "right", or "justify"
The horizontal alignment of the text within the element. This can
be one of the following:
- ``"left"`` (default): Text is aligned to the left edge.
- ``"center"``: Text is centered.
- ``"right"``: Text is aligned to the right edge.
- ``"justify"``: Text is justified (stretched to fill the available
width with the last line left-aligned).
.. note::
For text alignment to have a visible effect, the element's
width must be wider than its content. If you use
``width="content"`` with short text, the alignment may not be
noticeable.
Examples
--------
>>> import streamlit as st
>>>
>>> st.text("This is text\n[and more text](that's not a Markdown link).")
.. output::
https://doc-text.streamlit.app/
height: 220px
streamlit.text_area
Python Library Documentation: method text_area in module streamlit.delta_generator
text_area(label: 'str', value: 'str | SupportsStr | None' = '', height: 'Height | None' = None, max_chars: 'int | None' = None, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, placeholder: 'str | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'str | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a multi-line text input widget.
Parameters
----------
label : str
A short label explaining to the user what this input is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
value : object or None
The text value of this widget when it first renders. This will be
cast to str internally. If ``None``, will initialize empty and
return ``None`` until the user provides input. Defaults to empty string.
height : "content", "stretch", int, or None
The height of the text area widget. This can be one of the
following:
- ``None`` (default): The height of the widget fits three lines.
- ``"content"``: The height of the widget matches the
height of its content.
- ``"stretch"``: The height of the widget matches the height of
its content or the height of the parent container, whichever is
larger. If the widget is not in a parent container, the height
of the widget matches the height of its content.
- An integer specifying the height in pixels: The widget has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
The widget's height can't be smaller than the height of two lines.
When ``label_visibility="collapsed"``, the minimum height is 68
pixels. Otherwise, the minimum height is 98 pixels.
max_chars : int or None
Maximum number of characters allowed in text area.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``max_chars`` resets the widget even when a key
is provided.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this text_area's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
placeholder : str or None
An optional string displayed when the text area is empty. If None,
no text is displayed.
disabled : bool
An optional boolean that disables the text area if set to ``True``.
The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "stretch" or int
The width of the text area widget. This can be one of the
following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
An empty query parameter (e.g., ``?my_key=``) clears the
widget.
Returns
-------
str or None
The current value of the text area widget or ``None`` if no value has been
provided by the user.
Examples
--------
>>> import streamlit as st
>>>
>>> txt = st.text_area(
... "Text to analyze",
... "It was the best of times, it was the worst of times, it was the age of "
... "wisdom, it was the age of foolishness, it was the epoch of belief, it "
... "was the epoch of incredulity, it was the season of Light, it was the "
... "season of Darkness, it was the spring of hope, it was the winter of "
... "despair, (...)",
... )
>>>
>>> st.write(f"You wrote {len(txt)} characters.")
.. output::
https://doc-text-area.streamlit.app/
height: 300px
streamlit.text_input
Python Library Documentation: method text_input in module streamlit.delta_generator
text_input(label: 'str', value: 'str | SupportsStr | None' = '', max_chars: 'int | None' = None, key: 'Key | None' = None, type: "Literal['default', 'password']" = 'default', help: 'str | None' = None, autocomplete: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, placeholder: 'str | None' = None, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'str | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a single-line text input widget.
Parameters
----------
label : str
A short label explaining to the user what this input is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
value : object or None
The text value of this widget when it first renders. This will be
cast to str internally. If ``None``, will initialize empty and
return ``None`` until the user provides input. Defaults to empty string.
max_chars : int or None
Max number of characters allowed in text input.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``max_chars`` resets the widget even when a key
is provided.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
type : "default" or "password"
The type of the text input. This can be either "default" (for
a regular text input), or "password" (for a text input that
masks the user's typed value). Defaults to "default".
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
autocomplete : str
An optional value that will be passed to the <input> element's
autocomplete property. If unspecified, this value will be set to
"new-password" for "password" inputs, and the empty string for
"default" inputs. For more details, see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
on_change : callable
An optional callback invoked when this text input's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
placeholder : str or None
An optional string displayed when the text input is empty. If None,
no text is displayed.
disabled : bool
An optional boolean that disables the text input if set to
``True``. The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
icon : str, None
An optional emoji or icon to display within the input field to the
left of the value. If ``icon`` is ``None`` (default), no icon is
displayed. If ``icon`` is a string, the following options are
valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols \
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
width : "stretch" or int
The width of the text input widget. This can be one of the
following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
This can't be used with ``type="password"``. An empty
query parameter (e.g., ``?my_key=``) clears the widget.
Returns
-------
str or None
The current value of the text input widget or ``None`` if no value has been
provided by the user.
Examples
--------
>>> import streamlit as st
>>>
>>> title = st.text_input("Movie title", "Life of Brian")
>>> st.write("The current movie title is", title)
.. output::
https://doc-text-input.streamlit.app/
height: 260px
streamlit.time_input
Python Library Documentation: method time_input in module streamlit.delta_generator
time_input(label: 'str', value: 'TimeValue | None' = 'now', key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', step: 'int | timedelta' = datetime.timedelta(seconds=900), width: 'WidthWithoutContent' = 'stretch', bind: 'BindOption' = None) -> 'time | None' method of streamlit.delta_generator.DeltaGenerator instance
Display a time input widget.
Parameters
----------
label : str
A short label explaining to the user what this time input is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
value : "now", datetime.time, datetime.datetime, str, or None
The value of this widget when it first renders. This can be one of
the following:
- ``"now"`` (default): The widget initializes with the current time.
- A ``datetime.time`` or ``datetime.datetime`` object: The widget
initializes with the given time, ignoring any date if included.
- An ISO-formatted time (hh:mm[:ss.sss]) or datetime
(YYYY-MM-DD hh:mm[:ss]) string: The widget initializes with the
given time, ignoring any date if included.
- ``None``: The widget initializes with no time and returns
``None`` until the user selects a time.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
.. note::
Changing ``step`` resets the widget even when a key is
provided, because it constrains valid values.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this time_input's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the time input if set to
``True``. The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
step : int or timedelta
The stepping interval in seconds. This defaults to ``900`` (15
minutes). You can also pass a ``datetime.timedelta`` object. The
value must be between 60 seconds and 23 hours.
width : "stretch" or int
The width of the time input widget. This can be one of the following:
- ``"stretch"`` (default): The width of the widget matches the
width of the parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Times use HH:MM format in the URL. Invalid query parameter
values are ignored and removed from the URL. If ``value``
is ``None``, an empty query parameter (e.g., ``?my_key=``)
clears the widget.
Returns
-------
datetime.time or None
The current value of the time input widget or ``None`` if no time has been
selected.
Examples
--------
**Example 1: Basic usage**
>>> import datetime
>>> import streamlit as st
>>>
>>> t = st.time_input("Set an alarm for", datetime.time(8, 45))
>>> st.write("Alarm is set for", t)
.. output::
https://doc-time-input.streamlit.app/
height: 260px
**Example 2: Empty initial value**
To initialize an empty time input, use ``None`` as the value:
>>> import datetime
>>> import streamlit as st
>>>
>>> t = st.time_input("Set an alarm for", value=None)
>>> st.write("Alarm is set for", t)
.. output::
https://doc-time-input-empty.streamlit.app/
height: 260px
streamlit.time_util
Python Library Documentation: module streamlit.time_util in streamlit
NAME
streamlit.time_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUNCTIONS
adjust_years(input_date: 'date', years: 'int') -> 'date'
Add or subtract years from a date.
time_to_seconds(t: 'float | timedelta | str | None', *, coerce_none_to_inf: 'bool' = True) -> 'float | None'
Convert a time string value to a float representing "number of seconds".
DATA
Literal = typing.Literal
Special typing form to define literal types (a.k.a. value types).
This form can be used to indicate to type checkers that the corresponding
variable or function parameter has a value equivalent to the provided
literal (or one of several literals)::
def validate_simple(data: Any) -> Literal[True]: # always returns True
...
MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
...
open_helper('/some/path', 'r') # Passes type check
open_helper('/other/path', 'typo') # Error in type checker
Literal[...] cannot be subclassed. At runtime, an arbitrary value
is allowed as type argument to Literal[...], but type checkers may
impose restrictions.
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\time_util.py
streamlit.title
Python Library Documentation: method title in module streamlit.delta_generator
title(body: 'SupportsStr', anchor: 'Anchor' = None, *, help: 'str | None' = None, width: 'Width' = 'stretch', text_alignment: 'TextAlignment' = 'left') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display text in title formatting.
Each document should have a single `st.title()`, although this is not
enforced.
Parameters
----------
body : str
The text to display as GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
anchor : str or False
The anchor name of the header that can be accessed with #anchor
in the URL. If omitted, it generates an anchor using the body.
If False, the anchor is not shown in the UI.
help : str or None
A tooltip that gets displayed next to the title. If this is
``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
width : "stretch", "content", or int
The width of the title element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
text_alignment : "left", "center", "right", or "justify"
The horizontal alignment of the text within the element. This can
be one of the following:
- ``"left"`` (default): Text is aligned to the left edge.
- ``"center"``: Text is centered.
- ``"right"``: Text is aligned to the right edge.
- ``"justify"``: Text is justified (stretched to fill the available
width with the last line left-aligned).
.. note::
For text alignment to have a visible effect, the element's
width must be wider than its content. If you use
``width="content"`` with short text, the alignment may not be
noticeable.
Examples
--------
>>> import streamlit as st
>>>
>>> st.title("This is a title")
>>> st.title("_Streamlit_ is :blue[cool] :sunglasses:")
.. output::
https://doc-title.streamlit.app/
height: 220px
streamlit.toast
Python Library Documentation: method toast in module streamlit.delta_generator
toast(body: 'SupportsStr', *, icon: 'str | None' = None, duration: "Literal['short', 'long', 'infinite'] | int" = 'short') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a short message, known as a notification "toast".
The toast appears in the app's top-right corner and disappears after four seconds.
.. warning::
``st.toast`` is not compatible with Streamlit's `caching <https://docs.streamlit.io/develop/concepts/architecture/caching>`_ and
cannot be called within a cached function.
Parameters
----------
body : str
The string to display as GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
icon : str, None
An optional emoji or icon to display next to the alert. If ``icon``
is ``None`` (default), no icon is displayed. If ``icon`` is a
string, the following options are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
duration : "short", "long", "infinite", or int
The time to display the toast message. This can be one of the
following:
- ``"short"`` (default): Displays for 4 seconds.
- ``"long"``: Displays for 10 seconds.
- ``"infinite"``: Shows the toast until the user dismisses it.
- An integer: Displays for the specified number of seconds.
Examples
--------
**Example 1: Show a toast message**
>>> import streamlit as st
>>>
>>> st.toast("Your edited image was saved!", icon="😍")
.. output::
https://doc-status-toast.streamlit.app
height: 200px
**Example 2: Show multiple toasts**
When multiple toasts are generated, they will stack. Hovering over a
toast will stop it from disappearing. When hovering ends, the toast
will disappear after time specified in ``duration``.
>>> import time
>>> import streamlit as st
>>>
>>> if st.button("Three cheers"):
>>> st.toast("Hip!")
>>> time.sleep(0.5)
>>> st.toast("Hip!")
>>> time.sleep(0.5)
>>> st.toast("Hooray!", icon="🎉")
.. output::
https://doc-status-toast1.streamlit.app
height: 300px
**Example 3: Update a toast message**
Toast messages can also be updated. Assign ``st.toast(my_message)`` to
a variable and use the ``.toast()`` method to update it. If a toast has
already disappeared or been dismissed, the update will not be seen.
>>> import time
>>> import streamlit as st
>>>
>>> def cook_breakfast():
>>> msg = st.toast("Gathering ingredients...")
>>> time.sleep(1)
>>> msg.toast("Cooking...")
>>> time.sleep(1)
>>> msg.toast("Ready!", icon="🥞")
>>>
>>> if st.button("Cook breakfast"):
>>> cook_breakfast()
.. output::
https://doc-status-toast2.streamlit.app
height: 200px
streamlit.toggle
Python Library Documentation: method toggle in module streamlit.delta_generator
toggle(label: 'str', value: 'bool' = False, key: 'Key | None' = None, help: 'str | None' = None, on_change: 'WidgetCallback | None' = None, args: 'WidgetArgs | None' = None, kwargs: 'WidgetKwargs | None' = None, *, disabled: 'bool' = False, label_visibility: 'LabelVisibility' = 'visible', width: 'Width' = 'content', bind: 'BindOption' = None) -> 'bool' method of streamlit.delta_generator.DeltaGenerator instance
Display a toggle widget.
Parameters
----------
label : str
A short label explaining to the user what this toggle is for.
The label can optionally contain GitHub-flavored Markdown of the
following types: Bold, Italics, Strikethroughs, Inline Code, Links,
and Images. Images display like icons, with a max height equal to
the font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Common block-level Markdown (headings,
lists, blockquotes) is automatically escaped and displays as
literal text in labels.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
For accessibility reasons, you should never set an empty label, but
you can hide it with ``label_visibility`` if needed. In the future,
we may disallow empty labels by raising an exception.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
value : bool
Preselect the toggle when it first renders. This will be
cast to bool internally.
key : str, int, or None
An optional string or integer to use as the unique key for
the widget. If this is ``None`` (default), a key will be
generated for the widget based on the values of the other
parameters. No two widgets may have the same key. Assigning
a key stabilizes the widget's identity and preserves its
state across reruns even when other parameters change.
A key lets you read or update the widget's value via
``st.session_state[key]``. For more details, see `Widget
behavior <https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
help : str or None
A tooltip that gets displayed next to the widget label. Streamlit
only displays the tooltip when ``label_visibility="visible"``. If
this is ``None`` (default), no tooltip is displayed.
The tooltip can optionally contain GitHub-flavored Markdown,
including the Markdown directives described in the ``body``
parameter of ``st.markdown``.
on_change : callable
An optional callback invoked when this toggle's value changes.
args : list or tuple
An optional list or tuple of args to pass to the callback.
kwargs : dict
An optional dict of kwargs to pass to the callback.
disabled : bool
An optional boolean that disables the toggle if set to ``True``.
The default is ``False``.
label_visibility : "visible", "hidden", or "collapsed"
The visibility of the label. The default is ``"visible"``. If this
is ``"hidden"``, Streamlit displays an empty spacer instead of the
label, which can help keep the widget aligned with other widgets.
If this is ``"collapsed"``, Streamlit displays no label or spacer.
width : "content", "stretch", or int
The width of the toggle widget. This can be one of the following:
- ``"content"`` (default): The width of the widget matches the
width of its content, but doesn't exceed the width of the parent
container.
- ``"stretch"``: The width of the widget matches the width of the
parent container.
- An integer specifying the width in pixels: The widget has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the widget matches the width
of the parent container.
bind : "query-params" or None
Binding mode for syncing the widget's value with a URL query
parameter. If this is ``None`` (default), the widget's value
is not synced to the URL. When this is set to
``"query-params"``, changes to the widget update the URL, and
the widget can be initialized or updated through a query
parameter in the URL. This requires ``key`` to be set. The
key is used as the query parameter name.
When the widget's value equals its default, the query
parameter is removed from the URL to keep it clean. A bound
query parameter can't be set or deleted through
``st.query_params``; it can only be programmatically changed
through ``st.session_state``.
Returns
-------
bool
Whether or not the toggle is checked.
Examples
--------
>>> import streamlit as st
>>>
>>> on = st.toggle("Activate feature")
>>>
>>> if on:
... st.write("Feature activated!")
.. output::
https://doc-toggle.streamlit.app/
height: 220px
streamlit.type_util
Python Library Documentation: module streamlit.type_util in streamlit
NAME
streamlit.type_util - A bunch of useful utilities for dealing with types.
CLASSES
typing.Protocol(typing.Generic)
CustomDict
SupportsReprHtml
SupportsStr
class CustomDict(typing.Protocol)
| CustomDict(*args, **kwargs)
|
| Protocol for Streamlit native custom dictionaries (e.g. session state, secrets, query params).
| that can be converted to a dict.
|
| All these implementations should provide a to_dict method.
|
| Method resolution order:
| CustomDict
| typing.Protocol
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__ = _no_init_or_replace_init(self, *args, **kwargs) from typing
|
| to_dict(self) -> 'dict[str, Any]'
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __subclasshook__ = _proto_hook(other) from typing
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __parameters__ = ()
|
| __protocol_attrs__ = {'to_dict'}
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Protocol:
|
| __init_subclass__(*args, **kwargs)
| Function to initialize subclasses.
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
class SupportsReprHtml(typing.Protocol)
| SupportsReprHtml(*args, **kwargs)
|
| Method resolution order:
| SupportsReprHtml
| typing.Protocol
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__ = _no_init_or_replace_init(self, *args, **kwargs) from typing
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __subclasshook__ = _proto_hook(other) from typing
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __parameters__ = ()
|
| __protocol_attrs__ = {'_repr_html_'}
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Protocol:
|
| __init_subclass__(*args, **kwargs)
| Function to initialize subclasses.
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
class SupportsStr(typing.Protocol)
| SupportsStr(*args, **kwargs)
|
| Method resolution order:
| SupportsStr
| typing.Protocol
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__ = _no_init_or_replace_init(self, *args, **kwargs) from typing
|
| __str__(self) -> 'str'
| Return str(self).
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __subclasshook__ = _proto_hook(other) from typing
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| __parameters__ = ()
|
| __protocol_attrs__ = {'__str__'}
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Protocol:
|
| __init_subclass__(*args, **kwargs)
| Function to initialize subclasses.
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
FUNCTIONS
async_generator_to_sync(async_gen: 'AsyncGenerator[Any, Any]') -> 'Generator[Any, Any, Any]'
Convert an async generator to a synchronous generator.
check_python_comparable(seq: 'Sequence[Any]') -> 'None'
Check if the sequence elements support "python comparison".
That means that the equality operator (==) returns a boolean value.
Which is not True for e.g. numpy arrays and pandas series.
dump_pydantic_sequence(obj: 'Sequence[object]') -> 'list[dict[str, Any]]'
Dump a sequence of Pydantic models to a list of dictionaries.
get_fqn(the_type: 'type') -> 'str'
Get module.type_name for a given type.
get_fqn_type(obj: 'object') -> 'str'
Get module.type_name for a given object.
get_func_parameters(func: 'Callable[..., Any]') -> 'list[inspect.Parameter]'
Return the parameters of a function's signature.
On Python 3.14+, PEP 649 causes annotation evaluation to be deferred until
accessed. This can fail with NameError when annotations reference types
imported under TYPE_CHECKING. Since we only need parameter names and kinds
(not annotations), we use ``annotation_format=Format.STRING`` to avoid
evaluation. Note that on Python 3.14+, the returned Parameter.annotation
values will be strings rather than actual types.
See: https://github.com/streamlit/streamlit/issues/14324
get_object_name(obj: 'object') -> 'str'
Get a simplified name of the given object.
has_callable_attr(obj: 'object', name: 'str') -> 'bool'
True if obj has the specified attribute that is callable.
is_altair_chart(obj: 'object') -> 'bool'
True if input looks like an Altair chart.
is_altair_version_less_than(v: 'str') -> 'bool'
Return True if the current Altair version is less than the input version.
Parameters
----------
v : str
Version string, e.g. "0.25.0"
Returns
-------
bool
is_bytes_like(obj: 'object') -> 'TypeGuard[BytesLike]'
True if the type is considered bytes-like for the purposes of
protobuf data marshalling.
is_custom_dict(obj: 'object') -> 'TypeGuard[CustomDict]'
True if input looks like one of the Streamlit custom dictionaries.
is_dataclass_instance(obj: 'object') -> 'bool'
True if obj is an instance of a dataclass.
is_delta_generator(obj: 'object') -> 'TypeGuard[DeltaGenerator]'
True if input looks like a DeltaGenerator.
is_function(x: 'object') -> 'TypeGuard[types.FunctionType]'
Return True if x is a function.
is_graphviz_chart(obj: 'object') -> 'TypeGuard[graphviz.Graph | graphviz.Digraph | graphviz.Source]'
True if input looks like a GraphViz chart.
is_iterable(obj: 'object') -> 'TypeGuard[Iterable[Any]]'
is_keras_model(obj: 'object') -> 'bool'
True if input looks like a Keras model.
is_list_like(obj: 'object') -> 'TypeGuard[Sequence[Any]]'
True if input looks like a list.
is_namedtuple(x: 'object') -> 'TypeGuard[NamedTuple]'
True if obj is an instance of a namedtuple.
is_openai_chunk(obj: 'object') -> 'bool'
True if input looks like an OpenAI chat completion chunk.
is_pillow_image(obj: 'object') -> 'bool'
True if input looks like a pillow image.
is_plotly_chart(obj: 'object') -> 'TypeGuard[Figure | list[Any] | dict[str, Any]]'
True if input looks like a Plotly chart.
is_pydantic_model(obj: 'object') -> 'bool'
True if input looks like a Pydantic model instance.
is_pydeck(obj: 'object') -> 'TypeGuard[Deck]'
True if input looks like a pydeck chart.
is_sequence_of_pydantic_models(obj: 'object') -> 'TypeGuard[Sequence[Any]]'
True if obj is a non-empty list/tuple/set/frozenset of Pydantic model instances.
is_sympy_expression(obj: 'object') -> 'TypeGuard[sympy.Expr]'
True if input is a SymPy expression.
is_type(obj: 'object', fqn_type_pattern: 'str | re.Pattern[str]') -> 'bool'
Check type without importing expensive modules.
Parameters
----------
obj : object
The object to type-check.
fqn_type_pattern : str or regex
The fully-qualified type string or a regular expression.
Regexes should start with `^` and end with `$`.
Examples
--------
To check whether something is a Matplotlib Figure without importing
matplotlib, use:
>>> is_type(foo, "matplotlib.figure.Figure")
is_version_less_than(v1: 'str', v2: 'str') -> 'bool'
Return True if the v1 version string is less than the v2 version string
based on semantic versioning.
to_bytes(obj: 'BytesLike') -> 'bytes'
Converts the given object to bytes.
Only types for which `is_bytes_like` is true can be converted; anything
else will result in an exception.
DATA
BytesLike = bytes | bytearray
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
Literal = typing.Literal
Special typing form to define literal types (a.k.a. value types).
This form can be used to indicate to type checkers that the corresponding
variable or function parameter has a value equivalent to the provided
literal (or one of several literals)::
def validate_simple(data: Any) -> Literal[True]: # always returns True
...
MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
...
open_helper('/some/path', 'r') # Passes type check
open_helper('/other/path', 'typo') # Error in type checker
Literal[...] cannot be subclassed. At runtime, an arbitrary value
is allowed as type argument to Literal[...], but type checkers may
impose restrictions.
NumpyShape = tuple[int, ...]
TYPE_CHECKING = False
TypeAlias = typing.TypeAlias
Special form for marking type aliases.
Use TypeAlias to indicate that an assignment should
be recognized as a proper type alias definition by type
checkers.
For example::
Predicate: TypeAlias = Callable[..., bool]
It's invalid when used anywhere except as in the example above.
TypeGuard = typing.TypeGuard
Special typing construct for marking user-defined type guard functions.
``TypeGuard`` can be used to annotate the return type of a user-defined
type guard function. ``TypeGuard`` only accepts a single type argument.
At runtime, functions marked this way should return a boolean.
``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static
type checkers to determine a more precise type of an expression within a
program's code flow. Usually type narrowing is done by analyzing
conditional code flow and applying the narrowing to a block of code. The
conditional expression here is sometimes referred to as a "type guard".
Sometimes it would be convenient to use a user-defined boolean function
as a type guard. Such a function should use ``TypeGuard[...]`` as its
return type to alert static type checkers to this intention.
Using ``-> TypeGuard`` tells the static type checker that for a given
function:
1. The return value is a boolean.
2. If the return value is ``True``, the type of its argument
is the type inside ``TypeGuard``.
For example::
def is_str_list(val: list[object]) -> TypeGuard[list[str]]:
'''Determines whether all objects in the list are strings'''
return all(isinstance(x, str) for x in val)
def func1(val: list[object]):
if is_str_list(val):
# Type of ``val`` is narrowed to ``list[str]``.
print(" ".join(val))
else:
# Type of ``val`` remains as ``list[object]``.
print("Not a list of strings!")
Strict type narrowing is not enforced -- ``TypeB`` need not be a narrower
form of ``TypeA`` (it can even be a wider form) and this may lead to
type-unsafe results. The main reason is to allow for things like
narrowing ``list[object]`` to ``list[str]`` even though the latter is not
a subtype of the former, since ``list`` is invariant. The responsibility of
writing type-safe type guards is left to the user.
``TypeGuard`` also works with type variables. For more information, see
PEP 647 (User-Defined Type Guards).
__annotations__ = {'BytesLike': 'TypeAlias', 'NumpyShape': 'TypeAlias'...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\type_util.py
streamlit.url_util
Python Library Documentation: module streamlit.url_util in streamlit
NAME
streamlit.url_util
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUNCTIONS
get_hostname(url: 'str') -> 'str | None'
Return the hostname of a URL (with or without protocol).
is_relative_static_url(url: 'str') -> 'bool'
Check if a string is a relative static URL (starts with /app/static/).
These URLs are served by Streamlit's static file serving endpoint and can be
used directly without needing to go through the media file manager.
Parameters
----------
url : str
The URL to check.
Returns
-------
bool
True if the URL starts with /app/static/, False otherwise.
is_url(url: 'str', allowed_schemas: 'tuple[UrlSchema, ...]' = ('http', 'https')) -> 'bool'
Check if a string looks like an URL.
This doesn't check if the URL is actually valid or reachable.
Parameters
----------
url : str
The URL to check.
allowed_schemas : Tuple[str]
The allowed URL schemas. Default is ("http", "https").
make_url_path(base_url: 'str', path: 'str') -> 'str'
Make a URL from a base URL and a path.
Parameters
----------
base_url : str
The base URL.
path : str
The path to append to the base URL.
Returns
-------
str
The resulting URL.
process_gitblob_url(url: 'str') -> 'str'
Check url to see if it describes a GitHub Gist "blob" URL.
If so, returns a new URL to get the "raw" script.
If not, returns URL unchanged.
DATA
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
Literal = typing.Literal
Special typing form to define literal types (a.k.a. value types).
This form can be used to indicate to type checkers that the corresponding
variable or function parameter has a value equivalent to the provided
literal (or one of several literals)::
def validate_simple(data: Any) -> Literal[True]: # always returns True
...
MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
...
open_helper('/some/path', 'r') # Passes type check
open_helper('/other/path', 'typo') # Error in type checker
Literal[...] cannot be subclassed. At runtime, an arbitrary value
is allowed as type argument to Literal[...], but type checkers may
impose restrictions.
TypeAlias = typing.TypeAlias
Special form for marking type aliases.
Use TypeAlias to indicate that an assignment should
be recognized as a proper type alias definition by type
checkers.
For example::
Predicate: TypeAlias = Callable[..., bool]
It's invalid when used anywhere except as in the example above.
UrlSchema = typing.Literal['http', 'https', 'mailto', 'data']
__annotations__ = {'UrlSchema': 'TypeAlias', '_GITBLOB_RE': 'Final', '...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\url_util.py
streamlit.user
Python Library Documentation: UserInfoProxy in module streamlit.user_info object
class UserInfoProxy(collections.abc.Mapping)
| A read-only, dict-like object for accessing information about the current user.
|
| ``st.user`` is dependent on the host platform running your
| Streamlit app. If your host platform has not configured the object,
| ``st.user`` will behave as it does in a locally running app.
|
| When authentication is configured in ``secrets.toml``, Streamlit will parse
| the OpenID Connect (OIDC) identity token and copy the attributes to
| ``st.user``. Check your provider's documentation for their
| available attributes (known as claims).
|
| When authentication is not configured, ``st.user`` has no
| attributes.
|
| You can access values via key or attribute notation. For example, use
| ``st.user["email"]`` or ``st.user.email`` to
| access the ``email`` attribute.
|
| .. Important::
| Identity tokens include an issuance and expiration time. Streamlit does
| not implicitly check these. If you want to automatically expire a
| user's authentication, check these values manually and programmatically
| log out your user (``st.logout()``) when needed.
|
| Attributes
| ----------
| is_logged_in : bool
| Whether a user is logged in. For a locally running app, this attribute
| is only available when authentication (``st.login()``) is configured in
| ``secrets.toml``. Otherwise, it does not exist.
| tokens : TokensProxy
| A read-only, dict-like object for accessing exposed tokens from the
| identity provider.
|
| Examples
| --------
| **Example 1: Google's identity token**
|
| If you configure a basic Google OIDC connection as shown in Example 1 of
| ``st.login()``, the following data is available in
| ``st.user``. Streamlit adds the ``is_logged_in`` attribute.
| Additional attributes may be available depending on the configuration of
| the user's Google account. For more information about Google's identity
| tokens, see `Obtain user information from the ID token
| <https://developers.google.com/identity/openid-connect/openid-connect#obtainuserinfo>`_
| in Google's docs.
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| if st.user.is_logged_in:
| st.write(st.user)
|
| Displayed data when a user is logged in:
|
| .. code-block:: json
|
| {
| "is_logged_in":true
| "iss":"https://accounts.google.com"
| "azp":"{client_id}.apps.googleusercontent.com"
| "aud":"{client_id}.apps.googleusercontent.com"
| "sub":"{unique_user_id}"
| "email":"{user}@gmail.com"
| "email_verified":true
| "at_hash":"{access_token_hash}"
| "nonce":"{nonce_string}"
| "name":"{full_name}"
| "picture":"https://lh3.googleusercontent.com/a/{content_path}"
| "given_name":"{given_name}"
| "family_name":"{family_name}"
| "iat":{issued_time}
| "exp":{expiration_time}
| "tokens":{}
| }
|
| **Example 2: Microsoft's identity token**
|
| If you configure a basic Microsoft OIDC connection as shown in Example 2 of
| ``st.login()``, the following data is available in
| ``st.user``. For more information about Microsoft's identity
| tokens, see `ID token claims reference
| <https://learn.microsoft.com/en-us/entra/identity-platform/id-token-claims-reference>`_
| in Microsoft's docs.
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| if st.user.is_logged_in:
| st.write(st.user)
|
| Displayed data when a user is logged in:
|
| .. code-block:: json
|
| {
| "is_logged_in":true
| "ver":"2.0"
| "iss":"https://login.microsoftonline.com/{tenant_id}/v2.0"
| "sub":"{application_user_id}"
| "aud":"{application_id}"
| "exp":{expiration_time}
| "iat":{issued_time}
| "nbf":{start_time}
| "name":"{full_name}"
| "preferred_username":"{username}"
| "oid":"{user_GUID}"
| "email":"{email}"
| "tid":"{tenant_id}"
| "nonce":"{nonce_string}"
| "aio":"{opaque_string}"
| "tokens":{}
| }
|
| Method resolution order:
| UserInfoProxy
| collections.abc.Mapping
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| __getattr__(self, key: 'str') -> 'str | bool | TokensProxy | None'
|
| __getitem__(self, key: 'str') -> 'str | bool | TokensProxy | None'
|
| __iter__(self) -> 'Iterator[str]'
|
| __len__(self) -> 'int'
|
| __setattr__(self, name: 'str', value: 'str | None') -> 'NoReturn'
| Implement setattr(self, name, value).
|
| __setitem__(self, name: 'str', value: 'str | None') -> 'NoReturn'
|
| to_dict(self) -> 'UserInfoType'
| Get user info as a dictionary.
|
| This method primarily exists for internal use and is not needed for
| most cases. ``st.user`` returns an object that inherits from
| ``dict`` by default.
|
| Returns
| -------
| Dict[str,str]
| A dictionary of the current user's information.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| tokens
| Access exposed tokens via a dict-like object.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __orig_bases__ = (collections.abc.Mapping[str, str | bool | streamlit....
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Mapping:
|
| __contains__(self, key)
|
| __eq__(self, other)
| Return self==value.
|
| get(self, key, default=None)
| D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
|
| items(self)
| D.items() -> a set-like object providing a view on D's items
|
| keys(self)
| D.keys() -> a set-like object providing a view on D's keys
|
| values(self)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from collections.abc.Mapping:
|
| __hash__ = None
|
| __reversed__ = None
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Collection:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
streamlit.user_info
Python Library Documentation: module streamlit.user_info in streamlit
NAME
streamlit.user_info
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
CLASSES
collections.abc.Mapping(collections.abc.Collection)
TokensProxy
UserInfoProxy
class TokensProxy(collections.abc.Mapping)
| TokensProxy(tokens: 'dict[str, str]') -> 'None'
|
| A read-only, dict-like object for accessing exposed tokens from the identity provider.
|
| This class provides access to tokens that have been explicitly exposed via
| the ``expose_tokens`` setting in your authentication configuration. Tokens
| contain sensitive credentials that your app can use to authenticate with
| external services on behalf of the logged-in user.
|
| To expose tokens in ``st.user.tokens``, add the ``expose_tokens`` parameter to your authentication
| configuration in ``.streamlit/secrets.toml``. ``expose_tokens`` must be in
| the ``[auth]`` section and can't be a nested dictionary. You can specify a
| single token type as a string or multiple token types as a list. Streamlit
| supports exposing ``"id"`` tokens and ``"access"`` tokens. If
| ``expose_tokens`` isn't configured, ``st.user.tokens`` is an empty dict.
|
| .. warning::
| Tokens are sensitive credentials that should be handled securely. Never
| expose tokens in your app's UI, logs, or error messages. Only use tokens
| for server-side API calls, and be mindful of token expiration times.
| Only expose tokens if your app needs them for specific API integrations.
|
| You can access token values using either key or attribute notation. For
| example, use ``st.user.tokens["id"]`` or ``st.user.tokens.id`` to access
| the ``id`` token. The object is read-only to prevent accidental modification of sensitive
| credentials.
|
| Attributes
| ----------
| id : str
| The identity token. This is only available if ``"id"`` is in ``expose_tokens``.
| access : str
| The access token. This is only available if ``"access"`` is in ``expose_tokens``.
|
| Examples
| --------
| **Example 1: Expose the ID token**
|
| To expose only the identity token, add ``expose_tokens`` to your
| authentication configuration. This example uses an unnamed default provider.
|
| .. code-block:: toml
| :filename: .streamlit/secrets.toml
|
| [auth]
| redirect_uri = "http://localhost:8501/oauth2callback"
| cookie_secret = "xxx"
| client_id = "xxx"
| client_secret = "xxx"
| server_metadata_url = "https://accounts.google.com/.well-known/openid-configuration"
| expose_tokens = "id"
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| if st.user.is_logged_in:
| id_token = st.user.tokens["id"]
| # Use the token for API verification
|
| **Example 2: Expose both ID and access tokens**
|
| You can use a list to expose multiple tokens. If you use one or more named
| identity providers, the same tokens must be exposed for all providers in
| the shared ``[auth]`` section.
|
| .. code-block:: toml
| :filename: .streamlit/secrets.toml
|
| [auth]
| redirect_uri = "http://localhost:8501/oauth2callback"
| cookie_secret = "xxx"
| expose_tokens = ["id", "access"]
|
| [auth.google]
| client_id = "xxx"
| client_secret = "xxx"
| server_metadata_url = "https://accounts.google.com/.well-known/openid-configuration"
|
| [auth.microsoft]
| client_id = "xxx"
| client_secret = "xxx"
| server_metadata_url = "https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration"
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| if st.user.is_logged_in:
| id_token = st.user.tokens["id"]
| access_token = st.user.tokens["access"]
| # Use the tokens for API verification
|
| Method resolution order:
| TokensProxy
| collections.abc.Mapping
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| __getattr__(self, key: 'str') -> 'str'
|
| __getitem__(self, key: 'str') -> 'str'
|
| __init__(self, tokens: 'dict[str, str]') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self) -> 'Iterator[str]'
|
| __len__(self) -> 'int'
|
| __setattr__(self, name: 'str', value: 'Any') -> 'None'
| Implement setattr(self, name, value).
|
| __setitem__(self, name: 'str', value: 'Any') -> 'None'
|
| to_dict(self) -> 'dict[str, str]'
| Return the token mapping as a standard dictionary.
|
| Returns
| -------
| dict[str, str]
| A dictionary mapping token names to token values.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __orig_bases__ = (collections.abc.Mapping[str, str],)
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Mapping:
|
| __contains__(self, key)
|
| __eq__(self, other)
| Return self==value.
|
| get(self, key, default=None)
| D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
|
| items(self)
| D.items() -> a set-like object providing a view on D's items
|
| keys(self)
| D.keys() -> a set-like object providing a view on D's keys
|
| values(self)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from collections.abc.Mapping:
|
| __hash__ = None
|
| __reversed__ = None
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Collection:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
class UserInfoProxy(collections.abc.Mapping)
| A read-only, dict-like object for accessing information about the current user.
|
| ``st.user`` is dependent on the host platform running your
| Streamlit app. If your host platform has not configured the object,
| ``st.user`` will behave as it does in a locally running app.
|
| When authentication is configured in ``secrets.toml``, Streamlit will parse
| the OpenID Connect (OIDC) identity token and copy the attributes to
| ``st.user``. Check your provider's documentation for their
| available attributes (known as claims).
|
| When authentication is not configured, ``st.user`` has no
| attributes.
|
| You can access values via key or attribute notation. For example, use
| ``st.user["email"]`` or ``st.user.email`` to
| access the ``email`` attribute.
|
| .. Important::
| Identity tokens include an issuance and expiration time. Streamlit does
| not implicitly check these. If you want to automatically expire a
| user's authentication, check these values manually and programmatically
| log out your user (``st.logout()``) when needed.
|
| Attributes
| ----------
| is_logged_in : bool
| Whether a user is logged in. For a locally running app, this attribute
| is only available when authentication (``st.login()``) is configured in
| ``secrets.toml``. Otherwise, it does not exist.
| tokens : TokensProxy
| A read-only, dict-like object for accessing exposed tokens from the
| identity provider.
|
| Examples
| --------
| **Example 1: Google's identity token**
|
| If you configure a basic Google OIDC connection as shown in Example 1 of
| ``st.login()``, the following data is available in
| ``st.user``. Streamlit adds the ``is_logged_in`` attribute.
| Additional attributes may be available depending on the configuration of
| the user's Google account. For more information about Google's identity
| tokens, see `Obtain user information from the ID token
| <https://developers.google.com/identity/openid-connect/openid-connect#obtainuserinfo>`_
| in Google's docs.
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| if st.user.is_logged_in:
| st.write(st.user)
|
| Displayed data when a user is logged in:
|
| .. code-block:: json
|
| {
| "is_logged_in":true
| "iss":"https://accounts.google.com"
| "azp":"{client_id}.apps.googleusercontent.com"
| "aud":"{client_id}.apps.googleusercontent.com"
| "sub":"{unique_user_id}"
| "email":"{user}@gmail.com"
| "email_verified":true
| "at_hash":"{access_token_hash}"
| "nonce":"{nonce_string}"
| "name":"{full_name}"
| "picture":"https://lh3.googleusercontent.com/a/{content_path}"
| "given_name":"{given_name}"
| "family_name":"{family_name}"
| "iat":{issued_time}
| "exp":{expiration_time}
| "tokens":{}
| }
|
| **Example 2: Microsoft's identity token**
|
| If you configure a basic Microsoft OIDC connection as shown in Example 2 of
| ``st.login()``, the following data is available in
| ``st.user``. For more information about Microsoft's identity
| tokens, see `ID token claims reference
| <https://learn.microsoft.com/en-us/entra/identity-platform/id-token-claims-reference>`_
| in Microsoft's docs.
|
| .. code-block:: python
| :filename: streamlit_app.py
|
| import streamlit as st
|
| if st.user.is_logged_in:
| st.write(st.user)
|
| Displayed data when a user is logged in:
|
| .. code-block:: json
|
| {
| "is_logged_in":true
| "ver":"2.0"
| "iss":"https://login.microsoftonline.com/{tenant_id}/v2.0"
| "sub":"{application_user_id}"
| "aud":"{application_id}"
| "exp":{expiration_time}
| "iat":{issued_time}
| "nbf":{start_time}
| "name":"{full_name}"
| "preferred_username":"{username}"
| "oid":"{user_GUID}"
| "email":"{email}"
| "tid":"{tenant_id}"
| "nonce":"{nonce_string}"
| "aio":"{opaque_string}"
| "tokens":{}
| }
|
| Method resolution order:
| UserInfoProxy
| collections.abc.Mapping
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| __getattr__(self, key: 'str') -> 'str | bool | TokensProxy | None'
|
| __getitem__(self, key: 'str') -> 'str | bool | TokensProxy | None'
|
| __iter__(self) -> 'Iterator[str]'
|
| __len__(self) -> 'int'
|
| __setattr__(self, name: 'str', value: 'str | None') -> 'NoReturn'
| Implement setattr(self, name, value).
|
| __setitem__(self, name: 'str', value: 'str | None') -> 'NoReturn'
|
| to_dict(self) -> 'UserInfoType'
| Get user info as a dictionary.
|
| This method primarily exists for internal use and is not needed for
| most cases. ``st.user`` returns an object that inherits from
| ``dict`` by default.
|
| Returns
| -------
| Dict[str,str]
| A dictionary of the current user's information.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| tokens
| Access exposed tokens via a dict-like object.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __orig_bases__ = (collections.abc.Mapping[str, str | bool | streamlit....
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Mapping:
|
| __contains__(self, key)
|
| __eq__(self, other)
| Return self==value.
|
| get(self, key, default=None)
| D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
|
| items(self)
| D.items() -> a set-like object providing a view on D's items
|
| keys(self)
| D.keys() -> a set-like object providing a view on D's keys
|
| values(self)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from collections.abc.Mapping:
|
| __hash__ = None
|
| __reversed__ = None
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Collection:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
FUNCTIONS
generate_login_redirect_url(provider: 'str') -> 'str'
Generate the login redirect URL for the given provider.
login(provider: 'str | None' = None) -> 'None'
Initiate the login flow for the given provider.
This command redirects the user to an OpenID Connect (OIDC) provider. After
the user authenticates their identity, they are redirected back to the
home page of your app. Streamlit stores a cookie with the user's identity
information in the user's browser . You can access the identity information
through |st.user|_. Call ``st.logout()`` to remove the cookie
and start a new session.
You can use any OIDC provider, including Google, Microsoft, Okta, and more.
You must configure the provider through secrets management. Although OIDC
is an extension of OAuth 2.0, you can't use generic OAuth providers.
Streamlit parses the user's identity token and surfaces its attributes in
``st.user``. If the provider returns an access token, that
token is ignored unless you explicitly expose it.
For all providers, there are three shared settings, ``redirect_uri``,
``cookie_secret``, and ``expose_tokens``, which you must specify in an
``[auth]`` dictionary in ``secrets.toml``. Other settings must be defined
as described in the ``provider`` parameter.
- ``redirect_uri`` is your app's absolute URL with the pathname
``oauth2callback``. For local development using the default port, this is
``http://localhost:8501/oauth2callback``.
- ``cookie_secret`` should be a strong, randomly generated secret.
- ``expose_tokens`` is a list of token types to expose. The supported token
types are ``"id"`` and ``"access"``. This is an optional setting, and no
tokens are exposed by default. For information and examples about exposing
tokens, see |st.user|_.
In addition to the shared settings, the following settings are required:
- ``client_id``
- ``client_secret``
- ``server_metadata_url``
For a complete list of OIDC parameters, see `OpenID Connect Core
<https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest>`_ and
your provider's documentation. By default, Streamlit sets
``scope="openid profile email"`` and ``prompt="select_account"``. You can
change these and other OIDC parameters by passing a dictionary of settings
to ``client_kwargs``. ``state`` and ``nonce``, which are used for
security, are handled automatically and don't need to be specified. For
more information, see Example 4.
.. Important::
- You must install ``Authlib>=1.3.2`` to use this command. You can
install it as an extra with Streamlit:
.. code-block:: shell
pip install streamlit[auth]
- Your authentication configuration is dependent on your host location.
When you deploy your app, remember to update your ``redirect_uri``
within your app and your provider.
- All URLs declared in the settings must be absolute (i.e., begin with
``http://`` or ``https://``).
- Streamlit automatically enables CORS and XSRF protection when you
configure authentication in ``secrets.toml``. This takes precedence
over configuration options in ``config.toml``.
- If a user is logged into your app and opens a new tab in the same
browser, they will automatically be logged in to the new session with
the same account.
- If a user closes your app without logging out, the identity cookie
will expire after 30 days.
- For security reasons, authentication is not supported for embedded
apps.
.. |st.user| replace:: ``st.user``
.. _st.user: https://docs.streamlit.io/develop/api-reference/user/st.user
Parameters
----------
provider: str or None
The name of your provider configuration to use for login.
If ``provider`` is ``None`` (default), Streamlit will use all settings
in the ``[auth]`` dictionary within your app's ``secrets.toml`` file.
Otherwise, use an ``[auth.{provider}]`` dictionary for the named
provider, as shown in the examples that follow. When you pass a string
to ``provider``, Streamlit will use ``redirect_uri`` and
``cookie_secret``, while ignoring any other values in the ``[auth]``
dictionary.
Due to internal implementation details, Streamlit does not support
using an underscore within ``provider`` at this time.
Examples
--------
**Example 1: Use an unnamed default identity provider**
If you do not specify a name for your provider, specify all settings within
the ``[auth]`` dictionary of your ``secrets.toml`` file. The following
example configures Google as the default provider. For information about
using OIDC with Google, see `Google Identity
<https://developers.google.com/identity/openid-connect/openid-connect>`_.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[auth]
redirect_uri = "http://localhost:8501/oauth2callback"
cookie_secret = "xxx"
client_id = "xxx"
client_secret = "xxx"
server_metadata_url = "https://accounts.google.com/.well-known/openid-configuration" # fmt: skip
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
if not st.user.is_logged_in:
if st.button("Log in"):
st.login()
else:
if st.button("Log out"):
st.logout()
st.write(f"Hello, {st.user.name}!")
**Example 2: Use a named identity provider**
If you specify a name for your provider, save the shared settings in the
``[auth]`` dictionary of your ``secrets.toml`` file, and save the other
settings in an ``[auth.{provider}]`` dictionary, where ``{provider}`` is
the name of your provider. The following example configures Microsoft as
the provider. The example uses ``provider="microsoft"``, but you can use
any name. This name is internal to Streamlit and is used to match the login
command to its configuration. For information about using OIDC with
Microsoft, see `Microsoft Entra ID
<https://learn.microsoft.com/en-us/power-pages/security/authentication/openid-settings>`_.
To configure your ``{tenant}`` value in ``server_metadata_url``, see
`Microsoft identity platform
<https://learn.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc#find-your-apps-openid-configuration-document-uri>`_.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[auth]
redirect_uri = "http://localhost:8501/oauth2callback"
cookie_secret = "xxx"
[auth.microsoft]
client_id = "xxx"
client_secret = "xxx"
server_metadata_url = "https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration"
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
if not st.user.is_logged_in:
st.login("microsoft")
else:
st.write(f"Hello, {st.user.name}!")
**Example 3: Use multiple, named providers**
If you want to give your users a choice of authentication methods,
configure multiple providers and give them each a unique name. The
following example lets users choose between Okta and Microsoft to log in.
Always check with your identity provider to understand the structure of
their identity tokens because the returned fields may differ. Remember to
set ``{tenant}`` and ``{subdomain}`` in ``server_metadata_url`` for
Microsoft and Okta, respectively.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[auth]
redirect_uri = "http://localhost:8501/oauth2callback"
cookie_secret = "xxx"
[auth.microsoft]
client_id = "xxx"
client_secret = "xxx"
server_metadata_url = "https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration"
[auth.okta]
client_id = "xxx"
client_secret = "xxx"
server_metadata_url = "https://{subdomain}.okta.com/.well-known/openid-configuration"
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
if not st.user.is_logged_in:
st.header("Log in:")
if st.button("Microsoft"):
st.login("microsoft")
if st.button("Okta"):
st.login("okta")
else:
if st.button("Log out"):
st.logout()
st.write(f"Hello, {st.user.name}!")
**Example 4: Change the default connection settings**
``prompt="select_account"`` may be treated differently by some
providers when a user is already logged into their account. If a user is
logged into their Google or Microsoft account from a previous session, the
provider will prompt them to select the account they want to use, even if
it's the only one. However, if the user is logged into their Okta or Auth0
account from a previous session, the account will automatically be
selected. ``st.logout()`` does not clear a user's related cookies. To force
users to log in every time, use ``prompt="login"`` as described in Auth0's
`Customize Signup and Login Prompts
<https://auth0.com/docs/customize/login-pages/universal-login/customize-signup-and-login-prompts>`_.
.. code-block:: toml
:filename: .streamlit/secrets.toml
[auth]
redirect_uri = "http://localhost:8501/oauth2callback"
cookie_secret = "xxx"
[auth.auth0]
client_id = "xxx"
client_secret = "xxx"
server_metadata_url = "https://{account}.{region}.auth0.com/.well-known/openid-configuration"
client_kwargs = { "prompt" = "login" }
.. code-block:: python
:filename: streamlit_app.py
import streamlit as st
if st.button("Log in"):
st.login("auth0")
if st.user.is_logged_in:
if st.button("Log out"):
st.logout()
st.write(f"Hello, {st.user.name}!)
logout() -> 'None'
Logout the current user.
This command removes the user's information from ``st.user``,
deletes their identity cookie, and redirects them to perform a proper
logout from the OAuth provider (if available) before returning to your
app's home page. This creates a new session.
If the user has multiple sessions open in the same browser,
``st.user`` will not be cleared in any other session.
``st.user`` only reads from the identity cookie at the start
of a session. After a session is running, you must call ``st.login()`` or
``st.logout()`` within that session to update ``st.user``.
.. Note::
If the OAuth provider supports OIDC end_session_endpoint in their
server metadata, the user will be logged out from the identity provider
as well. If not available, only local logout is performed.
Example
-------
``.streamlit/secrets.toml``:
>>> [auth]
>>> redirect_uri = "http://localhost:8501/oauth2callback"
>>> cookie_secret = "xxx"
>>> client_id = "xxx"
>>> client_secret = "xxx"
>>> server_metadata_url = "https://accounts.google.com/.well-known/openid-configuration" # fmt: skip
Your app code:
>>> import streamlit as st
>>>
>>> if not st.user.is_logged_in:
>>> if st.button("Log in"):
>>> st.login()
>>> else:
>>> if st.button("Log out"):
>>> st.logout()
>>> st.write(f"Hello, {st.user.name}!")
DATA
AUTH_LOGIN_ENDPOINT = '/auth/login'
AUTH_LOGOUT_ENDPOINT = '/auth/logout'
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
NoReturn = typing.NoReturn
Special type indicating functions that never return.
Example::
from typing import NoReturn
def stop() -> NoReturn:
raise Exception('no way')
NoReturn can also be used as a bottom type, a type that
has no values. Starting in Python 3.11, the Never type should
be used for this concept instead. Type checkers should treat the two
equivalently.
TYPE_CHECKING = False
__annotations__ = {'AUTH_LOGIN_ENDPOINT': 'Final', 'AUTH_LOGOUT_ENDPOI...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\user_info.py
streamlit.util
Python Library Documentation: module streamlit.util in streamlit
NAME
streamlit.util - A bunch of useful utilities.
CLASSES
builtins.dict(builtins.object)
AttributeDictionary
ReadOnlyAttributeDictionary
class AttributeDictionary(builtins.dict)
| A dictionary subclass that supports attribute-style access.
|
| This class extends the functionality of a standard dictionary to allow items
| to be accessed via attribute-style dot notation in addition to the traditional
| key-based access. If a dictionary item is accessed and is itself a dictionary,
| it is automatically wrapped in another `AttributeDictionary`, enabling recursive
| attribute-style access.
|
| Method resolution order:
| AttributeDictionary
| builtins.dict
| builtins.object
|
| Methods defined here:
|
| __getattr__(self, key: 'str') -> 'Any'
|
| __setattr__(self, name: 'str', value: 'Any') -> 'None'
| Implement setattr(self, name, value).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __orig_bases__ = (dict[typing.Any, typing.Any],)
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.dict:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| D.clear() -> None. Remove all items from D.
|
| copy(...)
| D.copy() -> a shallow copy of D
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| pop(...)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(...)
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods inherited from builtins.dict:
|
| __class_getitem__(...)
| See PEP 585
|
| fromkeys(iterable, value=None, /)
| Create a new dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.dict:
|
| __new__(*args, **kwargs) class method of builtins.dict
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from builtins.dict:
|
| __hash__ = None
class ReadOnlyAttributeDictionary(AttributeDictionary)
| Read-only dictionary subclass with attribute-style access.
|
| Similar to AttributeDictionary, but raises TypeError on any mutation attempt.
| Used for widget state return values (e.g., dataframe selections) to prevent
| users from modifying values in ways that don't trigger proper state updates.
|
| Modifications should be done by assigning a new dictionary to the session
| state key, e.g., ``st.session_state['key'] = {'selection': {'rows': [0]}}``.
|
| Method resolution order:
| ReadOnlyAttributeDictionary
| AttributeDictionary
| builtins.dict
| builtins.object
|
| Methods defined here:
|
| __copy__(self) -> 'ReadOnlyAttributeDictionary'
|
| __deepcopy__(self, memo: 'dict[Any, Any]') -> 'ReadOnlyAttributeDictionary'
|
| __delitem__(self, key: 'Any') -> 'None'
| Delete self[key].
|
| __getattr__(self, key: 'str') -> 'Any'
|
| __getitem__(self, key: 'Any') -> 'Any'
| Return self[key].
|
| __ior__(self, other: 'Any') -> 'ReadOnlyAttributeDictionary'
| Return self|=value.
|
| __setattr__(self, name: 'str', value: 'Any') -> 'None'
| Implement setattr(self, name, value).
|
| __setitem__(self, key: 'Any', value: 'Any') -> 'None'
| Set self[key] to value.
|
| clear(self) -> 'None'
| D.clear() -> None. Remove all items from D.
|
| pop(self, *args: 'Any') -> 'Any'
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self) -> 'tuple[Any, Any]'
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key: 'Any', default: 'Any' = None) -> 'Any'
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(self, *args: 'Any', **kwargs: 'Any') -> 'None'
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| ----------------------------------------------------------------------
| Data descriptors inherited from AttributeDictionary:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from AttributeDictionary:
|
| __orig_bases__ = (dict[typing.Any, typing.Any],)
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.dict:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __gt__(self, value, /)
| Return self>value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| copy(...)
| D.copy() -> a shallow copy of D
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods inherited from builtins.dict:
|
| __class_getitem__(...)
| See PEP 585
|
| fromkeys(iterable, value=None, /)
| Create a new dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.dict:
|
| __new__(*args, **kwargs) class method of builtins.dict
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from builtins.dict:
|
| __hash__ = None
FUNCTIONS
calc_hash(s: 'bytes | str') -> 'str'
Return a fast hash of the given string.
Uses BLAKE2b (~2.4x faster than MD5) and produces 32-character hex digests.
This should not be used for security-related purposes.
create_fast_hasher() -> '_Hash'
Create a fast hasher for incremental hashing.
Uses BLAKE2b which produces 32-character hex digests (16 bytes).
in_sidebar(dg: 'DeltaGenerator') -> 'bool'
Check if the DeltaGenerator is in the sidebar.
memoize(func: 'Callable[..., Any]') -> 'Callable[..., Any]'
Decorator to memoize the result of a no-args func.
repr_(self: 'Any') -> 'str'
A clean repr for a class, excluding both values that are likely defaults,
and those explicitly default for dataclasses.
DATA
RootContainer = <google.protobuf.internal.enum_type_wrapper.EnumTypeWr...
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\util.py
streamlit.vega_lite_chart
Python Library Documentation: method vega_lite_chart in module streamlit.delta_generator
vega_lite_chart(data: 'Data' = None, spec: 'VegaLiteSpec | None' = None, *, width: 'Width | None' = None, height: 'Height' = 'content', use_container_width: 'bool | None' = None, theme: "Literal['streamlit'] | None" = 'streamlit', key: 'Key | None' = None, on_select: "Literal['rerun', 'ignore'] | WidgetCallback" = 'ignore', selection_mode: 'str | Iterable[str] | None' = None) -> 'DeltaGenerator | VegaLiteState' method of streamlit.delta_generator.DeltaGenerator instance
Display a chart using the Vega-Lite library.
`Vega-Lite <https://vega.github.io/vega-lite/>`_ is a high-level
grammar for defining interactive graphics.
Parameters
----------
data : Anything supported by st.dataframe
Either the data to be plotted or a Vega-Lite spec containing the
data (which more closely follows the Vega-Lite API).
spec : dict or None
The Vega-Lite spec for the chart. If ``spec`` is ``None`` (default),
Streamlit uses the spec passed in ``data``. You cannot pass a spec
to both ``data`` and ``spec``. See
https://vega.github.io/vega-lite/docs/ for more info.
width : "stretch", "content", int, or None
The width of the chart element. This can be one of the following:
- ``"stretch"``: The width of the element matches the width of the
parent container.
- ``"content"``: The width of the element matches the width of its
content, but doesn't exceed the width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
- ``None`` (default): Streamlit uses ``"stretch"`` for most charts,
and uses ``"content"`` for the following multi-view charts:
- Facet charts: the spec contains ``"facet"`` or encodings for
``"row"``, ``"column"``, or ``"facet"``.
- Horizontal concatenation charts: the spec contains
``"hconcat"``.
- Repeat charts: the spec contains ``"repeat"``.
- Nested composition charts: the spec contains ``"vconcat"``
with nested ``"hconcat"``, ``"vconcat"``, ``"concat"``, or
``"layer"`` operators (e.g., scatter plots with marginal
histograms).
height : "content", "stretch", or int
The height of the chart element. This can be one of the following:
- ``"content"`` (default): The height of the element matches the
height of its content.
- ``"stretch"``: The height of the element matches the height of
its content or the height of the parent container, whichever is
larger. If the element is not in a parent container, the height
of the element matches the height of its content.
- An integer specifying the height in pixels: The element has a
fixed height. If the content is larger than the specified
height, scrolling is enabled.
use_container_width : bool or None
Whether to override the chart's native width with the width of
the parent container. This can be one of the following:
- ``None`` (default): Streamlit will use the parent container's
width for all charts except those with known incompatibility
(``altair.Facet``, ``altair.HConcatChart``, and
``altair.RepeatChart``).
- ``True``: Streamlit sets the width of the chart to match the
width of the parent container.
- ``False``: Streamlit sets the width of the chart to fit its
contents according to the plotting library, up to the width of
the parent container.
.. deprecated::
``use_container_width`` is deprecated and will be removed in a
future release. For ``use_container_width=True``, use
``width="stretch"``.
theme : "streamlit" or None
The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
Streamlit uses its own design default. If ``theme`` is ``None``,
Streamlit falls back to the default behavior of the library.
The ``"streamlit"`` theme can be partially customized through the
configuration options ``theme.chartCategoricalColors`` and
``theme.chartSequentialColors``. Font configuration options are
also applied.
key : str, int, or None
An optional string to use for giving this element a stable
identity. If this is ``None`` (default), the element's identity
will be determined based on the values of the other parameters.
If selections are activated and ``key`` is provided,
Streamlit will register the key in Session State to store the
selection state. The selection state is read-only. For more
details, see `Widget behavior
<https://docs.streamlit.io/develop/concepts/architecture/widget-behavior>`_.
Additionally, if ``key`` is provided, it will be used as a
CSS class name prefixed with ``st-key-``.
on_select : "ignore", "rerun", or callable
How the figure should respond to user selection events. This
controls whether or not the figure behaves like an input widget.
``on_select`` can be one of the following:
- ``"ignore"`` (default): Streamlit will not react to any selection
events in the chart. The figure will not behave like an input
widget.
- ``"rerun"``: Streamlit will rerun the app when the user selects
data in the chart. In this case, ``st.vega_lite_chart`` will
return the selection data as a dictionary.
- A ``callable``: Streamlit will rerun the app and execute the
``callable`` as a callback function before the rest of the app.
In this case, ``st.vega_lite_chart`` will return the selection data
as a dictionary.
To use selection events, the Vega-Lite spec defined in ``data`` or
``spec`` must include selection parameters from the charting
library. To learn about defining interactions in Vega-Lite, see
`Dynamic Behaviors with Parameters <https://vega.github.io/vega-lite/docs/parameter.html>`_
in Vega-Lite's documentation.
For consistent selection output, especially in multi-view charts
(layer, hconcat, vconcat, facet, repeat), specify ``fields`` or
``encodings`` in your selection, like
``alt.selection_point(fields=["Origin"])`` or
``alt.selection_point(encodings=["x", "y"])``. Without explicit
fields, Vega may add an internal row identifier field (``vgsid``)
to your data, and selections can then return this identifier
instead of your original data values.
selection_mode : str or Iterable of str
The selection parameters Streamlit should use. If
``selection_mode`` is ``None`` (default), Streamlit will use all
selection parameters defined in the chart's Vega-Lite spec.
When Streamlit uses a selection parameter, selections from that
parameter will trigger a rerun and be included in the selection
state. When Streamlit does not use a selection parameter,
selections from that parameter will not trigger a rerun and not be
included in the selection state.
Selection parameters are identified by their ``name`` property.
Returns
-------
element or dict
If ``on_select`` is ``"ignore"`` (default), this command returns an
internal placeholder for the chart element that can be used with
the ``.add_rows()`` method. Otherwise, this command returns a
dictionary-like object that supports both key and attribute
notation. The attributes are described by the ``VegaLiteState``
dictionary schema.
Examples
--------
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(rng(0).standard_normal((60, 3)), columns=["a", "b", "c"])
>>>
>>> st.vega_lite_chart(
... df,
... {
... "mark": {"type": "circle", "tooltip": True},
... "encoding": {
... "x": {"field": "a", "type": "quantitative"},
... "y": {"field": "b", "type": "quantitative"},
... "size": {"field": "c", "type": "quantitative"},
... "color": {"field": "c", "type": "quantitative"},
... },
... },
... )
.. output::
https://doc-vega-lite-chart.streamlit.app/
height: 450px
Examples of Vega-Lite usage without Streamlit can be found at
https://vega.github.io/vega-lite/examples/. Most of those can be easily
translated to the syntax shown above.
streamlit.version
Python Library Documentation: module streamlit.version in streamlit
NAME
streamlit.version
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
DATA
Final = typing.Final
Special typing construct to indicate final names to type checkers.
A final name cannot be re-assigned or overridden in a subclass.
For example::
MAX_SIZE: Final = 9000
MAX_SIZE += 1 # Error reported by type checker
class Connection:
TIMEOUT: Final[int] = 10
class FastConnector(Connection):
TIMEOUT = 1 # Error reported by type checker
There is no runtime checking of these properties.
STREAMLIT_VERSION_STRING = '1.57.0'
__annotations__ = {'STREAMLIT_VERSION_STRING': typing.Final[str]}
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\version.py
streamlit.video
Python Library Documentation: method video in module streamlit.delta_generator
video(data: 'MediaData', format: 'str' = 'video/mp4', start_time: 'MediaTime' = 0, *, subtitles: 'SubtitleData' = None, end_time: 'MediaTime | None' = None, loop: 'bool' = False, autoplay: 'bool' = False, muted: 'bool' = False, width: 'WidthWithoutContent' = 'stretch') -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display a video player.
Parameters
----------
data : str, Path, bytes, io.BytesIO, numpy.ndarray, or file
The video to play. This can be one of the following:
- A URL (string) for a hosted video file, including YouTube URLs.
Also supports ``/app/static/<asset>`` URLs for files served via
`static file serving <https://docs.streamlit.io/develop/concepts/configuration/serving-static-files>`_.
- A path to a local video file. The path can be a ``str``
or ``Path`` object. Paths can be absolute or relative to the
working directory (where you execute ``streamlit run``).
- Raw video data. Raw data formats must include all necessary file
headers to match the file format specified via ``format``.
format : str
The MIME type for the video file. This defaults to ``"video/mp4"``.
For more information about MIME types, see
https://www.iana.org/assignments/media-types/media-types.xhtml.
start_time : int, float, timedelta, str, or None
The time from which the element should start playing. This can be
one of the following:
- ``None`` (default): The element plays from the beginning.
- An ``int`` or ``float`` specifying the time in seconds. ``float``
values are rounded down to whole seconds.
- A string specifying the time in a format supported by `Pandas'
Timedelta constructor <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_,
e.g. ``"2 minute"``, ``"20s"``, or ``"1m14s"``.
- A ``timedelta`` object from `Python's built-in datetime library
<https://docs.python.org/3/library/datetime.html#timedelta-objects>`_,
e.g. ``timedelta(seconds=70)``.
subtitles : str, bytes, Path, io.BytesIO, or dict
Optional subtitle data for the video, supporting several input types:
- ``None`` (default): No subtitles.
- A string, bytes, or Path: File path to a subtitle file in
``.vtt`` or ``.srt`` formats, or the raw content of subtitles
conforming to these formats. Paths can be absolute or relative to
the working directory (where you execute ``streamlit run``).
If providing raw content, the string must adhere to the WebVTT or
SRT format specifications.
- io.BytesIO: A BytesIO stream that contains valid ``.vtt`` or ``.srt``
formatted subtitle data.
- A dictionary: Pairs of labels and file paths or raw subtitle content in
``.vtt`` or ``.srt`` formats to enable multiple subtitle tracks.
The label will be shown in the video player. Example:
``{"English": "path/to/english.vtt", "French": "path/to/french.srt"}``
When provided, subtitles are displayed by default. For multiple
tracks, the first one is displayed by default. If you don't want any
subtitles displayed by default, use an empty string for the value
in a dictrionary's first pair: ``{"None": "", "English": "path/to/english.vtt"}``
Not supported for YouTube videos.
end_time : int, float, timedelta, str, or None
The time at which the element should stop playing. This can be
one of the following:
- ``None`` (default): The element plays through to the end.
- An ``int`` or ``float`` specifying the time in seconds. ``float``
values are rounded down to whole seconds.
- A string specifying the time in a format supported by `Pandas'
Timedelta constructor <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_,
e.g. ``"2 minute"``, ``"20s"``, or ``"1m14s"``.
- A ``timedelta`` object from `Python's built-in datetime library
<https://docs.python.org/3/library/datetime.html#timedelta-objects>`_,
e.g. ``timedelta(seconds=70)``.
loop : bool
Whether the video should loop playback.
autoplay : bool
Whether the video should start playing automatically. This is
``False`` by default. Browsers will not autoplay unmuted videos
if the user has not interacted with the page by clicking somewhere.
To enable autoplay without user interaction, you must also set
``muted=True``.
muted : bool
Whether the video should play with the audio silenced. This is
``False`` by default. Use this in conjunction with ``autoplay=True``
to enable autoplay without user interaction.
width : "stretch" or int
The width of the video player element. This can be one of the
following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
Examples
--------
>>> import streamlit as st
>>>
>>> video_file = open("myvideo.mp4", "rb")
>>> video_bytes = video_file.read()
>>>
>>> st.video(video_bytes)
.. output::
https://doc-video.streamlit.app/
height: 700px
When you include subtitles, they will be turned on by default. A viewer
can turn off the subtitles (or captions) from the browser's default video
control menu, usually located in the lower-right corner of the video.
Here is a simple VTT file (``subtitles.vtt``):
>>> WEBVTT
>>>
>>> 0:00:01.000 --> 0:00:02.000
>>> Look!
>>>
>>> 0:00:03.000 --> 0:00:05.000
>>> Look at the pretty stars!
If the above VTT file lives in the same directory as your app, you can
add subtitles like so:
>>> import streamlit as st
>>>
>>> VIDEO_URL = "https://example.com/not-youtube.mp4"
>>> st.video(VIDEO_URL, subtitles="subtitles.vtt")
.. output::
https://doc-video-subtitles.streamlit.app/
height: 700px
See additional examples of supported subtitle input types in our
`video subtitles feature demo <https://doc-video-subtitle-inputs.streamlit.app/>`_.
.. note::
Some videos may not display if they are encoded using MP4V (which is an export option in OpenCV),
as this codec is not widely supported by browsers. Converting your video to H.264 will allow
the video to be displayed in Streamlit.
See this `StackOverflow post <https://stackoverflow.com/a/49535220/2394542>`_ or this
`Streamlit forum post <https://discuss.streamlit.io/t/st-video-doesnt-show-opencv-generated-mp4/3193/2>`_
for more information.
streamlit.warning
Python Library Documentation: method warning in module streamlit.delta_generator
warning(body: 'SupportsStr', *, icon: 'str | None' = None, width: 'WidthWithoutContent' = 'stretch', title: 'SupportsStr | None' = None) -> 'DeltaGenerator' method of streamlit.delta_generator.DeltaGenerator instance
Display warning message.
Parameters
----------
body : str
The text to display as GitHub-flavored Markdown. Syntax
information can be found at: https://github.github.com/gfm.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
If ``icon`` is ``None``, and ``body`` begins with an emoji or
Material icon shortcode, Streamlit will extract it and display it
slightly enlarged, as if it were passed to ``icon``. If ``body``
contains multiple icons, or you want to override this behavior,
you can insert a null Markdown directive like ``:red[]`` before
your leading icon.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
icon : str or None
An optional emoji or icon to display next to the alert. If ``icon``
is ``None`` (default), Streamlit attempts to extract a leading
emoji or Material icon shortcode from ``body``. If found, the icon
is displayed and removed from the body text. If no leading icon is
found, no icon is displayed. If ``icon`` is a string, it takes
precedence over any icon in the body, and the following options
are valid:
- A single-character emoji. For example, you can set ``icon="🚨"``
or ``icon="🔥"``. Emoji short codes are not supported.
- An icon from the Material Symbols library (rounded style) in the
format ``":material/icon_name:"`` where "icon_name" is the name
of the icon in snake case.
For example, ``icon=":material/thumb_up:"`` will display the
Thumb Up icon. Find additional icons in the `Material Symbols <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
font library.
- ``"spinner"``: Displays a spinner as an icon.
width : "stretch" or int
The width of the warning element. This can be one of the following:
- ``"stretch"`` (default): The width of the element matches the
width of the parent container.
- An integer specifying the width in pixels: The element has a
fixed width. If the specified width is greater than the width of
the parent container, the width of the element matches the width
of the parent container.
title : str or None
An optional title to display above the body text. If ``None``
(default), no title is displayed. The title is rendered with bold
styling and can optionally contain GitHub-flavored Markdown of the
following types: Italics, Strikethroughs, Inline Code, Links, and
Images. Images display like icons, with a max height equal to the
font height.
Unsupported Markdown elements are unwrapped so only their children
(text contents) render. Display elements are not supported.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
Examples
--------
>>> import streamlit as st
>>>
>>> st.warning('This is a warning', icon="⚠️")
streamlit.watcher
Python Library Documentation: package streamlit.watcher in streamlit
NAME
streamlit.watcher
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PACKAGE CONTENTS
event_based_path_watcher
folder_black_list
local_sources_watcher
path_watcher
polling_path_watcher
util
CLASSES
builtins.object
streamlit.watcher.local_sources_watcher.LocalSourcesWatcher
class LocalSourcesWatcher(builtins.object)
| LocalSourcesWatcher(pages_manager: 'PagesManager') -> 'None'
|
| Watch local Python sources and pages to trigger app reruns.
|
| Purpose
| -------
| This watcher powers Streamlit's core developer workflow: save a Python file
| and the app reruns. It tracks Python modules, the main script directory, and
| configured watch folders to notify the runtime when a relevant file changes.
|
| Methods defined here:
|
| __init__(self, pages_manager: 'PagesManager') -> 'None'
| Initialize self. See help(type(self)) for accurate signature.
|
| close(self) -> 'None'
|
| on_path_changed(self, filepath: 'str') -> 'None'
|
| register_file_change_callback(self, cb: 'Callable[[str], None]') -> 'None'
|
| update_watched_modules(self) -> 'None'
|
| update_watched_pages(self) -> 'None'
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
FUNCTIONS
report_watchdog_availability() -> 'None'
watch_dir(path: 'str', on_dir_changed: 'Callable[[str], None]', watcher_type: 'str | None' = None, *, glob_pattern: 'str | None' = None, allow_nonexistent: 'bool' = False) -> 'bool'
Watch a directory for file changes.
The callback is invoked for any file activity within the directory,
including file creation, deletion, and content modifications. The callback
receives the path of the actual changed file (not the directory path).
Note: The glob_pattern parameter only affects the initial state detection
(which files are counted when determining if the directory changed). It does
NOT filter which file events trigger the callback - all file events in the
directory will invoke the callback regardless of glob_pattern.
Parameters
----------
path
Path to the directory to watch.
on_dir_changed
Callback invoked with the changed file path when changes are detected.
watcher_type
Optional watcher type ('watchdog', 'poll', 'auto', or 'none').
glob_pattern
Glob pattern for initial state detection (e.g., "*.py"). Does not
filter runtime events.
allow_nonexistent
If True, watch for directory creation even if it doesn't exist yet.
Returns
-------
bool
True if the watcher was successfully created.
watch_file(path: 'str', on_file_changed: 'Callable[[str], None]', watcher_type: 'str | None' = None, *, allow_nonexistent: 'bool' = False) -> 'bool'
Watch a file for changes.
The callback is invoked when the file's content changes (detected via hash).
If allow_nonexistent is True, the watcher will also detect when the file
is created.
Parameters
----------
path
Path to the file to watch.
on_file_changed
Callback invoked with the file path when changes are detected.
watcher_type
Optional watcher type ('watchdog', 'poll', 'auto', or 'none').
allow_nonexistent
If True, watch for file creation even if the file doesn't exist yet.
Note: The file's parent directory must exist for watching to work.
If the parent directory doesn't exist, the watcher silently skips
watching (the file can't be created without its parent directory).
Returns
-------
bool
True if the watcher was successfully created.
DATA
__all__ = ['LocalSourcesWatcher', 'report_watchdog_availability', 'wat...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\watcher\__init__.py
streamlit.web
Python Library Documentation: package streamlit.web in streamlit
NAME
streamlit.web
DESCRIPTION
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PACKAGE CONTENTS
bootstrap
cache_storage_manager_config
cli
server (package)
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\streamlit\web\__init__.py
streamlit.write
Python Library Documentation: method write in module streamlit.delta_generator
write(*args: 'Any', unsafe_allow_html: 'bool' = False) -> 'None' method of streamlit.delta_generator.DeltaGenerator instance
Displays arguments in the app.
This is the Swiss Army knife of Streamlit commands: it does different
things depending on what you throw at it. Unlike other Streamlit
commands, ``st.write()`` has some unique properties:
- You can pass in multiple arguments, all of which will be displayed.
- Its behavior depends on the input type(s).
Parameters
----------
*args : any
One or many objects to display in the app.
.. list-table:: Each type of argument is handled as follows:
:header-rows: 1
* - Type
- Handling
* - ``str``
- Uses ``st.markdown()``.
* - dataframe-like, ``dict``, or ``list``
- Uses ``st.dataframe()``.
* - ``Exception``
- Uses ``st.exception()``.
* - function, module, or class
- Uses ``st.help()``.
* - ``DeltaGenerator``
- Uses ``st.help()``.
* - Altair chart
- Uses ``st.altair_chart()``.
* - Bokeh figure
- Uses ``st.bokeh_chart()``.
* - Graphviz graph
- Uses ``st.graphviz_chart()``.
* - Keras model
- Converts model and uses ``st.graphviz_chart()``.
* - Matplotlib figure
- Uses ``st.pyplot()``.
* - Plotly figure
- Uses ``st.plotly_chart()``.
* - ``PIL.Image``
- Uses ``st.image()``.
* - generator or stream (like ``openai.Stream``)
- Uses ``st.write_stream()``.
* - SymPy expression
- Uses ``st.latex()``.
* - An object with ``._repr_html()``
- Uses ``st.html()``.
* - Database cursor
- Displays DB API 2.0 cursor results in a table.
* - Any
- Displays ``str(arg)`` as inline code.
unsafe_allow_html : bool
Whether to render HTML within ``*args``. This only applies to
strings or objects falling back on ``_repr_html_()``. If this is
``False`` (default), any HTML tags found in ``body`` will be
escaped and therefore treated as raw text. If this is ``True``, any
HTML expressions within ``body`` will be rendered.
Adding custom HTML to your app impacts safety, styling, and
maintainability.
.. note::
If you only want to insert HTML or CSS without Markdown text,
we recommend using ``st.html`` instead.
Examples
--------
Its basic use case is to draw Markdown-formatted text, whenever the
input is a string:
>>> import streamlit as st
>>>
>>> st.write("Hello, *World!* :sunglasses:")
.. output::
https://doc-write1.streamlit.app/
height: 200px
As mentioned earlier, ``st.write()`` also accepts other data formats, such as
numbers, data frames, styled data frames, and assorted objects:
>>> import streamlit as st
>>> import pandas as pd
>>>
>>> st.write(1234)
>>> st.write(
... pd.DataFrame(
... {
... "first column": [1, 2, 3, 4],
... "second column": [10, 20, 30, 40],
... }
... )
... )
.. output::
https://doc-write2.streamlit.app/
height: 350px
Finally, you can pass in multiple arguments to do things like:
>>> import streamlit as st
>>>
>>> st.write("1 + 1 = ", 2)
>>> st.write("Below is a DataFrame:", data_frame, "Above is a dataframe.")
.. output::
https://doc-write3.streamlit.app/
height: 410px
Oh, one more thing: ``st.write`` accepts chart objects too! For example:
>>> import altair as alt
>>> import pandas as pd
>>> import streamlit as st
>>> from numpy.random import default_rng as rng
>>>
>>> df = pd.DataFrame(rng(0).standard_normal((200, 3)), columns=["a", "b", "c"])
>>> chart = (
... alt.Chart(df)
... .mark_circle()
... .encode(x="a", y="b", size="c", color="c", tooltip=["a", "b", "c"])
... )
>>>
>>> st.write(chart)
.. output::
https://doc-vega-lite-chart.streamlit.app/
height: 300px
streamlit.write_stream
Python Library Documentation: method write_stream in module streamlit.delta_generator
write_stream(stream: 'Callable[..., Any] | Generator[Any, Any, Any] | Iterable[Any] | AsyncGenerator[Any, Any]', *, cursor: 'str | None' = None) -> 'list[Any] | str' method of streamlit.delta_generator.DeltaGenerator instance
Stream a generator, iterable, or stream-like sequence to the app.
``st.write_stream`` iterates through the given sequences and writes all
chunks to the app. String chunks will be written using a typewriter effect.
Other data types will be written using ``st.write``.
Parameters
----------
stream : Callable, Generator, Iterable, OpenAI Stream, or LangChain Stream
The generator or iterable to stream.
If you pass an async generator, Streamlit will internally convert
it to a sync generator. If the generator depends on a cached object
with async references, this can raise an error.
.. note::
To use additional LLM libraries, you can create a wrapper to
manually define a generator function and include custom output
parsing.
cursor : str or None
A string to append to text as it's being written. If this is
``None`` (default), no cursor is shown. Otherwise, the string is
rendered as Markdown and appears as a cursor at the end of the
streamed text. For example, you can use an emoji, emoji shortcode,
or Material icon.
The first line of the cursor string can contain GitHub-flavored
Markdown of the following types: Bold, Italics, Strikethroughs,
Inline Code, Links, and Images. Images display like icons, with a
max height equal to the font height. If you pass a multiline
string, additional lines display after the text with the full
Markdown rendering capabilities of ``st.markdown``.
See the ``body`` parameter of |st.markdown|_ for additional,
supported Markdown directives.
.. |st.markdown| replace:: ``st.markdown``
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
Returns
-------
str or list
The full response. If the streamed output only contains text, this
is a string. Otherwise, this is a list of all the streamed objects.
The return value is fully compatible as input for ``st.write``.
Examples
--------
You can pass an OpenAI stream as shown in our tutorial, `Build a \
basic LLM chat app <https://docs.streamlit.io/develop/tutorials/llms\
/build-conversational-apps#build-a-chatgpt-like-app>`_. Alternatively,
you can pass a generic generator function as input:
>>> import time
>>> import numpy as np
>>> import pandas as pd
>>> import streamlit as st
>>>
>>> _LOREM_IPSUM = \"\"\"
>>> Lorem ipsum dolor sit amet, **consectetur adipiscing** elit, sed do eiusmod tempor
>>> incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
>>> nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
>>> \"\"\"
>>>
>>>
>>> def stream_data():
>>> for word in _LOREM_IPSUM.split(" "):
>>> yield word + " "
>>> time.sleep(0.02)
>>>
>>> yield pd.DataFrame(
>>> np.random.randn(5, 10),
>>> columns=["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"],
>>> )
>>>
>>> for word in _LOREM_IPSUM.split(" "):
>>> yield word + " "
>>> time.sleep(0.02)
>>>
>>>
>>> if st.button("Stream data"):
>>> st.write_stream(stream_data)
.. output::
https://doc-write-stream-data.streamlit.app/
height: 550px