streamlit-nightly 1.37.2.dev20240819__py2.py3-none-any.whl → 1.37.2.dev20240822__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/elements/arrow.py +33 -8
- streamlit/elements/code.py +7 -0
- streamlit/elements/image.py +15 -25
- streamlit/elements/json.py +12 -5
- streamlit/elements/lib/column_types.py +3 -3
- streamlit/elements/lib/policies.py +10 -9
- streamlit/elements/map.py +13 -18
- streamlit/elements/vega_charts.py +6 -14
- streamlit/elements/widgets/button_group.py +2 -2
- streamlit/elements/widgets/data_editor.py +9 -6
- streamlit/elements/widgets/multiselect.py +4 -4
- streamlit/elements/widgets/radio.py +43 -4
- streamlit/elements/widgets/select_slider.py +63 -11
- streamlit/elements/widgets/selectbox.py +4 -4
- streamlit/elements/write.py +1 -1
- streamlit/proto/Code_pb2.py +2 -2
- streamlit/proto/Code_pb2.pyi +4 -1
- streamlit/runtime/caching/__init__.py +1 -11
- streamlit/runtime/caching/cache_data_api.py +10 -81
- streamlit/runtime/caching/cache_errors.py +13 -9
- streamlit/runtime/caching/cache_resource_api.py +8 -56
- streamlit/runtime/caching/cache_utils.py +7 -12
- streamlit/runtime/caching/cached_message_replay.py +29 -185
- streamlit/runtime/caching/legacy_cache_api.py +15 -11
- streamlit/runtime/scriptrunner_utils/script_run_context.py +9 -4
- streamlit/runtime/state/widgets.py +0 -5
- streamlit/static/asset-manifest.json +24 -24
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{1074.0db34d15.chunk.js → 1074.9d1e63cc.chunk.js} +1 -1
- streamlit/static/static/js/{1116.22f8322c.chunk.js → 1116.85ec79d5.chunk.js} +1 -1
- streamlit/static/static/js/{1168.2a9806f0.chunk.js → 1168.7c30158a.chunk.js} +1 -1
- streamlit/static/static/js/1307.2bdac721.chunk.js +1 -0
- streamlit/static/static/js/{1451.d93e956f.chunk.js → 1451.7ff31fc7.chunk.js} +1 -1
- streamlit/static/static/js/1792.d126bbd9.chunk.js +1 -0
- streamlit/static/static/js/3513.5e3a04f2.chunk.js +1 -0
- streamlit/static/static/js/3599.963d0e5a.chunk.js +5 -0
- streamlit/static/static/js/{4335.bc097c4d.chunk.js → 4335.b166a7b6.chunk.js} +1 -1
- streamlit/static/static/js/{4477.edb1d80a.chunk.js → 4477.568118b6.chunk.js} +1 -1
- streamlit/static/static/js/5106.62135ac5.chunk.js +1 -0
- streamlit/static/static/js/{5441.4cdb2690.chunk.js → 5441.63087272.chunk.js} +1 -1
- streamlit/static/static/js/6013.b6375a8d.chunk.js +5 -0
- streamlit/static/static/js/6718.f5745d2b.chunk.js +1 -0
- streamlit/static/static/js/{7175.70728640.chunk.js → 7175.a10184bd.chunk.js} +1 -1
- streamlit/static/static/js/{7323.4e64ad2c.chunk.js → 7323.05e7058a.chunk.js} +2 -2
- streamlit/static/static/js/7602.a6e1d802.chunk.js +1 -0
- streamlit/static/static/js/7702.b905bebd.chunk.js +1 -0
- streamlit/static/static/js/7805.23670b3c.chunk.js +1 -0
- streamlit/static/static/js/8148.8bd2f9d3.chunk.js +1 -0
- streamlit/static/static/js/8536.bdf41383.chunk.js +1 -0
- streamlit/static/static/js/8691.ee55fefc.chunk.js +5 -0
- streamlit/static/static/js/main.33cac65c.js +28 -0
- {streamlit_nightly-1.37.2.dev20240819.dist-info → streamlit_nightly-1.37.2.dev20240822.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.37.2.dev20240819.dist-info → streamlit_nightly-1.37.2.dev20240822.dist-info}/RECORD +59 -59
- {streamlit_nightly-1.37.2.dev20240819.dist-info → streamlit_nightly-1.37.2.dev20240822.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/1307.74a443f7.chunk.js +0 -1
- streamlit/static/static/js/1792.eb8a836f.chunk.js +0 -1
- streamlit/static/static/js/3513.577f3dc5.chunk.js +0 -1
- streamlit/static/static/js/3599.eaeac234.chunk.js +0 -5
- streamlit/static/static/js/4666.0e91bb87.chunk.js +0 -1
- streamlit/static/static/js/5106.4c60cfa4.chunk.js +0 -1
- streamlit/static/static/js/6013.fb4531df.chunk.js +0 -5
- streamlit/static/static/js/6718.6fb2aa21.chunk.js +0 -1
- streamlit/static/static/js/7602.33571c14.chunk.js +0 -1
- streamlit/static/static/js/7805.ba32ae70.chunk.js +0 -1
- streamlit/static/static/js/8148.b905db99.chunk.js +0 -1
- streamlit/static/static/js/8536.b7b2ef90.chunk.js +0 -1
- streamlit/static/static/js/8691.93a29403.chunk.js +0 -5
- streamlit/static/static/js/main.8c6fc86e.js +0 -28
- /streamlit/static/static/js/{7323.4e64ad2c.chunk.js.LICENSE.txt → 7323.05e7058a.chunk.js.LICENSE.txt} +0 -0
- /streamlit/static/static/js/{main.8c6fc86e.js.LICENSE.txt → main.33cac65c.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.37.2.dev20240819.data → streamlit_nightly-1.37.2.dev20240822.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.37.2.dev20240819.dist-info → streamlit_nightly-1.37.2.dev20240822.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.37.2.dev20240819.dist-info → streamlit_nightly-1.37.2.dev20240822.dist-info}/top_level.txt +0 -0
streamlit/elements/arrow.py
CHANGED
@@ -271,21 +271,46 @@ class ArrowMixin:
|
|
271
271
|
) -> DeltaGenerator | DataframeState:
|
272
272
|
"""Display a dataframe as an interactive table.
|
273
273
|
|
274
|
-
This command works with
|
275
|
-
|
276
|
-
e.g. numpy arrays, lists, sets and dictionaries.
|
274
|
+
This command works with a wide variety of collection-like and
|
275
|
+
dataframe-like object types.
|
277
276
|
|
278
277
|
Parameters
|
279
278
|
----------
|
280
|
-
data :
|
281
|
-
pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, \
|
282
|
-
snowflake.snowpark.table.Table, Iterable, dict, or None
|
279
|
+
data : dataframe-like, collection-like, or None
|
283
280
|
The data to display.
|
284
281
|
|
282
|
+
Dataframe-like objects include dataframe and series objects from
|
283
|
+
popular libraries like Dask, Modin, Numpy, pandas, Polars, PyArrow,
|
284
|
+
Snowpark, Xarray, and more. You can use database cursors and
|
285
|
+
clients that comply with the
|
286
|
+
`Python Database API Specification v2.0 (PEP 249)
|
287
|
+
<https://peps.python.org/pep-0249/>`_. Additionally, you can use
|
288
|
+
anything that supports the `Python dataframe interchange protocol
|
289
|
+
<https://data-apis.org/dataframe-protocol/latest/>`_.
|
290
|
+
|
291
|
+
For example, you can use the following:
|
292
|
+
|
293
|
+
- ``pandas.DataFrame``, ``pandas.Series``, ``pandas.Index``,
|
294
|
+
``pandas.Styler``, and ``pandas.Array``
|
295
|
+
- ``polars.DataFrame``, ``polars.LazyFrame``, and ``polars.Series``
|
296
|
+
- ``snowflake.snowpark.dataframe.DataFrame``,
|
297
|
+
``snowflake.snowpark.table.Table``
|
298
|
+
|
299
|
+
If a dataype is not recognized, Streamlit will convert the object
|
300
|
+
to a ``pandas.DataFrame`` or ``pyarrow.Table`` using a
|
301
|
+
``.to_pandas()`` or ``.to_arrow()`` method, respectively, if
|
302
|
+
available.
|
303
|
+
|
285
304
|
If ``data`` is a ``pandas.Styler``, it will be used to style its
|
286
305
|
underlying ``pandas.DataFrame``. Streamlit supports custom cell
|
287
306
|
values and colors. It does not support some of the more exotic
|
288
|
-
|
307
|
+
styling options, like bar charts, hovering, and captions. For
|
308
|
+
these styling options, use column configuration instead.
|
309
|
+
|
310
|
+
Collection-like objects include all Python-native ``Collection``
|
311
|
+
types, such as ``dict``, ``list``, and ``set``.
|
312
|
+
|
313
|
+
If ``data`` is ``None``, Streamlit renders an empty table.
|
289
314
|
|
290
315
|
width : int or None
|
291
316
|
Desired width of the dataframe expressed in pixels. If ``width`` is
|
@@ -581,7 +606,7 @@ class ArrowMixin:
|
|
581
606
|
|
582
607
|
Parameters
|
583
608
|
----------
|
584
|
-
data :
|
609
|
+
data : Anything supported by st.dataframe
|
585
610
|
The table data.
|
586
611
|
|
587
612
|
Example
|
streamlit/elements/code.py
CHANGED
@@ -31,7 +31,9 @@ class CodeMixin:
|
|
31
31
|
self,
|
32
32
|
body: SupportsStr,
|
33
33
|
language: str | None = "python",
|
34
|
+
*,
|
34
35
|
line_numbers: bool = False,
|
36
|
+
wrap_lines: bool = False,
|
35
37
|
) -> DeltaGenerator:
|
36
38
|
"""Display a code block with optional syntax highlighting.
|
37
39
|
|
@@ -52,6 +54,10 @@ class CodeMixin:
|
|
52
54
|
An optional boolean indicating whether to show line numbers to the
|
53
55
|
left of the code block. Defaults to ``False``.
|
54
56
|
|
57
|
+
wrap_lines : bool
|
58
|
+
An optional boolean indicating whether to wrap lines. Defaults
|
59
|
+
to ``False``.
|
60
|
+
|
55
61
|
Example
|
56
62
|
-------
|
57
63
|
>>> import streamlit as st
|
@@ -65,6 +71,7 @@ class CodeMixin:
|
|
65
71
|
code_proto.code_text = clean_text(body)
|
66
72
|
code_proto.language = language or "plaintext"
|
67
73
|
code_proto.show_line_numbers = line_numbers
|
74
|
+
code_proto.wrap_lines = wrap_lines
|
68
75
|
return self.dg._enqueue("code", code_proto)
|
69
76
|
|
70
77
|
@property
|
streamlit/elements/image.py
CHANGED
@@ -25,7 +25,7 @@ import io
|
|
25
25
|
import os
|
26
26
|
import re
|
27
27
|
from enum import IntEnum
|
28
|
-
from typing import TYPE_CHECKING, Final,
|
28
|
+
from typing import TYPE_CHECKING, Final, Literal, Sequence, Union, cast
|
29
29
|
|
30
30
|
from typing_extensions import TypeAlias
|
31
31
|
|
@@ -54,7 +54,7 @@ PILImage: TypeAlias = Union[
|
|
54
54
|
"ImageFile.ImageFile", "Image.Image", "GifImagePlugin.GifImageFile"
|
55
55
|
]
|
56
56
|
AtomicImage: TypeAlias = Union[PILImage, "npt.NDArray[Any]", io.BytesIO, str, bytes]
|
57
|
-
ImageOrImageList: TypeAlias = Union[AtomicImage,
|
57
|
+
ImageOrImageList: TypeAlias = Union[AtomicImage, Sequence[AtomicImage]]
|
58
58
|
UseColumnWith: TypeAlias = Union[Literal["auto", "always", "never"], bool, None]
|
59
59
|
Channels: TypeAlias = Literal["RGB", "BGR"]
|
60
60
|
ImageFormat: TypeAlias = Literal["JPEG", "PNG", "GIF"]
|
@@ -178,14 +178,11 @@ class ImageMixin:
|
|
178
178
|
|
179
179
|
|
180
180
|
def _image_may_have_alpha_channel(image: PILImage) -> bool:
|
181
|
-
|
182
|
-
return True
|
183
|
-
else:
|
184
|
-
return False
|
181
|
+
return image.mode in ("RGBA", "LA", "P")
|
185
182
|
|
186
183
|
|
187
184
|
def _image_is_gif(image: PILImage) -> bool:
|
188
|
-
return
|
185
|
+
return image.format == "GIF"
|
189
186
|
|
190
187
|
|
191
188
|
def _validate_image_format_string(
|
@@ -199,7 +196,7 @@ def _validate_image_format_string(
|
|
199
196
|
"GIF" if the image is a GIF, and "JPEG" otherwise.
|
200
197
|
"""
|
201
198
|
format = format.upper()
|
202
|
-
if format
|
199
|
+
if format in {"JPEG", "PNG"}:
|
203
200
|
return cast(ImageFormat, format)
|
204
201
|
|
205
202
|
# We are forgiving on the spelling of JPEG
|
@@ -509,30 +506,23 @@ def marshall_images(
|
|
509
506
|
|
510
507
|
# Turn single image and caption into one element list.
|
511
508
|
images: Sequence[AtomicImage]
|
512
|
-
if isinstance(image, list):
|
513
|
-
images = image
|
509
|
+
if isinstance(image, (list, set, tuple)):
|
510
|
+
images = list(image)
|
514
511
|
elif isinstance(image, np.ndarray) and len(cast(NumpyShape, image.shape)) == 4:
|
515
512
|
images = _4d_to_list_3d(image)
|
516
513
|
else:
|
517
|
-
images = [image]
|
514
|
+
images = [image] # type: ignore
|
518
515
|
|
519
516
|
if isinstance(caption, list):
|
520
517
|
captions: Sequence[str | None] = caption
|
518
|
+
elif isinstance(caption, str):
|
519
|
+
captions = [caption]
|
520
|
+
elif isinstance(caption, np.ndarray) and len(cast(NumpyShape, caption.shape)) == 1:
|
521
|
+
captions = caption.tolist()
|
522
|
+
elif caption is None:
|
523
|
+
captions = [None] * len(images)
|
521
524
|
else:
|
522
|
-
|
523
|
-
captions = [caption]
|
524
|
-
# You can pass in a 1-D Numpy array as captions.
|
525
|
-
elif (
|
526
|
-
isinstance(caption, np.ndarray)
|
527
|
-
and len(cast(NumpyShape, caption.shape)) == 1
|
528
|
-
):
|
529
|
-
captions = caption.tolist()
|
530
|
-
# If there are no captions then make the captions list the same size
|
531
|
-
# as the images list.
|
532
|
-
elif caption is None:
|
533
|
-
captions = [None] * len(images)
|
534
|
-
else:
|
535
|
-
captions = [str(caption)]
|
525
|
+
captions = [str(caption)]
|
536
526
|
|
537
527
|
assert isinstance(
|
538
528
|
captions, list
|
streamlit/elements/json.py
CHANGED
@@ -46,7 +46,7 @@ class JsonMixin:
|
|
46
46
|
*, # keyword-only arguments:
|
47
47
|
expanded: bool | int = True,
|
48
48
|
) -> DeltaGenerator:
|
49
|
-
"""Display object or string as a pretty-printed JSON string.
|
49
|
+
"""Display an object or string as a pretty-printed, interactive JSON string.
|
50
50
|
|
51
51
|
Parameters
|
52
52
|
----------
|
@@ -57,10 +57,17 @@ class JsonMixin:
|
|
57
57
|
contains serialized JSON.
|
58
58
|
|
59
59
|
expanded : bool or int
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
The initial expansion state of the JSON element. This can be one
|
61
|
+
of the following:
|
62
|
+
|
63
|
+
- ``True`` (default): The element is fully expanded.
|
64
|
+
- ``False``: The element is fully collapsed.
|
65
|
+
- An integer: The element is expanded to the depth specified. The
|
66
|
+
integer must be non-negative. ``expanded=0`` is equivalent to
|
67
|
+
``expanded=False``.
|
68
|
+
|
69
|
+
Regardless of the initial expansion state, users can collapse or
|
70
|
+
expand any key-value pair to show or hide any part of the object.
|
64
71
|
|
65
72
|
Example
|
66
73
|
-------
|
@@ -448,7 +448,7 @@ def TextColumn(
|
|
448
448
|
>>> help="Streamlit **widget** commands 🎈",
|
449
449
|
>>> default="st.",
|
450
450
|
>>> max_chars=50,
|
451
|
-
>>> validate="^st\.[a-z_]+$",
|
451
|
+
>>> validate=r"^st\.[a-z_]+$",
|
452
452
|
>>> )
|
453
453
|
>>> },
|
454
454
|
>>> hide_index=True,
|
@@ -571,9 +571,9 @@ def LinkColumn(
|
|
571
571
|
>>> "apps": st.column_config.LinkColumn(
|
572
572
|
>>> "Trending apps",
|
573
573
|
>>> help="The top trending Streamlit apps",
|
574
|
-
>>> validate="^https://[a-z]+\\.streamlit\\.app$",
|
574
|
+
>>> validate=r"^https://[a-z]+\\.streamlit\\.app$",
|
575
575
|
>>> max_chars=100,
|
576
|
-
>>> display_text="https://(.*?)\\.streamlit\\.app"
|
576
|
+
>>> display_text=r"https://(.*?)\\.streamlit\\.app"
|
577
577
|
>>> ),
|
578
578
|
>>> "creator": st.column_config.LinkColumn(
|
579
579
|
>>> "App Creator", display_text="Open profile"
|
@@ -19,7 +19,10 @@ from typing import TYPE_CHECKING, Any, Final, Sequence
|
|
19
19
|
from streamlit import config, errors, logger, runtime
|
20
20
|
from streamlit.elements.form_utils import is_in_form
|
21
21
|
from streamlit.errors import StreamlitAPIException, StreamlitAPIWarning
|
22
|
-
from streamlit.runtime.scriptrunner_utils.script_run_context import
|
22
|
+
from streamlit.runtime.scriptrunner_utils.script_run_context import (
|
23
|
+
get_script_run_ctx,
|
24
|
+
in_cached_function,
|
25
|
+
)
|
23
26
|
from streamlit.runtime.state import WidgetCallback, get_session_state
|
24
27
|
|
25
28
|
if TYPE_CHECKING:
|
@@ -114,14 +117,12 @@ def check_cache_replay_rules() -> None:
|
|
114
117
|
If there are other similar checks in the future, we could extend this
|
115
118
|
function to check for those as well. And rename it to check_widget_usage_rules.
|
116
119
|
"""
|
117
|
-
if
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
# that indicates to the user where the issue is.
|
124
|
-
exception(CachedWidgetWarning())
|
120
|
+
if in_cached_function.get():
|
121
|
+
from streamlit import exception
|
122
|
+
|
123
|
+
# We use an exception here to show a proper stack trace
|
124
|
+
# that indicates to the user where the issue is.
|
125
|
+
exception(CachedWidgetWarning())
|
125
126
|
|
126
127
|
|
127
128
|
_fragment_writes_widget_to_outside_error = (
|
streamlit/elements/map.py
CHANGED
@@ -105,10 +105,7 @@ class MapMixin:
|
|
105
105
|
|
106
106
|
Parameters
|
107
107
|
----------
|
108
|
-
data :
|
109
|
-
snowflake.snowpark.dataframe.DataFrame, snowflake.snowpark.table.Table,\
|
110
|
-
Iterable, dict, or None
|
111
|
-
|
108
|
+
data : Anything supported by st.dataframe
|
112
109
|
The data to be plotted.
|
113
110
|
|
114
111
|
latitude : str or None
|
@@ -170,8 +167,8 @@ class MapMixin:
|
|
170
167
|
>>>
|
171
168
|
>>> df = pd.DataFrame(
|
172
169
|
... np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
|
173
|
-
... columns=[
|
174
|
-
...
|
170
|
+
... columns=["lat", "lon"],
|
171
|
+
... )
|
175
172
|
>>> st.map(df)
|
176
173
|
|
177
174
|
.. output::
|
@@ -180,7 +177,7 @@ class MapMixin:
|
|
180
177
|
|
181
178
|
You can also customize the size and color of the datapoints:
|
182
179
|
|
183
|
-
>>> st.map(df, size=20, color=
|
180
|
+
>>> st.map(df, size=20, color="#0044ff")
|
184
181
|
|
185
182
|
And finally, you can choose different columns to use for the latitude
|
186
183
|
and longitude components, as well as set size and color of each
|
@@ -190,18 +187,16 @@ class MapMixin:
|
|
190
187
|
>>> import pandas as pd
|
191
188
|
>>> import numpy as np
|
192
189
|
>>>
|
193
|
-
>>> df = pd.DataFrame(
|
194
|
-
...
|
195
|
-
...
|
196
|
-
...
|
197
|
-
...
|
198
|
-
...
|
190
|
+
>>> df = pd.DataFrame(
|
191
|
+
... {
|
192
|
+
... "col1": np.random.randn(1000) / 50 + 37.76,
|
193
|
+
... "col2": np.random.randn(1000) / 50 + -122.4,
|
194
|
+
... "col3": np.random.randn(1000) * 100,
|
195
|
+
... "col4": np.random.rand(1000, 4).tolist(),
|
196
|
+
... }
|
197
|
+
... )
|
199
198
|
>>>
|
200
|
-
>>> st.map(df,
|
201
|
-
... latitude='col1',
|
202
|
-
... longitude='col2',
|
203
|
-
... size='col3',
|
204
|
-
... color='col4')
|
199
|
+
>>> st.map(df, latitude="col1", longitude="col2", size="col3", color="col4")
|
205
200
|
|
206
201
|
.. output::
|
207
202
|
https://doc-map-color.streamlit.app/
|
@@ -122,7 +122,7 @@ class VegaLiteState(TypedDict, total=False):
|
|
122
122
|
--------
|
123
123
|
The following two examples have equivalent definitions. Each one has a
|
124
124
|
point and interval selection parameter include in the chart definition.
|
125
|
-
The point
|
125
|
+
The point selection parameter is named ``"point_selection"``. The interval
|
126
126
|
or box selection parameter is named ``"interval_selection"``.
|
127
127
|
|
128
128
|
The follow example uses ``st.altair_chart``:
|
@@ -574,9 +574,7 @@ class VegaChartsMixin:
|
|
574
574
|
|
575
575
|
Parameters
|
576
576
|
----------
|
577
|
-
data :
|
578
|
-
pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, \
|
579
|
-
snowflake.snowpark.table.Table, Iterable, dict or None
|
577
|
+
data : Anything supported by st.dataframe
|
580
578
|
Data to be plotted.
|
581
579
|
|
582
580
|
x : str or None
|
@@ -773,9 +771,7 @@ class VegaChartsMixin:
|
|
773
771
|
|
774
772
|
Parameters
|
775
773
|
----------
|
776
|
-
data :
|
777
|
-
pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, \
|
778
|
-
snowflake.snowpark.table.Table, Iterable, or dict
|
774
|
+
data : Anything supported by st.dataframe
|
779
775
|
Data to be plotted.
|
780
776
|
|
781
777
|
x : str or None
|
@@ -1012,9 +1008,7 @@ class VegaChartsMixin:
|
|
1012
1008
|
|
1013
1009
|
Parameters
|
1014
1010
|
----------
|
1015
|
-
data :
|
1016
|
-
pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, \
|
1017
|
-
snowflake.snowpark.table.Table, Iterable, or dict
|
1011
|
+
data : Anything supported by st.dataframe
|
1018
1012
|
Data to be plotted.
|
1019
1013
|
|
1020
1014
|
x : str or None
|
@@ -1278,9 +1272,7 @@ class VegaChartsMixin:
|
|
1278
1272
|
|
1279
1273
|
Parameters
|
1280
1274
|
----------
|
1281
|
-
data :
|
1282
|
-
pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, \
|
1283
|
-
snowflake.snowpark.table.Table, Iterable, dict or None
|
1275
|
+
data : Anything supported by st.dataframe
|
1284
1276
|
Data to be plotted.
|
1285
1277
|
|
1286
1278
|
x : str or None
|
@@ -1661,7 +1653,7 @@ class VegaChartsMixin:
|
|
1661
1653
|
|
1662
1654
|
Parameters
|
1663
1655
|
----------
|
1664
|
-
data :
|
1656
|
+
data : Anything supported by st.dataframe
|
1665
1657
|
Either the data to be plotted or a Vega-Lite spec containing the
|
1666
1658
|
data (which more closely follows the Vega-Lite API).
|
1667
1659
|
|
@@ -264,7 +264,7 @@ class ButtonGroupMixin:
|
|
264
264
|
|
265
265
|
.. output ::
|
266
266
|
https://doc-feedback-stars.streamlit.app/
|
267
|
-
height:
|
267
|
+
height: 200px
|
268
268
|
|
269
269
|
Display a feedback widget with thumbs, and show the selected sentiment:
|
270
270
|
|
@@ -277,7 +277,7 @@ class ButtonGroupMixin:
|
|
277
277
|
|
278
278
|
.. output ::
|
279
279
|
https://doc-feedback-thumbs.streamlit.app/
|
280
|
-
height:
|
280
|
+
height: 200px
|
281
281
|
|
282
282
|
"""
|
283
283
|
|
@@ -599,18 +599,21 @@ class DataEditorMixin:
|
|
599
599
|
|
600
600
|
Parameters
|
601
601
|
----------
|
602
|
-
data :
|
602
|
+
data : Anything supported by st.dataframe
|
603
603
|
The data to edit in the data editor.
|
604
604
|
|
605
605
|
.. note::
|
606
606
|
- Styles from ``pandas.Styler`` will only be applied to non-editable columns.
|
607
607
|
- Mixing data types within a column can make the column uneditable.
|
608
608
|
- Additionally, the following data types are not yet supported for editing:
|
609
|
-
complex
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
609
|
+
``complex``, ``list``, ``tuple``, ``bytes``, ``bytearray``,
|
610
|
+
``memoryview``, ``dict``, ``set``, ``frozenset``,
|
611
|
+
``fractions.Fraction``, ``pandas.Interval``, and
|
612
|
+
``pandas.Period``.
|
613
|
+
- To prevent overflow in JavaScript, columns containing
|
614
|
+
``datetime.timedelta`` and ``pandas.Timedelta`` values will
|
615
|
+
default to uneditable, but this can be changed through column
|
616
|
+
configuration.
|
614
617
|
|
615
618
|
width : int or None
|
616
619
|
Desired width of the data editor expressed in pixels. If ``width``
|
@@ -156,10 +156,10 @@ class MultiSelectMixin:
|
|
156
156
|
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
157
157
|
|
158
158
|
options : Iterable
|
159
|
-
Labels for the select options in an Iterable
|
160
|
-
|
161
|
-
|
162
|
-
|
159
|
+
Labels for the select options in an ``Iterable``. This can be a
|
160
|
+
``list``, ``set``, or anything supported by ``st.dataframe``. If
|
161
|
+
``options`` is dataframe-like, the first column will be used. Each
|
162
|
+
label will be cast to ``str`` internally by default.
|
163
163
|
|
164
164
|
default: Iterable of V, V, or None
|
165
165
|
List of default values. Can also be a single value.
|
@@ -16,7 +16,7 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
from dataclasses import dataclass
|
18
18
|
from textwrap import dedent
|
19
|
-
from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast
|
19
|
+
from typing import TYPE_CHECKING, Any, Callable, Generic, Sequence, cast, overload
|
20
20
|
|
21
21
|
from streamlit.dataframe_util import OptionSequence, convert_anything_to_list
|
22
22
|
from streamlit.elements.form_utils import current_form_id
|
@@ -81,6 +81,44 @@ class RadioSerde(Generic[T]):
|
|
81
81
|
|
82
82
|
|
83
83
|
class RadioMixin:
|
84
|
+
@overload
|
85
|
+
def radio(
|
86
|
+
self,
|
87
|
+
label: str,
|
88
|
+
options: OptionSequence[T],
|
89
|
+
index: int = 0,
|
90
|
+
format_func: Callable[[Any], Any] = str,
|
91
|
+
key: Key | None = None,
|
92
|
+
help: str | None = None,
|
93
|
+
on_change: WidgetCallback | None = None,
|
94
|
+
args: WidgetArgs | None = None,
|
95
|
+
kwargs: WidgetKwargs | None = None,
|
96
|
+
*, # keyword-only args:
|
97
|
+
disabled: bool = False,
|
98
|
+
horizontal: bool = False,
|
99
|
+
captions: Sequence[str] | None = None,
|
100
|
+
label_visibility: LabelVisibility = "visible",
|
101
|
+
) -> T: ...
|
102
|
+
|
103
|
+
@overload
|
104
|
+
def radio(
|
105
|
+
self,
|
106
|
+
label: str,
|
107
|
+
options: OptionSequence[T],
|
108
|
+
index: None,
|
109
|
+
format_func: Callable[[Any], Any] = str,
|
110
|
+
key: Key | None = None,
|
111
|
+
help: str | None = None,
|
112
|
+
on_change: WidgetCallback | None = None,
|
113
|
+
args: WidgetArgs | None = None,
|
114
|
+
kwargs: WidgetKwargs | None = None,
|
115
|
+
*, # keyword-only args:
|
116
|
+
disabled: bool = False,
|
117
|
+
horizontal: bool = False,
|
118
|
+
captions: Sequence[str] | None = None,
|
119
|
+
label_visibility: LabelVisibility = "visible",
|
120
|
+
) -> T | None: ...
|
121
|
+
|
84
122
|
@gather_metrics("radio")
|
85
123
|
def radio(
|
86
124
|
self,
|
@@ -125,9 +163,10 @@ class RadioMixin:
|
|
125
163
|
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
126
164
|
|
127
165
|
options : Iterable
|
128
|
-
Labels for the select options in an Iterable
|
129
|
-
|
130
|
-
|
166
|
+
Labels for the select options in an ``Iterable``. This can be a
|
167
|
+
``list``, ``set``, or anything supported by ``st.dataframe``. If
|
168
|
+
``options`` is dataframe-like, the first column will be used. Each
|
169
|
+
label will be cast to ``str`` internally by default.
|
131
170
|
|
132
171
|
Labels can include markdown as described in the ``label`` parameter
|
133
172
|
and will be cast to str internally by default.
|
@@ -16,7 +16,16 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
from dataclasses import dataclass
|
18
18
|
from textwrap import dedent
|
19
|
-
from typing import
|
19
|
+
from typing import (
|
20
|
+
TYPE_CHECKING,
|
21
|
+
Any,
|
22
|
+
Callable,
|
23
|
+
Generic,
|
24
|
+
Sequence,
|
25
|
+
Tuple,
|
26
|
+
cast,
|
27
|
+
overload,
|
28
|
+
)
|
20
29
|
|
21
30
|
from typing_extensions import TypeGuard
|
22
31
|
|
@@ -49,10 +58,7 @@ from streamlit.runtime.state.common import (
|
|
49
58
|
compute_widget_id,
|
50
59
|
save_for_app_testing,
|
51
60
|
)
|
52
|
-
from streamlit.type_util import
|
53
|
-
T,
|
54
|
-
check_python_comparable,
|
55
|
-
)
|
61
|
+
from streamlit.type_util import T, check_python_comparable
|
56
62
|
from streamlit.util import index_
|
57
63
|
|
58
64
|
if TYPE_CHECKING:
|
@@ -102,12 +108,58 @@ class SelectSliderSerde(Generic[T]):
|
|
102
108
|
|
103
109
|
|
104
110
|
class SelectSliderMixin:
|
111
|
+
@overload
|
112
|
+
def select_slider( # type: ignore[overload-overlap]
|
113
|
+
self,
|
114
|
+
label: str,
|
115
|
+
options: OptionSequence[T],
|
116
|
+
value: tuple[T, T] | list[T],
|
117
|
+
format_func: Callable[[Any], Any] = str,
|
118
|
+
key: Key | None = None,
|
119
|
+
help: str | None = None,
|
120
|
+
on_change: WidgetCallback | None = None,
|
121
|
+
args: WidgetArgs | None = None,
|
122
|
+
kwargs: WidgetKwargs | None = None,
|
123
|
+
*, # keyword-only arguments:
|
124
|
+
disabled: bool = False,
|
125
|
+
label_visibility: LabelVisibility = "visible",
|
126
|
+
) -> tuple[T, T]: ...
|
127
|
+
|
128
|
+
# The overload-overlap error given by mypy here stems from
|
129
|
+
# the fact that
|
130
|
+
#
|
131
|
+
# opt:List[object] = [1, 2, "3"]
|
132
|
+
# select_slider("foo", options=opt, value=[1, 2])
|
133
|
+
#
|
134
|
+
# matches both overloads; "opt" matches
|
135
|
+
# OptionsSequence[T] in each case, binding T to object.
|
136
|
+
# However, the list[int] type of "value" can be interpreted
|
137
|
+
# as subtype of object, or as a subtype of List[object],
|
138
|
+
# meaning it matches both signatures.
|
139
|
+
|
140
|
+
@overload
|
141
|
+
def select_slider(
|
142
|
+
self,
|
143
|
+
label: str,
|
144
|
+
options: OptionSequence[T] = (),
|
145
|
+
value: T | None = None,
|
146
|
+
format_func: Callable[[Any], Any] = str,
|
147
|
+
key: Key | None = None,
|
148
|
+
help: str | None = None,
|
149
|
+
on_change: WidgetCallback | None = None,
|
150
|
+
args: WidgetArgs | None = None,
|
151
|
+
kwargs: WidgetKwargs | None = None,
|
152
|
+
*, # keyword-only arguments:
|
153
|
+
disabled: bool = False,
|
154
|
+
label_visibility: LabelVisibility = "visible",
|
155
|
+
) -> T: ...
|
156
|
+
|
105
157
|
@gather_metrics("select_slider")
|
106
158
|
def select_slider(
|
107
159
|
self,
|
108
160
|
label: str,
|
109
161
|
options: OptionSequence[T] = (),
|
110
|
-
value:
|
162
|
+
value: T | Sequence[T] | None = None,
|
111
163
|
format_func: Callable[[Any], Any] = str,
|
112
164
|
key: Key | None = None,
|
113
165
|
help: str | None = None,
|
@@ -153,10 +205,10 @@ class SelectSliderMixin:
|
|
153
205
|
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
154
206
|
|
155
207
|
options : Iterable
|
156
|
-
Labels for the select options in an Iterable
|
157
|
-
|
158
|
-
|
159
|
-
|
208
|
+
Labels for the select options in an ``Iterable``. This can be a
|
209
|
+
``list``, ``set``, or anything supported by ``st.dataframe``. If
|
210
|
+
``options`` is dataframe-like, the first column will be used. Each
|
211
|
+
label will be cast to ``str`` internally by default.
|
160
212
|
|
161
213
|
value : a supported type or a tuple/list of supported types or None
|
162
214
|
The value of the slider when it first renders. If a tuple/list
|
@@ -266,7 +318,7 @@ class SelectSliderMixin:
|
|
266
318
|
self,
|
267
319
|
label: str,
|
268
320
|
options: OptionSequence[T] = (),
|
269
|
-
value:
|
321
|
+
value: T | Sequence[T] | None = None,
|
270
322
|
format_func: Callable[[Any], Any] = str,
|
271
323
|
key: Key | None = None,
|
272
324
|
help: str | None = None,
|
@@ -153,10 +153,10 @@ class SelectboxMixin:
|
|
153
153
|
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
154
154
|
|
155
155
|
options : Iterable
|
156
|
-
Labels for the select options in an Iterable
|
157
|
-
|
158
|
-
|
159
|
-
|
156
|
+
Labels for the select options in an ``Iterable``. This can be a
|
157
|
+
``list``, ``set``, or anything supported by ``st.dataframe``. If
|
158
|
+
``options`` is dataframe-like, the first column will be used. Each
|
159
|
+
label will be cast to ``str`` internally by default.
|
160
160
|
|
161
161
|
index : int
|
162
162
|
The index of the preselected option on first render. If ``None``,
|
streamlit/elements/write.py
CHANGED
@@ -259,7 +259,7 @@ class WriteMixin:
|
|
259
259
|
- write(string) : Prints the formatted Markdown string, with
|
260
260
|
support for LaTeX expression, emoji shortcodes, and colored text.
|
261
261
|
See docs for st.markdown for more.
|
262
|
-
- write(dataframe) : Displays any dataframe-like object in
|
262
|
+
- write(dataframe) : Displays any dataframe-like object in an interactive table.
|
263
263
|
- write(dict) : Displays dict-like in an interactive viewer.
|
264
264
|
- write(list) : Displays list-like in an interactive viewer.
|
265
265
|
- write(error) : Prints an exception specially.
|