streamlit 1.49.1__py3-none-any.whl → 1.50.0__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/column_config.py +2 -0
- streamlit/commands/navigation.py +3 -1
- streamlit/components/v1/custom_component.py +17 -42
- streamlit/config.py +306 -0
- streamlit/connections/base_connection.py +4 -2
- streamlit/dataframe_util.py +3 -2
- streamlit/delta_generator.py +2 -3
- streamlit/elements/arrow.py +63 -43
- streamlit/elements/deck_gl_json_chart.py +1 -0
- streamlit/elements/form.py +6 -6
- streamlit/elements/graphviz_chart.py +23 -6
- streamlit/elements/iframe.py +0 -2
- streamlit/elements/image.py +10 -9
- streamlit/elements/layouts.py +58 -11
- streamlit/elements/lib/built_in_chart_utils.py +95 -29
- streamlit/elements/lib/column_config_utils.py +5 -0
- streamlit/elements/lib/column_types.py +563 -144
- streamlit/elements/lib/dialog.py +1 -0
- streamlit/elements/lib/pandas_styler_utils.py +30 -14
- streamlit/elements/lib/utils.py +17 -5
- streamlit/elements/map.py +1 -3
- streamlit/elements/media.py +2 -0
- streamlit/elements/metric.py +10 -32
- streamlit/elements/plotly_chart.py +17 -9
- streamlit/elements/pyplot.py +6 -6
- streamlit/elements/vega_charts.py +110 -44
- streamlit/elements/widgets/audio_input.py +48 -0
- streamlit/elements/widgets/button.py +27 -25
- streamlit/elements/widgets/button_group.py +1 -0
- streamlit/elements/widgets/camera_input.py +1 -0
- streamlit/elements/widgets/chat.py +1 -0
- streamlit/elements/widgets/checkbox.py +1 -0
- streamlit/elements/widgets/color_picker.py +1 -0
- streamlit/elements/widgets/data_editor.py +6 -5
- streamlit/elements/widgets/file_uploader.py +1 -0
- streamlit/elements/widgets/multiselect.py +10 -0
- streamlit/elements/widgets/number_input.py +3 -0
- streamlit/elements/widgets/radio.py +1 -0
- streamlit/elements/widgets/select_slider.py +1 -0
- streamlit/elements/widgets/selectbox.py +4 -0
- streamlit/elements/widgets/slider.py +1 -0
- streamlit/elements/widgets/text_widgets.py +6 -0
- streamlit/elements/widgets/time_widgets.py +9 -0
- streamlit/elements/write.py +1 -17
- streamlit/git_util.py +65 -43
- streamlit/material_icon_names.py +1 -1
- streamlit/proto/Arrow_pb2.py +10 -8
- streamlit/proto/Arrow_pb2.pyi +31 -2
- streamlit/proto/AudioInput_pb2.py +2 -2
- streamlit/proto/AudioInput_pb2.pyi +6 -2
- streamlit/proto/Block_pb2.py +11 -11
- streamlit/proto/Block_pb2.pyi +5 -0
- streamlit/proto/NewSession_pb2.py +18 -16
- streamlit/proto/NewSession_pb2.pyi +135 -2
- streamlit/runtime/app_session.py +18 -5
- streamlit/runtime/theme_util.py +148 -0
- streamlit/static/index.html +2 -2
- streamlit/static/manifest.json +222 -222
- streamlit/static/static/css/index.CHEnSPGk.css +1 -0
- streamlit/static/static/css/{index.C8X8rNzw.css → index.CIiu7Ygf.css} +1 -1
- streamlit/static/static/js/{ErrorOutline.esm.DcGrhbBP.js → ErrorOutline.esm.DUpR0_Ka.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.DgBvV6Pq.js → FileDownload.esm.CN4j9-1w.js} +1 -1
- streamlit/static/static/js/{FileHelper.M6AAaeuA.js → FileHelper.CaIUKG91.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.DHh1GFzm.js → FormClearHelper.DTcdrasw.js} +1 -1
- streamlit/static/static/js/{Hooks.DGu1od_L.js → Hooks.BRba_Own.js} +1 -1
- streamlit/static/static/js/InputInstructions.xnSDuYeQ.js +1 -0
- streamlit/static/static/js/{Particles.DDVT-6Qc.js → Particles.CElH0XX2.js} +1 -1
- streamlit/static/static/js/{ProgressBar.BEY0cXXV.js → ProgressBar.DetlP5aY.js} +2 -2
- streamlit/static/static/js/Toolbar.C77ar7rq.js +1 -0
- streamlit/static/static/js/{base-input.CK3UVGp1.js → base-input.BQft14La.js} +3 -3
- streamlit/static/static/js/{checkbox.D8W881TL.js → checkbox.yZOfXCeX.js} +1 -1
- streamlit/static/static/js/{createSuper.B6W-Dh9S.js → createSuper.Dh9w1cs8.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.DcuHuCyW.js +1 -0
- streamlit/static/static/js/{downloader.DiKpuU_S.js → downloader.MeHtkq8r.js} +1 -1
- streamlit/static/static/js/{es6.B8zRNPZ-.js → es6.VpBPGCnM.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.DIewJmmh.js → iframeResizer.contentWindow.yMw_ARIL.js} +1 -1
- streamlit/static/static/js/{index.B9mjBcgE.js → index.64ejlaaT.js} +1 -1
- streamlit/static/static/js/{index.CD8HuT3N.js → index.6xX1278W.js} +90 -91
- streamlit/static/static/js/index.B-hiXRzw.js +1 -0
- streamlit/static/static/js/{index.Ch7MBCx0.js → index.B0H9IXUJ.js} +47 -47
- streamlit/static/static/js/{index.4eF4NxG2.js → index.B4cAbHP6.js} +1 -1
- streamlit/static/static/js/{index.Dk4C7X3i.js → index.B4dUQfni.js} +1 -1
- streamlit/static/static/js/{index.CvYYtxD_.js → index.BPQo7BKk.js} +1 -1
- streamlit/static/static/js/index.Baqa90pe.js +2 -0
- streamlit/static/static/js/{index.D5naqx-J.js → index.Bj9JgOEC.js} +1 -1
- streamlit/static/static/js/index.BjCwMzj4.js +3 -0
- streamlit/static/static/js/{index.C_tmcx4B.js → index.Bm3VbPB5.js} +1 -1
- streamlit/static/static/js/{index.C7fRKRs4.js → index.Bxz2yX3P.js} +1 -1
- streamlit/static/static/js/{index.ho6NIXGl.js → index.BycLveZ4.js} +1 -1
- streamlit/static/static/js/{index.452cqrrL.js → index.C9BdUqTi.js} +1 -1
- streamlit/static/static/js/index.CFMf5_ez.js +197 -0
- streamlit/static/static/js/index.CGYqqs6j.js +1 -0
- streamlit/static/static/js/{index.zecpGxtj.js → index.CH1tqnSs.js} +1 -1
- streamlit/static/static/js/{index.CjXWwH-y.js → index.CMItVsFA.js} +1 -1
- streamlit/static/static/js/{index.B6U8LQo3.js → index.CTBk8Vk2.js} +1 -1
- streamlit/static/static/js/index.CiAQIz1H.js +7 -0
- streamlit/static/static/js/index.Cj7DSzVR.js +73 -0
- streamlit/static/static/js/index.Ck8rQ9OL.js +1 -0
- streamlit/static/static/js/{index.Ts_0SdB9.js → index.ClELlchS.js} +2 -2
- streamlit/static/static/js/{index.Bte_9Lyq.js → index.Cnpi3o3E.js} +1 -1
- streamlit/static/static/js/{index.CcJf6BCU.js → index.Ctn27_AE.js} +1 -1
- streamlit/static/static/js/{index.CP5TD2z1.js → index.D2QEXQq_.js} +1 -1
- streamlit/static/static/js/index.DH71Ezyj.js +1 -0
- streamlit/static/static/js/{index.D2-atlaQ.js → index.DHh-U0dK.js} +2 -2
- streamlit/static/static/js/{index.DtYN2x4k.js → index.DK7hD7_w.js} +1 -1
- streamlit/static/static/js/{index.qhs54UAB.js → index.DKv_lNO7.js} +1 -1
- streamlit/static/static/js/index.DNLrMXgm.js +12 -0
- streamlit/static/static/js/index.DW0Grddz.js +1 -0
- streamlit/static/static/js/{index.cnnXF7xQ.js → index.Dbe-Q3C-.js} +1 -1
- streamlit/static/static/js/index.DcPNYEUo.js +1 -0
- streamlit/static/static/js/index.DuxqVQpd.js +1 -0
- streamlit/static/static/js/{index.CejBxbg1.js → index.FFOzOWzC.js} +1 -1
- streamlit/static/static/js/{index.BnEpvLEz.js → index.GRUzrudl.js} +1 -1
- streamlit/static/static/js/{input.nzVJphXi.js → input.s6pjQ49A.js} +1 -1
- streamlit/static/static/js/{memory.CjCgTQz3.js → memory.Cuvsdfrl.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.DaRFzZEO.js → number-overlay-editor.DdgVR5m3.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.DgiPnZ9N.js → possibleConstructorReturn.CqidKeei.js} +1 -1
- streamlit/static/static/js/{sandbox.mithfq7Z.js → sandbox.CCQREcJx.js} +1 -1
- streamlit/static/static/js/{timepicker.Dbl5KFh6.js → timepicker.mkJF97Bb.js} +4 -4
- streamlit/static/static/js/{toConsumableArray.D-Dx88BQ.js → toConsumableArray.De7I7KVR.js} +1 -1
- streamlit/static/static/js/{uniqueId.Bh26R_3S.js → uniqueId.RI1LJdtz.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.DeK-QJpD.js → useBasicWidgetState.CedkNjUW.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.4iAdLWD-.js → useTextInputAutoExpand.Ca7w8dVs.js} +2 -2
- streamlit/static/static/js/{useUpdateUiValue.CmT7_nJN.js → useUpdateUiValue.DeXelfRH.js} +1 -1
- streamlit/static/static/js/withFullScreenWrapper.C3561XxJ.js +1 -0
- streamlit/static/static/media/MaterialSymbols-Rounded.DeCZgS-4.woff2 +0 -0
- streamlit/string_util.py +58 -1
- streamlit/web/bootstrap.py +0 -31
- streamlit/web/server/routes.py +17 -4
- streamlit/web/server/server.py +1 -0
- {streamlit-1.49.1.dist-info → streamlit-1.50.0.dist-info}/METADATA +1 -1
- {streamlit-1.49.1.dist-info → streamlit-1.50.0.dist-info}/RECORD +136 -135
- streamlit/static/static/css/index.COe1010n.css +0 -1
- streamlit/static/static/js/InputInstructions.z6sVgyYt.js +0 -1
- streamlit/static/static/js/Toolbar.DSnK1fUh.js +0 -1
- streamlit/static/static/js/data-grid-overlay-editor.DRTHOydk.js +0 -1
- streamlit/static/static/js/index.BXYmrqnf.js +0 -1
- streamlit/static/static/js/index.B_8AnktO.js +0 -1
- streamlit/static/static/js/index.Bl7zGQSh.js +0 -7
- streamlit/static/static/js/index.BnJIOYn9.js +0 -73
- streamlit/static/static/js/index.C1HcTl5K.js +0 -1
- streamlit/static/static/js/index.C7lSmSOP.js +0 -1
- streamlit/static/static/js/index.D3K5nOu9.js +0 -197
- streamlit/static/static/js/index.DkKT3LUI.js +0 -1
- streamlit/static/static/js/index.MTPPBDHk.js +0 -2
- streamlit/static/static/js/index.pqW9AMJD.js +0 -3
- streamlit/static/static/js/index.urHgTgMQ.js +0 -12
- streamlit/static/static/js/index.wzkv_11M.js +0 -1
- streamlit/static/static/js/index.yF5AncHY.js +0 -1
- streamlit/static/static/js/withFullScreenWrapper.DLp1ENGm.js +0 -1
- streamlit/static/static/media/MaterialSymbols-Rounded.CBxVaFdk.woff2 +0 -0
- {streamlit-1.49.1.data → streamlit-1.50.0.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.49.1.dist-info → streamlit-1.50.0.dist-info}/WHEEL +0 -0
- {streamlit-1.49.1.dist-info → streamlit-1.50.0.dist-info}/entry_points.txt +0 -0
- {streamlit-1.49.1.dist-info → streamlit-1.50.0.dist-info}/top_level.txt +0 -0
|
@@ -18,15 +18,18 @@
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
20
20
|
import datetime
|
|
21
|
+
import itertools
|
|
21
22
|
from typing import TYPE_CHECKING, Callable, Literal, TypedDict, Union
|
|
22
23
|
|
|
23
24
|
from typing_extensions import NotRequired, TypeAlias
|
|
24
25
|
|
|
26
|
+
from streamlit.elements.lib.color_util import is_css_color_like
|
|
27
|
+
from streamlit.errors import StreamlitValueError
|
|
25
28
|
from streamlit.runtime.metrics_util import gather_metrics
|
|
26
29
|
from streamlit.string_util import validate_material_icon
|
|
27
30
|
|
|
28
31
|
if TYPE_CHECKING:
|
|
29
|
-
from collections.abc import Iterable
|
|
32
|
+
from collections.abc import Iterable, Iterator
|
|
30
33
|
|
|
31
34
|
NumberFormat: TypeAlias = Literal[
|
|
32
35
|
"plain",
|
|
@@ -62,9 +65,57 @@ ColumnType: TypeAlias = Literal[
|
|
|
62
65
|
"area_chart",
|
|
63
66
|
"image",
|
|
64
67
|
"progress",
|
|
68
|
+
"multiselect",
|
|
65
69
|
"json",
|
|
66
70
|
]
|
|
67
71
|
|
|
72
|
+
# Themeable colors supported in the theme config:
|
|
73
|
+
ThemeColor: TypeAlias = Literal[
|
|
74
|
+
"red",
|
|
75
|
+
"blue",
|
|
76
|
+
"green",
|
|
77
|
+
"yellow",
|
|
78
|
+
"orange",
|
|
79
|
+
"violet",
|
|
80
|
+
"gray",
|
|
81
|
+
"grey",
|
|
82
|
+
"primary",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
# Color options for chart columns:
|
|
86
|
+
ChartColor: TypeAlias = Union[
|
|
87
|
+
Literal["auto", "auto-inverse"],
|
|
88
|
+
ThemeColor,
|
|
89
|
+
str,
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _validate_chart_color(maybe_color: str) -> None:
|
|
94
|
+
"""Validate a color for a chart column."""
|
|
95
|
+
|
|
96
|
+
supported_colors = [
|
|
97
|
+
"auto",
|
|
98
|
+
"auto-inverse",
|
|
99
|
+
"red",
|
|
100
|
+
"blue",
|
|
101
|
+
"green",
|
|
102
|
+
"yellow",
|
|
103
|
+
"violet",
|
|
104
|
+
"orange",
|
|
105
|
+
"gray",
|
|
106
|
+
"grey",
|
|
107
|
+
"primary",
|
|
108
|
+
]
|
|
109
|
+
if maybe_color not in supported_colors and not is_css_color_like(maybe_color):
|
|
110
|
+
raise StreamlitValueError(
|
|
111
|
+
"color",
|
|
112
|
+
[
|
|
113
|
+
*supported_colors,
|
|
114
|
+
"a valid hex color",
|
|
115
|
+
"an rgb() or rgba() color",
|
|
116
|
+
],
|
|
117
|
+
)
|
|
118
|
+
|
|
68
119
|
|
|
69
120
|
class NumberColumnConfig(TypedDict):
|
|
70
121
|
type: Literal["number"]
|
|
@@ -108,18 +159,21 @@ class BarChartColumnConfig(TypedDict):
|
|
|
108
159
|
type: Literal["bar_chart"]
|
|
109
160
|
y_min: NotRequired[int | float | None]
|
|
110
161
|
y_max: NotRequired[int | float | None]
|
|
162
|
+
color: NotRequired[ChartColor | None]
|
|
111
163
|
|
|
112
164
|
|
|
113
165
|
class LineChartColumnConfig(TypedDict):
|
|
114
166
|
type: Literal["line_chart"]
|
|
115
167
|
y_min: NotRequired[int | float | None]
|
|
116
168
|
y_max: NotRequired[int | float | None]
|
|
169
|
+
color: NotRequired[ChartColor | None]
|
|
117
170
|
|
|
118
171
|
|
|
119
172
|
class AreaChartColumnConfig(TypedDict):
|
|
120
173
|
type: Literal["area_chart"]
|
|
121
174
|
y_min: NotRequired[int | float | None]
|
|
122
175
|
y_max: NotRequired[int | float | None]
|
|
176
|
+
color: NotRequired[ChartColor | None]
|
|
123
177
|
|
|
124
178
|
|
|
125
179
|
class ImageColumnConfig(TypedDict):
|
|
@@ -130,6 +184,18 @@ class ListColumnConfig(TypedDict):
|
|
|
130
184
|
type: Literal["list"]
|
|
131
185
|
|
|
132
186
|
|
|
187
|
+
class MultiselectOption(TypedDict):
|
|
188
|
+
value: str
|
|
189
|
+
label: NotRequired[str | None]
|
|
190
|
+
color: NotRequired[str | ThemeColor | None]
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class MultiselectColumnConfig(TypedDict):
|
|
194
|
+
type: Literal["multiselect"]
|
|
195
|
+
options: NotRequired[Iterable[MultiselectOption | str] | None]
|
|
196
|
+
accept_new_options: NotRequired[bool | None]
|
|
197
|
+
|
|
198
|
+
|
|
133
199
|
class DatetimeColumnConfig(TypedDict):
|
|
134
200
|
type: Literal["datetime"]
|
|
135
201
|
format: NotRequired[
|
|
@@ -174,11 +240,11 @@ class ColumnConfig(TypedDict, total=False):
|
|
|
174
240
|
|
|
175
241
|
Parameters
|
|
176
242
|
----------
|
|
177
|
-
label: str or None
|
|
243
|
+
label : str or None
|
|
178
244
|
The label shown at the top of the column. If this is ``None``
|
|
179
245
|
(default), the column name is used.
|
|
180
246
|
|
|
181
|
-
width: "small", "medium", "large", int, or None
|
|
247
|
+
width : "small", "medium", "large", int, or None
|
|
182
248
|
The display width of the column. If this is ``None`` (default), the
|
|
183
249
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
184
250
|
one of the following:
|
|
@@ -188,7 +254,11 @@ class ColumnConfig(TypedDict, total=False):
|
|
|
188
254
|
- ``"large"``: 400px wide
|
|
189
255
|
- An integer specifying the width in pixels
|
|
190
256
|
|
|
191
|
-
|
|
257
|
+
If the total width of all columns is less than the width of the
|
|
258
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
259
|
+
columns.
|
|
260
|
+
|
|
261
|
+
help : str or None
|
|
192
262
|
A tooltip that gets displayed when hovering over the column label. If
|
|
193
263
|
this is ``None`` (default), no tooltip is displayed.
|
|
194
264
|
|
|
@@ -196,34 +266,34 @@ class ColumnConfig(TypedDict, total=False):
|
|
|
196
266
|
the Markdown directives described in the ``body`` parameter of
|
|
197
267
|
``st.markdown``.
|
|
198
268
|
|
|
199
|
-
disabled: bool or None
|
|
269
|
+
disabled : bool or None
|
|
200
270
|
Whether editing should be disabled for this column. If this is ``None``
|
|
201
271
|
(default), Streamlit will enable editing wherever possible.
|
|
202
272
|
|
|
203
273
|
If a column has mixed types, it may become uneditable regardless of
|
|
204
274
|
``disabled``.
|
|
205
275
|
|
|
206
|
-
required: bool or None
|
|
276
|
+
required : bool or None
|
|
207
277
|
Whether edited cells in the column need to have a value. If this is
|
|
208
278
|
``False`` (default), the user can submit empty values for this column.
|
|
209
279
|
If this is ``True``, an edited cell in this column can only be
|
|
210
280
|
submitted if its value is not ``None``, and a new row will only be
|
|
211
281
|
submitted after the user fills in this column.
|
|
212
282
|
|
|
213
|
-
pinned: bool or None
|
|
283
|
+
pinned : bool or None
|
|
214
284
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
215
285
|
left side no matter where the user scrolls. If this is ``None``
|
|
216
286
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
217
287
|
columns are not pinned.
|
|
218
288
|
|
|
219
|
-
default: str, bool, int, float, or None
|
|
289
|
+
default : str, bool, int, float, or None
|
|
220
290
|
Specifies the default value in this column when a new row is added by
|
|
221
291
|
the user. This defaults to ``None``.
|
|
222
292
|
|
|
223
|
-
hidden: bool or None
|
|
293
|
+
hidden : bool or None
|
|
224
294
|
Whether to hide the column. This defaults to ``False``.
|
|
225
295
|
|
|
226
|
-
type_config: dict or str or None
|
|
296
|
+
type_config : dict or str or None
|
|
227
297
|
Configure a column type and type specific options.
|
|
228
298
|
"""
|
|
229
299
|
|
|
@@ -251,6 +321,7 @@ class ColumnConfig(TypedDict, total=False):
|
|
|
251
321
|
| BarChartColumnConfig
|
|
252
322
|
| AreaChartColumnConfig
|
|
253
323
|
| ImageColumnConfig
|
|
324
|
+
| MultiselectColumnConfig
|
|
254
325
|
| JsonColumnConfig
|
|
255
326
|
| None
|
|
256
327
|
)
|
|
@@ -278,11 +349,11 @@ def Column(
|
|
|
278
349
|
|
|
279
350
|
Parameters
|
|
280
351
|
----------
|
|
281
|
-
label: str or None
|
|
352
|
+
label : str or None
|
|
282
353
|
The label shown at the top of the column. If this is ``None``
|
|
283
354
|
(default), the column name is used.
|
|
284
355
|
|
|
285
|
-
width: "small", "medium", "large", int, or None
|
|
356
|
+
width : "small", "medium", "large", int, or None
|
|
286
357
|
The display width of the column. If this is ``None`` (default), the
|
|
287
358
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
288
359
|
one of the following:
|
|
@@ -292,7 +363,11 @@ def Column(
|
|
|
292
363
|
- ``"large"``: 400px wide
|
|
293
364
|
- An integer specifying the width in pixels
|
|
294
365
|
|
|
295
|
-
|
|
366
|
+
If the total width of all columns is less than the width of the
|
|
367
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
368
|
+
columns.
|
|
369
|
+
|
|
370
|
+
help : str or None
|
|
296
371
|
A tooltip that gets displayed when hovering over the column label. If
|
|
297
372
|
this is ``None`` (default), no tooltip is displayed.
|
|
298
373
|
|
|
@@ -300,21 +375,21 @@ def Column(
|
|
|
300
375
|
the Markdown directives described in the ``body`` parameter of
|
|
301
376
|
``st.markdown``.
|
|
302
377
|
|
|
303
|
-
disabled: bool or None
|
|
378
|
+
disabled : bool or None
|
|
304
379
|
Whether editing should be disabled for this column. If this is ``None``
|
|
305
380
|
(default), Streamlit will enable editing wherever possible.
|
|
306
381
|
|
|
307
382
|
If a column has mixed types, it may become uneditable regardless of
|
|
308
383
|
``disabled``.
|
|
309
384
|
|
|
310
|
-
required: bool or None
|
|
385
|
+
required : bool or None
|
|
311
386
|
Whether edited cells in the column need to have a value. If this is
|
|
312
387
|
``False`` (default), the user can submit empty values for this column.
|
|
313
388
|
If this is ``True``, an edited cell in this column can only be
|
|
314
389
|
submitted if its value is not ``None``, and a new row will only be
|
|
315
390
|
submitted after the user fills in this column.
|
|
316
391
|
|
|
317
|
-
pinned: bool or None
|
|
392
|
+
pinned : bool or None
|
|
318
393
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
319
394
|
left side no matter where the user scrolls. If this is ``None``
|
|
320
395
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
@@ -382,11 +457,11 @@ def NumberColumn(
|
|
|
382
457
|
|
|
383
458
|
Parameters
|
|
384
459
|
----------
|
|
385
|
-
label: str or None
|
|
460
|
+
label : str or None
|
|
386
461
|
The label shown at the top of the column. If this is ``None``
|
|
387
462
|
(default), the column name is used.
|
|
388
463
|
|
|
389
|
-
width: "small", "medium", "large", int, or None
|
|
464
|
+
width : "small", "medium", "large", int, or None
|
|
390
465
|
The display width of the column. If this is ``None`` (default), the
|
|
391
466
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
392
467
|
one of the following:
|
|
@@ -396,7 +471,11 @@ def NumberColumn(
|
|
|
396
471
|
- ``"large"``: 400px wide
|
|
397
472
|
- An integer specifying the width in pixels
|
|
398
473
|
|
|
399
|
-
|
|
474
|
+
If the total width of all columns is less than the width of the
|
|
475
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
476
|
+
columns.
|
|
477
|
+
|
|
478
|
+
help : str or None
|
|
400
479
|
A tooltip that gets displayed when hovering over the column label. If
|
|
401
480
|
this is ``None`` (default), no tooltip is displayed.
|
|
402
481
|
|
|
@@ -404,31 +483,31 @@ def NumberColumn(
|
|
|
404
483
|
the Markdown directives described in the ``body`` parameter of
|
|
405
484
|
``st.markdown``.
|
|
406
485
|
|
|
407
|
-
disabled: bool or None
|
|
486
|
+
disabled : bool or None
|
|
408
487
|
Whether editing should be disabled for this column. If this is ``None``
|
|
409
488
|
(default), Streamlit will enable editing wherever possible.
|
|
410
489
|
|
|
411
490
|
If a column has mixed types, it may become uneditable regardless of
|
|
412
491
|
``disabled``.
|
|
413
492
|
|
|
414
|
-
required: bool or None
|
|
493
|
+
required : bool or None
|
|
415
494
|
Whether edited cells in the column need to have a value. If this is
|
|
416
495
|
``False`` (default), the user can submit empty values for this column.
|
|
417
496
|
If this is ``True``, an edited cell in this column can only be
|
|
418
497
|
submitted if its value is not ``None``, and a new row will only be
|
|
419
498
|
submitted after the user fills in this column.
|
|
420
499
|
|
|
421
|
-
pinned: bool or None
|
|
500
|
+
pinned : bool or None
|
|
422
501
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
423
502
|
left side no matter where the user scrolls. If this is ``None``
|
|
424
503
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
425
504
|
columns are not pinned.
|
|
426
505
|
|
|
427
|
-
default: int, float, or None
|
|
506
|
+
default : int, float, or None
|
|
428
507
|
Specifies the default value in this column when a new row is added by
|
|
429
508
|
the user. This defaults to ``None``.
|
|
430
509
|
|
|
431
|
-
format: str, "plain", "localized", "percent", "dollar", "euro", "yen", "accounting", "compact", "scientific", "engineering", or None
|
|
510
|
+
format : str, "plain", "localized", "percent", "dollar", "euro", "yen", "accounting", "compact", "scientific", "engineering", or None
|
|
432
511
|
A format string controlling how numbers are displayed.
|
|
433
512
|
This can be one of the following values:
|
|
434
513
|
|
|
@@ -455,15 +534,15 @@ def NumberColumn(
|
|
|
455
534
|
formatting from ``pandas.Styler``. The formatting does not impact the
|
|
456
535
|
return value when used in ``st.data_editor``.
|
|
457
536
|
|
|
458
|
-
min_value: int, float, or None
|
|
537
|
+
min_value : int, float, or None
|
|
459
538
|
The minimum value that can be entered. If this is ``None`` (default),
|
|
460
539
|
there will be no minimum.
|
|
461
540
|
|
|
462
|
-
max_value: int, float, or None
|
|
541
|
+
max_value : int, float, or None
|
|
463
542
|
The maximum value that can be entered. If this is ``None`` (default),
|
|
464
543
|
there will be no maximum.
|
|
465
544
|
|
|
466
|
-
step: int, float, or None
|
|
545
|
+
step : int, float, or None
|
|
467
546
|
The precision of numbers that can be entered. If this ``None``
|
|
468
547
|
(default), integer columns will have a step of 1 and float columns will
|
|
469
548
|
have unrestricted precision. In this case, some floats may display like
|
|
@@ -544,11 +623,11 @@ def TextColumn(
|
|
|
544
623
|
|
|
545
624
|
Parameters
|
|
546
625
|
----------
|
|
547
|
-
label: str or None
|
|
626
|
+
label : str or None
|
|
548
627
|
The label shown at the top of the column. If this is ``None``
|
|
549
628
|
(default), the column name is used.
|
|
550
629
|
|
|
551
|
-
width: "small", "medium", "large", int, or None
|
|
630
|
+
width : "small", "medium", "large", int, or None
|
|
552
631
|
The display width of the column. If this is ``None`` (default), the
|
|
553
632
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
554
633
|
one of the following:
|
|
@@ -558,7 +637,11 @@ def TextColumn(
|
|
|
558
637
|
- ``"large"``: 400px wide
|
|
559
638
|
- An integer specifying the width in pixels
|
|
560
639
|
|
|
561
|
-
|
|
640
|
+
If the total width of all columns is less than the width of the
|
|
641
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
642
|
+
columns.
|
|
643
|
+
|
|
644
|
+
help : str or None
|
|
562
645
|
A tooltip that gets displayed when hovering over the column label. If
|
|
563
646
|
this is ``None`` (default), no tooltip is displayed.
|
|
564
647
|
|
|
@@ -566,35 +649,35 @@ def TextColumn(
|
|
|
566
649
|
the Markdown directives described in the ``body`` parameter of
|
|
567
650
|
``st.markdown``.
|
|
568
651
|
|
|
569
|
-
disabled: bool or None
|
|
652
|
+
disabled : bool or None
|
|
570
653
|
Whether editing should be disabled for this column. If this is ``None``
|
|
571
654
|
(default), Streamlit will enable editing wherever possible.
|
|
572
655
|
|
|
573
656
|
If a column has mixed types, it may become uneditable regardless of
|
|
574
657
|
``disabled``.
|
|
575
658
|
|
|
576
|
-
required: bool or None
|
|
659
|
+
required : bool or None
|
|
577
660
|
Whether edited cells in the column need to have a value. If this is
|
|
578
661
|
``False`` (default), the user can submit empty values for this column.
|
|
579
662
|
If this is ``True``, an edited cell in this column can only be
|
|
580
663
|
submitted if its value is not ``None``, and a new row will only be
|
|
581
664
|
submitted after the user fills in this column.
|
|
582
665
|
|
|
583
|
-
pinned: bool or None
|
|
666
|
+
pinned : bool or None
|
|
584
667
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
585
668
|
left side no matter where the user scrolls. If this is ``None``
|
|
586
669
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
587
670
|
columns are not pinned.
|
|
588
671
|
|
|
589
|
-
default: str or None
|
|
672
|
+
default : str or None
|
|
590
673
|
Specifies the default value in this column when a new row is added by
|
|
591
674
|
the user. This defaults to ``None``.
|
|
592
675
|
|
|
593
|
-
max_chars: int or None
|
|
676
|
+
max_chars : int or None
|
|
594
677
|
The maximum number of characters that can be entered. If this is
|
|
595
678
|
``None`` (default), there will be no maximum.
|
|
596
679
|
|
|
597
|
-
validate: str or None
|
|
680
|
+
validate : str or None
|
|
598
681
|
A JS-flavored regular expression (e.g. ``"^[a-z]+$"``) that edited
|
|
599
682
|
values are validated against. If the user input is invalid, it will not
|
|
600
683
|
be submitted.
|
|
@@ -666,11 +749,11 @@ def LinkColumn(
|
|
|
666
749
|
|
|
667
750
|
Parameters
|
|
668
751
|
----------
|
|
669
|
-
label: str or None
|
|
752
|
+
label : str or None
|
|
670
753
|
The label shown at the top of the column. If this is ``None``
|
|
671
754
|
(default), the column name is used.
|
|
672
755
|
|
|
673
|
-
width: "small", "medium", "large", int, or None
|
|
756
|
+
width : "small", "medium", "large", int, or None
|
|
674
757
|
The display width of the column. If this is ``None`` (default), the
|
|
675
758
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
676
759
|
one of the following:
|
|
@@ -680,7 +763,11 @@ def LinkColumn(
|
|
|
680
763
|
- ``"large"``: 400px wide
|
|
681
764
|
- An integer specifying the width in pixels
|
|
682
765
|
|
|
683
|
-
|
|
766
|
+
If the total width of all columns is less than the width of the
|
|
767
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
768
|
+
columns.
|
|
769
|
+
|
|
770
|
+
help : str or None
|
|
684
771
|
A tooltip that gets displayed when hovering over the column label. If
|
|
685
772
|
this is ``None`` (default), no tooltip is displayed.
|
|
686
773
|
|
|
@@ -688,40 +775,40 @@ def LinkColumn(
|
|
|
688
775
|
the Markdown directives described in the ``body`` parameter of
|
|
689
776
|
``st.markdown``.
|
|
690
777
|
|
|
691
|
-
disabled: bool or None
|
|
778
|
+
disabled : bool or None
|
|
692
779
|
Whether editing should be disabled for this column. If this is ``None``
|
|
693
780
|
(default), Streamlit will enable editing wherever possible.
|
|
694
781
|
|
|
695
782
|
If a column has mixed types, it may become uneditable regardless of
|
|
696
783
|
``disabled``.
|
|
697
784
|
|
|
698
|
-
required: bool or None
|
|
785
|
+
required : bool or None
|
|
699
786
|
Whether edited cells in the column need to have a value. If this is
|
|
700
787
|
``False`` (default), the user can submit empty values for this column.
|
|
701
788
|
If this is ``True``, an edited cell in this column can only be
|
|
702
789
|
submitted if its value is not ``None``, and a new row will only be
|
|
703
790
|
submitted after the user fills in this column.
|
|
704
791
|
|
|
705
|
-
pinned: bool or None
|
|
792
|
+
pinned : bool or None
|
|
706
793
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
707
794
|
left side no matter where the user scrolls. If this is ``None``
|
|
708
795
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
709
796
|
columns are not pinned.
|
|
710
797
|
|
|
711
|
-
default: str or None
|
|
798
|
+
default : str or None
|
|
712
799
|
Specifies the default value in this column when a new row is added by
|
|
713
800
|
the user. This defaults to ``None``.
|
|
714
801
|
|
|
715
|
-
max_chars: int or None
|
|
802
|
+
max_chars : int or None
|
|
716
803
|
The maximum number of characters that can be entered. If this is
|
|
717
804
|
``None`` (default), there will be no maximum.
|
|
718
805
|
|
|
719
|
-
validate: str or None
|
|
806
|
+
validate : str or None
|
|
720
807
|
A JS-flavored regular expression (e.g. ``"^https://.+$"``) that edited
|
|
721
808
|
values are validated against. If the user input is invalid, it will not
|
|
722
809
|
be submitted.
|
|
723
810
|
|
|
724
|
-
display_text: str or None
|
|
811
|
+
display_text : str or None
|
|
725
812
|
The text that is displayed in the cell. This can be one of the
|
|
726
813
|
following:
|
|
727
814
|
|
|
@@ -824,11 +911,11 @@ def CheckboxColumn(
|
|
|
824
911
|
|
|
825
912
|
Parameters
|
|
826
913
|
----------
|
|
827
|
-
label: str or None
|
|
914
|
+
label : str or None
|
|
828
915
|
The label shown at the top of the column. If this is ``None``
|
|
829
916
|
(default), the column name is used.
|
|
830
917
|
|
|
831
|
-
width: "small", "medium", "large", int, or None
|
|
918
|
+
width : "small", "medium", "large", int, or None
|
|
832
919
|
The display width of the column. If this is ``None`` (default), the
|
|
833
920
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
834
921
|
one of the following:
|
|
@@ -838,7 +925,11 @@ def CheckboxColumn(
|
|
|
838
925
|
- ``"large"``: 400px wide
|
|
839
926
|
- An integer specifying the width in pixels
|
|
840
927
|
|
|
841
|
-
|
|
928
|
+
If the total width of all columns is less than the width of the
|
|
929
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
930
|
+
columns.
|
|
931
|
+
|
|
932
|
+
help : str or None
|
|
842
933
|
A tooltip that gets displayed when hovering over the column label. If
|
|
843
934
|
this is ``None`` (default), no tooltip is displayed.
|
|
844
935
|
|
|
@@ -846,27 +937,27 @@ def CheckboxColumn(
|
|
|
846
937
|
the Markdown directives described in the ``body`` parameter of
|
|
847
938
|
``st.markdown``.
|
|
848
939
|
|
|
849
|
-
disabled: bool or None
|
|
940
|
+
disabled : bool or None
|
|
850
941
|
Whether editing should be disabled for this column. If this is ``None``
|
|
851
942
|
(default), Streamlit will enable editing wherever possible.
|
|
852
943
|
|
|
853
944
|
If a column has mixed types, it may become uneditable regardless of
|
|
854
945
|
``disabled``.
|
|
855
946
|
|
|
856
|
-
required: bool or None
|
|
947
|
+
required : bool or None
|
|
857
948
|
Whether edited cells in the column need to have a value. If this is
|
|
858
949
|
``False`` (default), the user can submit empty values for this column.
|
|
859
950
|
If this is ``True``, an edited cell in this column can only be
|
|
860
951
|
submitted if its value is not ``None``, and a new row will only be
|
|
861
952
|
submitted after the user fills in this column.
|
|
862
953
|
|
|
863
|
-
pinned: bool or None
|
|
954
|
+
pinned : bool or None
|
|
864
955
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
865
956
|
left side no matter where the user scrolls. If this is ``None``
|
|
866
957
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
867
958
|
columns are not pinned.
|
|
868
959
|
|
|
869
|
-
default: bool or None
|
|
960
|
+
default : bool or None
|
|
870
961
|
Specifies the default value in this column when a new row is added by
|
|
871
962
|
the user. This defaults to ``None``.
|
|
872
963
|
|
|
@@ -933,11 +1024,11 @@ def SelectboxColumn(
|
|
|
933
1024
|
|
|
934
1025
|
Parameters
|
|
935
1026
|
----------
|
|
936
|
-
label: str or None
|
|
1027
|
+
label : str or None
|
|
937
1028
|
The label shown at the top of the column. If this is ``None``
|
|
938
1029
|
(default), the column name is used.
|
|
939
1030
|
|
|
940
|
-
width: "small", "medium", "large", int, or None
|
|
1031
|
+
width : "small", "medium", "large", int, or None
|
|
941
1032
|
The display width of the column. If this is ``None`` (default), the
|
|
942
1033
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
943
1034
|
one of the following:
|
|
@@ -947,7 +1038,11 @@ def SelectboxColumn(
|
|
|
947
1038
|
- ``"large"``: 400px wide
|
|
948
1039
|
- An integer specifying the width in pixels
|
|
949
1040
|
|
|
950
|
-
|
|
1041
|
+
If the total width of all columns is less than the width of the
|
|
1042
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
1043
|
+
columns.
|
|
1044
|
+
|
|
1045
|
+
help : str or None
|
|
951
1046
|
A tooltip that gets displayed when hovering over the column label. If
|
|
952
1047
|
this is ``None`` (default), no tooltip is displayed.
|
|
953
1048
|
|
|
@@ -955,43 +1050,42 @@ def SelectboxColumn(
|
|
|
955
1050
|
the Markdown directives described in the ``body`` parameter of
|
|
956
1051
|
``st.markdown``.
|
|
957
1052
|
|
|
958
|
-
disabled: bool or None
|
|
1053
|
+
disabled : bool or None
|
|
959
1054
|
Whether editing should be disabled for this column. If this is ``None``
|
|
960
1055
|
(default), Streamlit will enable editing wherever possible.
|
|
961
1056
|
|
|
962
1057
|
If a column has mixed types, it may become uneditable regardless of
|
|
963
1058
|
``disabled``.
|
|
964
1059
|
|
|
965
|
-
required: bool or None
|
|
1060
|
+
required : bool or None
|
|
966
1061
|
Whether edited cells in the column need to have a value. If this is
|
|
967
1062
|
``False`` (default), the user can submit empty values for this column.
|
|
968
1063
|
If this is ``True``, an edited cell in this column can only be
|
|
969
1064
|
submitted if its value is not ``None``, and a new row will only be
|
|
970
1065
|
submitted after the user fills in this column.
|
|
971
1066
|
|
|
972
|
-
pinned: bool or None
|
|
1067
|
+
pinned : bool or None
|
|
973
1068
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
974
1069
|
left side no matter where the user scrolls. If this is ``None``
|
|
975
1070
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
976
1071
|
columns are not pinned.
|
|
977
1072
|
|
|
978
|
-
default: str, int, float, bool, or None
|
|
1073
|
+
default : str, int, float, bool, or None
|
|
979
1074
|
Specifies the default value in this column when a new row is added by
|
|
980
1075
|
the user. This defaults to ``None``.
|
|
981
1076
|
|
|
982
|
-
options: Iterable[str, int, float, bool] or None
|
|
1077
|
+
options : Iterable[str, int, float, bool] or None
|
|
983
1078
|
The options that can be selected during editing. If this is ``None``
|
|
984
1079
|
(default), the options will be inferred from the underlying dataframe
|
|
985
1080
|
column if its dtype is "category". For more information, see `Pandas docs
|
|
986
1081
|
<https://pandas.pydata.org/docs/user_guide/categorical.html>`_).
|
|
987
1082
|
|
|
988
|
-
format_func: function or None
|
|
1083
|
+
format_func : function or None
|
|
989
1084
|
Function to modify the display of the options. It receives
|
|
990
1085
|
the raw option defined in ``options`` as an argument and should output
|
|
991
1086
|
the label to be shown for that option. If this is ``None`` (default),
|
|
992
1087
|
the raw option is used as the label.
|
|
993
1088
|
|
|
994
|
-
|
|
995
1089
|
Examples
|
|
996
1090
|
--------
|
|
997
1091
|
>>> import pandas as pd
|
|
@@ -1064,6 +1158,7 @@ def BarChartColumn(
|
|
|
1064
1158
|
pinned: bool | None = None,
|
|
1065
1159
|
y_min: int | float | None = None,
|
|
1066
1160
|
y_max: int | float | None = None,
|
|
1161
|
+
color: ChartColor | None = None,
|
|
1067
1162
|
) -> ColumnConfig:
|
|
1068
1163
|
"""Configure a bar chart column in ``st.dataframe`` or ``st.data_editor``.
|
|
1069
1164
|
|
|
@@ -1073,11 +1168,11 @@ def BarChartColumn(
|
|
|
1073
1168
|
|
|
1074
1169
|
Parameters
|
|
1075
1170
|
----------
|
|
1076
|
-
label: str or None
|
|
1171
|
+
label : str or None
|
|
1077
1172
|
The label shown at the top of the column. If this is ``None``
|
|
1078
1173
|
(default), the column name is used.
|
|
1079
1174
|
|
|
1080
|
-
width: "small", "medium", "large", int, or None
|
|
1175
|
+
width : "small", "medium", "large", int, or None
|
|
1081
1176
|
The display width of the column. If this is ``None`` (default), the
|
|
1082
1177
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
1083
1178
|
one of the following:
|
|
@@ -1087,7 +1182,11 @@ def BarChartColumn(
|
|
|
1087
1182
|
- ``"large"``: 400px wide
|
|
1088
1183
|
- An integer specifying the width in pixels
|
|
1089
1184
|
|
|
1090
|
-
|
|
1185
|
+
If the total width of all columns is less than the width of the
|
|
1186
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
1187
|
+
columns.
|
|
1188
|
+
|
|
1189
|
+
help : str or None
|
|
1091
1190
|
A tooltip that gets displayed when hovering over the column label. If
|
|
1092
1191
|
this is ``None`` (default), no tooltip is displayed.
|
|
1093
1192
|
|
|
@@ -1101,14 +1200,27 @@ def BarChartColumn(
|
|
|
1101
1200
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
1102
1201
|
columns are not pinned.
|
|
1103
1202
|
|
|
1104
|
-
y_min: int, float, or None
|
|
1203
|
+
y_min : int, float, or None
|
|
1105
1204
|
The minimum value on the y-axis for all cells in the column. If this is
|
|
1106
1205
|
``None`` (default), every cell will use the minimum of its data.
|
|
1107
1206
|
|
|
1108
|
-
y_max: int, float, or None
|
|
1207
|
+
y_max : int, float, or None
|
|
1109
1208
|
The maximum value on the y-axis for all cells in the column. If this is
|
|
1110
1209
|
``None`` (default), every cell will use the maximum of its data.
|
|
1111
1210
|
|
|
1211
|
+
color : "auto", "auto-inverse", str, or None
|
|
1212
|
+
The color to use for the chart. This can be one of the following:
|
|
1213
|
+
|
|
1214
|
+
- ``None`` (default): The primary color is used.
|
|
1215
|
+
- ``"auto"``: If the data is increasing, the chart is green; if the
|
|
1216
|
+
data is decreasing, the chart is red.
|
|
1217
|
+
- ``"auto-inverse"``: If the data is increasing, the chart is red; if
|
|
1218
|
+
the data is decreasing, the chart is green.
|
|
1219
|
+
- A single color value that is applied to all charts in the column.
|
|
1220
|
+
In addition to the basic color palette (red, orange, yellow, green,
|
|
1221
|
+
blue, violet, gray/grey, and primary), this supports hex codes like
|
|
1222
|
+
``"#483d8b"``.
|
|
1223
|
+
|
|
1112
1224
|
Examples
|
|
1113
1225
|
--------
|
|
1114
1226
|
>>> import pandas as pd
|
|
@@ -1143,12 +1255,17 @@ def BarChartColumn(
|
|
|
1143
1255
|
height: 300px
|
|
1144
1256
|
"""
|
|
1145
1257
|
|
|
1258
|
+
if color is not None:
|
|
1259
|
+
_validate_chart_color(color)
|
|
1260
|
+
|
|
1146
1261
|
return ColumnConfig(
|
|
1147
1262
|
label=label,
|
|
1148
1263
|
width=width,
|
|
1149
1264
|
help=help,
|
|
1150
1265
|
pinned=pinned,
|
|
1151
|
-
type_config=BarChartColumnConfig(
|
|
1266
|
+
type_config=BarChartColumnConfig(
|
|
1267
|
+
type="bar_chart", y_min=y_min, y_max=y_max, color=color
|
|
1268
|
+
),
|
|
1152
1269
|
)
|
|
1153
1270
|
|
|
1154
1271
|
|
|
@@ -1161,6 +1278,7 @@ def LineChartColumn(
|
|
|
1161
1278
|
pinned: bool | None = None,
|
|
1162
1279
|
y_min: int | float | None = None,
|
|
1163
1280
|
y_max: int | float | None = None,
|
|
1281
|
+
color: ChartColor | None = None,
|
|
1164
1282
|
) -> ColumnConfig:
|
|
1165
1283
|
"""Configure a line chart column in ``st.dataframe`` or ``st.data_editor``.
|
|
1166
1284
|
|
|
@@ -1170,11 +1288,11 @@ def LineChartColumn(
|
|
|
1170
1288
|
|
|
1171
1289
|
Parameters
|
|
1172
1290
|
----------
|
|
1173
|
-
label: str or None
|
|
1291
|
+
label : str or None
|
|
1174
1292
|
The label shown at the top of the column. If this is ``None``
|
|
1175
1293
|
(default), the column name is used.
|
|
1176
1294
|
|
|
1177
|
-
width: "small", "medium", "large", int, or None
|
|
1295
|
+
width : "small", "medium", "large", int, or None
|
|
1178
1296
|
The display width of the column. If this is ``None`` (default), the
|
|
1179
1297
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
1180
1298
|
one of the following:
|
|
@@ -1184,7 +1302,11 @@ def LineChartColumn(
|
|
|
1184
1302
|
- ``"large"``: 400px wide
|
|
1185
1303
|
- An integer specifying the width in pixels
|
|
1186
1304
|
|
|
1187
|
-
|
|
1305
|
+
If the total width of all columns is less than the width of the
|
|
1306
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
1307
|
+
columns.
|
|
1308
|
+
|
|
1309
|
+
help : str or None
|
|
1188
1310
|
A tooltip that gets displayed when hovering over the column label. If
|
|
1189
1311
|
this is ``None`` (default), no tooltip is displayed.
|
|
1190
1312
|
|
|
@@ -1192,20 +1314,33 @@ def LineChartColumn(
|
|
|
1192
1314
|
the Markdown directives described in the ``body`` parameter of
|
|
1193
1315
|
``st.markdown``.
|
|
1194
1316
|
|
|
1195
|
-
pinned: bool or None
|
|
1317
|
+
pinned : bool or None
|
|
1196
1318
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
1197
1319
|
left side no matter where the user scrolls. If this is ``None``
|
|
1198
1320
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
1199
1321
|
columns are not pinned.
|
|
1200
1322
|
|
|
1201
|
-
y_min: int, float, or None
|
|
1323
|
+
y_min : int, float, or None
|
|
1202
1324
|
The minimum value on the y-axis for all cells in the column. If this is
|
|
1203
1325
|
``None`` (default), every cell will use the minimum of its data.
|
|
1204
1326
|
|
|
1205
|
-
y_max: int, float, or None
|
|
1327
|
+
y_max : int, float, or None
|
|
1206
1328
|
The maximum value on the y-axis for all cells in the column. If this is
|
|
1207
1329
|
``None`` (default), every cell will use the maximum of its data.
|
|
1208
1330
|
|
|
1331
|
+
color : "auto", "auto-inverse", str, or None
|
|
1332
|
+
The color to use for the chart. This can be one of the following:
|
|
1333
|
+
|
|
1334
|
+
- ``None`` (default): The primary color is used.
|
|
1335
|
+
- ``"auto"``: If the data is increasing, the chart is green; if the
|
|
1336
|
+
data is decreasing, the chart is red.
|
|
1337
|
+
- ``"auto-inverse"``: If the data is increasing, the chart is red; if
|
|
1338
|
+
the data is decreasing, the chart is green.
|
|
1339
|
+
- A single color value that is applied to all charts in the column.
|
|
1340
|
+
In addition to the basic color palette (red, orange, yellow, green,
|
|
1341
|
+
blue, violet, gray/grey, and primary), this supports hex codes like
|
|
1342
|
+
``"#483d8b"``.
|
|
1343
|
+
|
|
1209
1344
|
Examples
|
|
1210
1345
|
--------
|
|
1211
1346
|
>>> import pandas as pd
|
|
@@ -1240,13 +1375,16 @@ def LineChartColumn(
|
|
|
1240
1375
|
https://doc-linechart-column.streamlit.app/
|
|
1241
1376
|
height: 300px
|
|
1242
1377
|
"""
|
|
1243
|
-
|
|
1378
|
+
if color is not None:
|
|
1379
|
+
_validate_chart_color(color)
|
|
1244
1380
|
return ColumnConfig(
|
|
1245
1381
|
label=label,
|
|
1246
1382
|
width=width,
|
|
1247
1383
|
help=help,
|
|
1248
1384
|
pinned=pinned,
|
|
1249
|
-
type_config=LineChartColumnConfig(
|
|
1385
|
+
type_config=LineChartColumnConfig(
|
|
1386
|
+
type="line_chart", y_min=y_min, y_max=y_max, color=color
|
|
1387
|
+
),
|
|
1250
1388
|
)
|
|
1251
1389
|
|
|
1252
1390
|
|
|
@@ -1259,6 +1397,7 @@ def AreaChartColumn(
|
|
|
1259
1397
|
pinned: bool | None = None,
|
|
1260
1398
|
y_min: int | float | None = None,
|
|
1261
1399
|
y_max: int | float | None = None,
|
|
1400
|
+
color: ChartColor | None = None,
|
|
1262
1401
|
) -> ColumnConfig:
|
|
1263
1402
|
"""Configure an area chart column in ``st.dataframe`` or ``st.data_editor``.
|
|
1264
1403
|
|
|
@@ -1268,11 +1407,11 @@ def AreaChartColumn(
|
|
|
1268
1407
|
|
|
1269
1408
|
Parameters
|
|
1270
1409
|
----------
|
|
1271
|
-
label: str or None
|
|
1410
|
+
label : str or None
|
|
1272
1411
|
The label shown at the top of the column. If this is ``None``
|
|
1273
1412
|
(default), the column name is used.
|
|
1274
1413
|
|
|
1275
|
-
width: "small", "medium", "large", int, or None
|
|
1414
|
+
width : "small", "medium", "large", int, or None
|
|
1276
1415
|
The display width of the column. If this is ``None`` (default), the
|
|
1277
1416
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
1278
1417
|
one of the following:
|
|
@@ -1282,7 +1421,11 @@ def AreaChartColumn(
|
|
|
1282
1421
|
- ``"large"``: 400px wide
|
|
1283
1422
|
- An integer specifying the width in pixels
|
|
1284
1423
|
|
|
1285
|
-
|
|
1424
|
+
If the total width of all columns is less than the width of the
|
|
1425
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
1426
|
+
columns.
|
|
1427
|
+
|
|
1428
|
+
help : str or None
|
|
1286
1429
|
A tooltip that gets displayed when hovering over the column label. If
|
|
1287
1430
|
this is ``None`` (default), no tooltip is displayed.
|
|
1288
1431
|
|
|
@@ -1290,20 +1433,35 @@ def AreaChartColumn(
|
|
|
1290
1433
|
the Markdown directives described in the ``body`` parameter of
|
|
1291
1434
|
``st.markdown``.
|
|
1292
1435
|
|
|
1293
|
-
pinned: bool or None
|
|
1436
|
+
pinned : bool or None
|
|
1294
1437
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
1295
1438
|
left side no matter where the user scrolls. If this is ``None``
|
|
1296
1439
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
1297
1440
|
columns are not pinned.
|
|
1298
1441
|
|
|
1299
|
-
y_min: int, float, or None
|
|
1442
|
+
y_min : int, float, or None
|
|
1300
1443
|
The minimum value on the y-axis for all cells in the column. If this is
|
|
1301
1444
|
``None`` (default), every cell will use the minimum of its data.
|
|
1302
1445
|
|
|
1303
|
-
y_max: int, float, or None
|
|
1446
|
+
y_max : int, float, or None
|
|
1304
1447
|
The maximum value on the y-axis for all cells in the column. If this is
|
|
1305
1448
|
``None`` (default), every cell will use the maximum of its data.
|
|
1306
1449
|
|
|
1450
|
+
color : "auto", "auto-inverse", str, or None
|
|
1451
|
+
The color to use for the chart. This can be one of the following:
|
|
1452
|
+
|
|
1453
|
+
- ``None`` (default): The primary color is used.
|
|
1454
|
+
- ``"auto"``: If the data is increasing, the chart is green; if the
|
|
1455
|
+
data is decreasing, the chart is red.
|
|
1456
|
+
- ``"auto-inverse"``: If the data is increasing, the chart is red; if
|
|
1457
|
+
the data is decreasing, the chart is green.
|
|
1458
|
+
- A single color value that is applied to all charts in the column.
|
|
1459
|
+
In addition to the basic color palette (red, orange, yellow, green,
|
|
1460
|
+
blue, violet, gray/grey, and primary), this supports hex codes like
|
|
1461
|
+
``"#483d8b"``.
|
|
1462
|
+
|
|
1463
|
+
The basic color palette can be configured in the theme settings.
|
|
1464
|
+
|
|
1307
1465
|
Examples
|
|
1308
1466
|
--------
|
|
1309
1467
|
>>> import pandas as pd
|
|
@@ -1339,12 +1497,16 @@ def AreaChartColumn(
|
|
|
1339
1497
|
height: 300px
|
|
1340
1498
|
"""
|
|
1341
1499
|
|
|
1500
|
+
if color is not None:
|
|
1501
|
+
_validate_chart_color(color)
|
|
1342
1502
|
return ColumnConfig(
|
|
1343
1503
|
label=label,
|
|
1344
1504
|
width=width,
|
|
1345
1505
|
help=help,
|
|
1346
1506
|
pinned=pinned,
|
|
1347
|
-
type_config=AreaChartColumnConfig(
|
|
1507
|
+
type_config=AreaChartColumnConfig(
|
|
1508
|
+
type="area_chart", y_min=y_min, y_max=y_max, color=color
|
|
1509
|
+
),
|
|
1348
1510
|
)
|
|
1349
1511
|
|
|
1350
1512
|
|
|
@@ -1372,11 +1534,11 @@ def ImageColumn(
|
|
|
1372
1534
|
|
|
1373
1535
|
Parameters
|
|
1374
1536
|
----------
|
|
1375
|
-
label: str or None
|
|
1537
|
+
label : str or None
|
|
1376
1538
|
The label shown at the top of the column. If this is ``None``
|
|
1377
1539
|
(default), the column name is used.
|
|
1378
1540
|
|
|
1379
|
-
width: "small", "medium", "large", int, or None
|
|
1541
|
+
width : "small", "medium", "large", int, or None
|
|
1380
1542
|
The display width of the column. If this is ``None`` (default), the
|
|
1381
1543
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
1382
1544
|
one of the following:
|
|
@@ -1386,7 +1548,11 @@ def ImageColumn(
|
|
|
1386
1548
|
- ``"large"``: 400px wide
|
|
1387
1549
|
- An integer specifying the width in pixels
|
|
1388
1550
|
|
|
1389
|
-
|
|
1551
|
+
If the total width of all columns is less than the width of the
|
|
1552
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
1553
|
+
columns.
|
|
1554
|
+
|
|
1555
|
+
help : str or None
|
|
1390
1556
|
A tooltip that gets displayed when hovering over the column label. If
|
|
1391
1557
|
this is ``None`` (default), no tooltip is displayed.
|
|
1392
1558
|
|
|
@@ -1394,7 +1560,7 @@ def ImageColumn(
|
|
|
1394
1560
|
the Markdown directives described in the ``body`` parameter of
|
|
1395
1561
|
``st.markdown``.
|
|
1396
1562
|
|
|
1397
|
-
pinned: bool or None
|
|
1563
|
+
pinned : bool or None
|
|
1398
1564
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
1399
1565
|
left side no matter where the user scrolls. If this is ``None``
|
|
1400
1566
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
@@ -1454,20 +1620,21 @@ def ListColumn(
|
|
|
1454
1620
|
|
|
1455
1621
|
This is the default column type for list-like values. This command needs to
|
|
1456
1622
|
be used in the ``column_config`` parameter of ``st.dataframe`` or
|
|
1457
|
-
``st.data_editor``.
|
|
1623
|
+
``st.data_editor``. When used with ``st.data_editor``, users can freely
|
|
1624
|
+
type in new options and remove existing ones.
|
|
1458
1625
|
|
|
1459
1626
|
.. Note::
|
|
1460
1627
|
Editing for non-string or mixed type lists can cause issues with Arrow
|
|
1461
|
-
serialization. We recommend you disable editing for these columns
|
|
1462
|
-
convert
|
|
1628
|
+
serialization. We recommend that you disable editing for these columns
|
|
1629
|
+
or convert all list values to strings.
|
|
1463
1630
|
|
|
1464
1631
|
Parameters
|
|
1465
1632
|
----------
|
|
1466
|
-
label: str or None
|
|
1633
|
+
label : str or None
|
|
1467
1634
|
The label shown at the top of the column. If this is ``None``
|
|
1468
1635
|
(default), the column name is used.
|
|
1469
1636
|
|
|
1470
|
-
width: "small", "medium", "large", int, or None
|
|
1637
|
+
width : "small", "medium", "large", int, or None
|
|
1471
1638
|
The display width of the column. If this is ``None`` (default), the
|
|
1472
1639
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
1473
1640
|
one of the following:
|
|
@@ -1477,7 +1644,11 @@ def ListColumn(
|
|
|
1477
1644
|
- ``"large"``: 400px wide
|
|
1478
1645
|
- An integer specifying the width in pixels
|
|
1479
1646
|
|
|
1480
|
-
|
|
1647
|
+
If the total width of all columns is less than the width of the
|
|
1648
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
1649
|
+
columns.
|
|
1650
|
+
|
|
1651
|
+
help : str or None
|
|
1481
1652
|
A tooltip that gets displayed when hovering over the column label. If
|
|
1482
1653
|
this is ``None`` (default), no tooltip is displayed.
|
|
1483
1654
|
|
|
@@ -1485,27 +1656,27 @@ def ListColumn(
|
|
|
1485
1656
|
the Markdown directives described in the ``body`` parameter of
|
|
1486
1657
|
``st.markdown``.
|
|
1487
1658
|
|
|
1488
|
-
pinned: bool or None
|
|
1659
|
+
pinned : bool or None
|
|
1489
1660
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
1490
1661
|
left side no matter where the user scrolls. If this is ``None``
|
|
1491
1662
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
1492
1663
|
columns are not pinned.
|
|
1493
1664
|
|
|
1494
|
-
disabled: bool or None
|
|
1665
|
+
disabled : bool or None
|
|
1495
1666
|
Whether editing should be disabled for this column. If this is ``None``
|
|
1496
1667
|
(default), Streamlit will enable editing wherever possible.
|
|
1497
1668
|
|
|
1498
1669
|
If a column has mixed types, it may become uneditable regardless of
|
|
1499
1670
|
``disabled``.
|
|
1500
1671
|
|
|
1501
|
-
required: bool or None
|
|
1672
|
+
required : bool or None
|
|
1502
1673
|
Whether edited cells in the column need to have a value. If this is
|
|
1503
1674
|
``False`` (default), the user can submit empty values for this column.
|
|
1504
1675
|
If this is ``True``, an edited cell in this column can only be
|
|
1505
1676
|
submitted if its value is not ``None``, and a new row will only be
|
|
1506
1677
|
submitted after the user fills in this column.
|
|
1507
1678
|
|
|
1508
|
-
default: Iterable of str or None
|
|
1679
|
+
default : Iterable of str or None
|
|
1509
1680
|
Specifies the default value in this column when a new row is added by
|
|
1510
1681
|
the user. This defaults to ``None``.
|
|
1511
1682
|
|
|
@@ -1553,6 +1724,234 @@ def ListColumn(
|
|
|
1553
1724
|
)
|
|
1554
1725
|
|
|
1555
1726
|
|
|
1727
|
+
@gather_metrics("column_config.MultiselectColumn")
|
|
1728
|
+
def MultiselectColumn(
|
|
1729
|
+
label: str | None = None,
|
|
1730
|
+
*,
|
|
1731
|
+
width: ColumnWidth | None = None,
|
|
1732
|
+
help: str | None = None,
|
|
1733
|
+
disabled: bool | None = None,
|
|
1734
|
+
required: bool | None = None,
|
|
1735
|
+
default: Iterable[str] | None = None,
|
|
1736
|
+
options: Iterable[str] | None = None,
|
|
1737
|
+
accept_new_options: bool | None = None,
|
|
1738
|
+
color: str | ThemeColor | Iterable[str | ThemeColor] | None = None,
|
|
1739
|
+
format_func: Callable[[str], str] | None = None,
|
|
1740
|
+
) -> ColumnConfig:
|
|
1741
|
+
"""Configure a multiselect column in ``st.dataframe`` or ``st.data_editor``.
|
|
1742
|
+
|
|
1743
|
+
This command needs to be used in the ``column_config`` parameter of
|
|
1744
|
+
``st.dataframe`` or ``st.data_editor``. When used with ``st.data_editor``,
|
|
1745
|
+
users can select options from a dropdown menu. You can configure the
|
|
1746
|
+
column to allow freely typed options, too.
|
|
1747
|
+
|
|
1748
|
+
You can also use this column type to display colored labels in a read-only
|
|
1749
|
+
``st.dataframe``.
|
|
1750
|
+
|
|
1751
|
+
.. Note::
|
|
1752
|
+
Editing for non-string or mixed type lists can cause issues with Arrow
|
|
1753
|
+
serialization. We recommend that you disable editing for these columns
|
|
1754
|
+
or convert all list values to strings.
|
|
1755
|
+
|
|
1756
|
+
Parameters
|
|
1757
|
+
----------
|
|
1758
|
+
label : str or None
|
|
1759
|
+
The label shown at the top of the column. If None (default),
|
|
1760
|
+
the column name is used.
|
|
1761
|
+
|
|
1762
|
+
width : "small", "medium", "large", or None
|
|
1763
|
+
The display width of the column. If this is ``None`` (default), the
|
|
1764
|
+
column will be sized to fit the cell contents. Otherwise, this can be
|
|
1765
|
+
one of the following:
|
|
1766
|
+
|
|
1767
|
+
- ``"small"``: 75px wide
|
|
1768
|
+
- ``"medium"``: 200px wide
|
|
1769
|
+
- ``"large"``: 400px wide
|
|
1770
|
+
- An integer specifying the width in pixels
|
|
1771
|
+
|
|
1772
|
+
If the total width of all columns is less than the width of the
|
|
1773
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
1774
|
+
columns.
|
|
1775
|
+
|
|
1776
|
+
help : str or None
|
|
1777
|
+
A tooltip that gets displayed when hovering over the column label. If
|
|
1778
|
+
this is ``None`` (default), no tooltip is displayed.
|
|
1779
|
+
|
|
1780
|
+
The tooltip can optionally contain GitHub-flavored Markdown, including
|
|
1781
|
+
the Markdown directives described in the ``body`` parameter of
|
|
1782
|
+
``st.markdown``.
|
|
1783
|
+
|
|
1784
|
+
disabled : bool or None
|
|
1785
|
+
Whether editing should be disabled for this column. Defaults to False.
|
|
1786
|
+
|
|
1787
|
+
required : bool or None
|
|
1788
|
+
Whether edited cells in the column need to have a value. If True, an edited cell
|
|
1789
|
+
can only be submitted if it has a value other than None. Defaults to False.
|
|
1790
|
+
|
|
1791
|
+
default : Iterable of str or None
|
|
1792
|
+
Specifies the default value in this column when a new row is added by the user.
|
|
1793
|
+
|
|
1794
|
+
options : Iterable of str or None
|
|
1795
|
+
The options that can be selected during editing.
|
|
1796
|
+
|
|
1797
|
+
accept_new_options : bool or None
|
|
1798
|
+
Whether the user can add selections that aren't included in ``options``.
|
|
1799
|
+
If this is ``False`` (default), the user can only select from the
|
|
1800
|
+
items in ``options``. If this is ``True``, the user can enter new
|
|
1801
|
+
items that don't exist in ``options``.
|
|
1802
|
+
|
|
1803
|
+
When a user enters and selects a new item, it is included in the
|
|
1804
|
+
returned cell list value as a string. The new item is not added to
|
|
1805
|
+
the options drop-down menu.
|
|
1806
|
+
|
|
1807
|
+
color : str, Iterable of str, or None
|
|
1808
|
+
The color to use for different options. This can be:
|
|
1809
|
+
|
|
1810
|
+
- None (default): The options are displayed without color.
|
|
1811
|
+
- A single color value that is used for all options. This can be one of
|
|
1812
|
+
the following strings:
|
|
1813
|
+
|
|
1814
|
+
- ``"primary"`` to use the primary theme color.
|
|
1815
|
+
- A CSS named color name like ``"darkBlue"`` or ``"maroon"``.
|
|
1816
|
+
- A hex color code like ``"#483d8b"`` or ``"#6A5ACD80"``.
|
|
1817
|
+
- An RGB or RGBA color code like ``"rgb(255,0,0)"`` or
|
|
1818
|
+
``"RGB(70, 130, 180, .7)"``.
|
|
1819
|
+
- An HSL or HSLA color code like ``"hsl(248, 53%, 58%)"``
|
|
1820
|
+
or ``"HSL(147, 50%, 47%, .3)"``.
|
|
1821
|
+
|
|
1822
|
+
- An iterable of color values that are mapped to the options. The colors
|
|
1823
|
+
are applied in sequence, cycling through the iterable if there are
|
|
1824
|
+
more options than colors.
|
|
1825
|
+
|
|
1826
|
+
format_func : function or None
|
|
1827
|
+
Function to modify the display of the options. It receives
|
|
1828
|
+
the raw option defined in ``options`` as an argument and should output
|
|
1829
|
+
the label to be shown for that option. When used in ``st.data_editor``,
|
|
1830
|
+
this has no impact on the returned value. If this is ``None``
|
|
1831
|
+
(default), the raw option is used as the label.
|
|
1832
|
+
|
|
1833
|
+
Examples
|
|
1834
|
+
--------
|
|
1835
|
+
**Example 1: Editable multiselect column**
|
|
1836
|
+
|
|
1837
|
+
To customize the label colors, provide a list of colors to the ``color``
|
|
1838
|
+
parameter. You can also format the option labels with the ``format_func``
|
|
1839
|
+
parameter.
|
|
1840
|
+
|
|
1841
|
+
>>> import pandas as pd
|
|
1842
|
+
>>> import streamlit as st
|
|
1843
|
+
>>>
|
|
1844
|
+
>>> data_df = pd.DataFrame(
|
|
1845
|
+
... {
|
|
1846
|
+
... "category": [
|
|
1847
|
+
... ["exploration", "visualization"],
|
|
1848
|
+
... ["llm", "visualization"],
|
|
1849
|
+
... ["exploration"],
|
|
1850
|
+
... ],
|
|
1851
|
+
... }
|
|
1852
|
+
... )
|
|
1853
|
+
>>>
|
|
1854
|
+
>>> st.data_editor(
|
|
1855
|
+
... data_df,
|
|
1856
|
+
... column_config={
|
|
1857
|
+
... "category": st.column_config.MultiselectColumn(
|
|
1858
|
+
... "App Categories",
|
|
1859
|
+
... help="The categories of the app",
|
|
1860
|
+
... options=[
|
|
1861
|
+
... "exploration",
|
|
1862
|
+
... "visualization",
|
|
1863
|
+
... "llm",
|
|
1864
|
+
... ],
|
|
1865
|
+
... color=["#ffa421", "#803df5", "#00c0f2"],
|
|
1866
|
+
... format_func=lambda x: x.capitalize(),
|
|
1867
|
+
... ),
|
|
1868
|
+
... },
|
|
1869
|
+
... )
|
|
1870
|
+
|
|
1871
|
+
.. output::
|
|
1872
|
+
https://doc-multiselect-column-1.streamlit.app/
|
|
1873
|
+
height: 300px
|
|
1874
|
+
|
|
1875
|
+
**Example 2: Colored tags for st.dataframe**
|
|
1876
|
+
|
|
1877
|
+
When using ``st.dataframe``, the multiselect column is read-only
|
|
1878
|
+
and can be used to display colored tags. In this example, the dataframe
|
|
1879
|
+
uses the primary theme color for all tags.
|
|
1880
|
+
|
|
1881
|
+
>>> import pandas as pd
|
|
1882
|
+
>>> import streamlit as st
|
|
1883
|
+
>>>
|
|
1884
|
+
>>> data_df = pd.DataFrame(
|
|
1885
|
+
... {
|
|
1886
|
+
... "category": [
|
|
1887
|
+
... ["exploration", "visualization"],
|
|
1888
|
+
... ["llm", "visualization"],
|
|
1889
|
+
... ["exploration"],
|
|
1890
|
+
... ],
|
|
1891
|
+
... }
|
|
1892
|
+
... )
|
|
1893
|
+
>>>
|
|
1894
|
+
>>> st.dataframe(
|
|
1895
|
+
... data_df,
|
|
1896
|
+
... column_config={
|
|
1897
|
+
... "category": st.column_config.MultiselectColumn(
|
|
1898
|
+
... "App Categories",
|
|
1899
|
+
... options=["exploration", "visualization", "llm"],
|
|
1900
|
+
... color="primary",
|
|
1901
|
+
... format_func=lambda x: x.capitalize(),
|
|
1902
|
+
... ),
|
|
1903
|
+
... },
|
|
1904
|
+
... )
|
|
1905
|
+
|
|
1906
|
+
.. output::
|
|
1907
|
+
https://doc-multiselect-column-2.streamlit.app/
|
|
1908
|
+
height: 300px
|
|
1909
|
+
"""
|
|
1910
|
+
|
|
1911
|
+
# Process options with color and format_func:
|
|
1912
|
+
processed_options: list[MultiselectOption] | None = None
|
|
1913
|
+
if options is not None:
|
|
1914
|
+
processed_options = []
|
|
1915
|
+
|
|
1916
|
+
# Convert color to an iterator
|
|
1917
|
+
color_iter: Iterator[str] | None = None
|
|
1918
|
+
if color is not None:
|
|
1919
|
+
if isinstance(color, str):
|
|
1920
|
+
# Single color for all options
|
|
1921
|
+
color_iter = itertools.repeat(color)
|
|
1922
|
+
else:
|
|
1923
|
+
# Iterable of colors - cycle through them
|
|
1924
|
+
color_iter = itertools.cycle(color)
|
|
1925
|
+
|
|
1926
|
+
for option in options:
|
|
1927
|
+
# Start with the option value
|
|
1928
|
+
option_dict = MultiselectOption(value=option)
|
|
1929
|
+
|
|
1930
|
+
# Apply format_func to generate label if not already present
|
|
1931
|
+
if format_func is not None:
|
|
1932
|
+
option_dict["label"] = format_func(option_dict["value"])
|
|
1933
|
+
|
|
1934
|
+
# Apply color if provided and not already present
|
|
1935
|
+
if color_iter is not None and "color" not in option_dict:
|
|
1936
|
+
option_dict["color"] = next(color_iter)
|
|
1937
|
+
|
|
1938
|
+
processed_options.append(option_dict)
|
|
1939
|
+
|
|
1940
|
+
return ColumnConfig(
|
|
1941
|
+
label=label,
|
|
1942
|
+
width=width,
|
|
1943
|
+
help=help,
|
|
1944
|
+
disabled=disabled,
|
|
1945
|
+
required=required,
|
|
1946
|
+
default=None if default is None else list(default),
|
|
1947
|
+
type_config=MultiselectColumnConfig(
|
|
1948
|
+
type="multiselect",
|
|
1949
|
+
options=processed_options,
|
|
1950
|
+
accept_new_options=accept_new_options,
|
|
1951
|
+
),
|
|
1952
|
+
)
|
|
1953
|
+
|
|
1954
|
+
|
|
1556
1955
|
@gather_metrics("column_config.DatetimeColumn")
|
|
1557
1956
|
def DatetimeColumn(
|
|
1558
1957
|
label: str | None = None,
|
|
@@ -1578,11 +1977,11 @@ def DatetimeColumn(
|
|
|
1578
1977
|
|
|
1579
1978
|
Parameters
|
|
1580
1979
|
----------
|
|
1581
|
-
label: str or None
|
|
1980
|
+
label : str or None
|
|
1582
1981
|
The label shown at the top of the column. If this is ``None``
|
|
1583
1982
|
(default), the column name is used.
|
|
1584
1983
|
|
|
1585
|
-
width: "small", "medium", "large", int, or None
|
|
1984
|
+
width : "small", "medium", "large", int, or None
|
|
1586
1985
|
The display width of the column. If this is ``None`` (default), the
|
|
1587
1986
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
1588
1987
|
one of the following:
|
|
@@ -1592,7 +1991,11 @@ def DatetimeColumn(
|
|
|
1592
1991
|
- ``"large"``: 400px wide
|
|
1593
1992
|
- An integer specifying the width in pixels
|
|
1594
1993
|
|
|
1595
|
-
|
|
1994
|
+
If the total width of all columns is less than the width of the
|
|
1995
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
1996
|
+
columns.
|
|
1997
|
+
|
|
1998
|
+
help : str or None
|
|
1596
1999
|
A tooltip that gets displayed when hovering over the column label. If
|
|
1597
2000
|
this is ``None`` (default), no tooltip is displayed.
|
|
1598
2001
|
|
|
@@ -1600,31 +2003,31 @@ def DatetimeColumn(
|
|
|
1600
2003
|
the Markdown directives described in the ``body`` parameter of
|
|
1601
2004
|
``st.markdown``.
|
|
1602
2005
|
|
|
1603
|
-
disabled: bool or None
|
|
2006
|
+
disabled : bool or None
|
|
1604
2007
|
Whether editing should be disabled for this column. If this is ``None``
|
|
1605
2008
|
(default), Streamlit will enable editing wherever possible.
|
|
1606
2009
|
|
|
1607
2010
|
If a column has mixed types, it may become uneditable regardless of
|
|
1608
2011
|
``disabled``.
|
|
1609
2012
|
|
|
1610
|
-
required: bool or None
|
|
2013
|
+
required : bool or None
|
|
1611
2014
|
Whether edited cells in the column need to have a value. If this is
|
|
1612
2015
|
``False`` (default), the user can submit empty values for this column.
|
|
1613
2016
|
If this is ``True``, an edited cell in this column can only be
|
|
1614
2017
|
submitted if its value is not ``None``, and a new row will only be
|
|
1615
2018
|
submitted after the user fills in this column.
|
|
1616
2019
|
|
|
1617
|
-
pinned: bool or None
|
|
2020
|
+
pinned : bool or None
|
|
1618
2021
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
1619
2022
|
left side no matter where the user scrolls. If this is ``None``
|
|
1620
2023
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
1621
2024
|
columns are not pinned.
|
|
1622
2025
|
|
|
1623
|
-
default: datetime.datetime or None
|
|
2026
|
+
default : datetime.datetime or None
|
|
1624
2027
|
Specifies the default value in this column when a new row is added by
|
|
1625
2028
|
the user. This defaults to ``None``.
|
|
1626
2029
|
|
|
1627
|
-
format: str, "localized", "distance", "calendar", "iso8601", or None
|
|
2030
|
+
format : str, "localized", "distance", "calendar", "iso8601", or None
|
|
1628
2031
|
A format string controlling how datetimes are displayed.
|
|
1629
2032
|
This can be one of the following values:
|
|
1630
2033
|
|
|
@@ -1646,19 +2049,19 @@ def DatetimeColumn(
|
|
|
1646
2049
|
formatting from ``pandas.Styler``. The formatting does not impact the
|
|
1647
2050
|
return value when used in ``st.data_editor``.
|
|
1648
2051
|
|
|
1649
|
-
min_value: datetime.datetime or None
|
|
2052
|
+
min_value : datetime.datetime or None
|
|
1650
2053
|
The minimum datetime that can be entered. If this is ``None``
|
|
1651
2054
|
(default), there will be no minimum.
|
|
1652
2055
|
|
|
1653
|
-
max_value: datetime.datetime or None
|
|
2056
|
+
max_value : datetime.datetime or None
|
|
1654
2057
|
The maximum datetime that can be entered. If this is ``None``
|
|
1655
2058
|
(default), there will be no maximum.
|
|
1656
2059
|
|
|
1657
|
-
step: int, float, datetime.timedelta, or None
|
|
2060
|
+
step : int, float, datetime.timedelta, or None
|
|
1658
2061
|
The stepping interval in seconds. If this is ``None`` (default), the
|
|
1659
2062
|
step will be 1 second.
|
|
1660
2063
|
|
|
1661
|
-
timezone: str or None
|
|
2064
|
+
timezone : str or None
|
|
1662
2065
|
The timezone of this column. If this is ``None`` (default), the
|
|
1663
2066
|
timezone is inferred from the underlying data.
|
|
1664
2067
|
|
|
@@ -1740,11 +2143,11 @@ def TimeColumn(
|
|
|
1740
2143
|
|
|
1741
2144
|
Parameters
|
|
1742
2145
|
----------
|
|
1743
|
-
label: str or None
|
|
2146
|
+
label : str or None
|
|
1744
2147
|
The label shown at the top of the column. If this is ``None``
|
|
1745
2148
|
(default), the column name is used.
|
|
1746
2149
|
|
|
1747
|
-
width: "small", "medium", "large", int, or None
|
|
2150
|
+
width : "small", "medium", "large", int, or None
|
|
1748
2151
|
The display width of the column. If this is ``None`` (default), the
|
|
1749
2152
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
1750
2153
|
one of the following:
|
|
@@ -1754,7 +2157,11 @@ def TimeColumn(
|
|
|
1754
2157
|
- ``"large"``: 400px wide
|
|
1755
2158
|
- An integer specifying the width in pixels
|
|
1756
2159
|
|
|
1757
|
-
|
|
2160
|
+
If the total width of all columns is less than the width of the
|
|
2161
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
2162
|
+
columns.
|
|
2163
|
+
|
|
2164
|
+
help : str or None
|
|
1758
2165
|
A tooltip that gets displayed when hovering over the column label. If
|
|
1759
2166
|
this is ``None`` (default), no tooltip is displayed.
|
|
1760
2167
|
|
|
@@ -1762,31 +2169,31 @@ def TimeColumn(
|
|
|
1762
2169
|
the Markdown directives described in the ``body`` parameter of
|
|
1763
2170
|
``st.markdown``.
|
|
1764
2171
|
|
|
1765
|
-
disabled: bool or None
|
|
2172
|
+
disabled : bool or None
|
|
1766
2173
|
Whether editing should be disabled for this column. If this is ``None``
|
|
1767
2174
|
(default), Streamlit will enable editing wherever possible.
|
|
1768
2175
|
|
|
1769
2176
|
If a column has mixed types, it may become uneditable regardless of
|
|
1770
2177
|
``disabled``.
|
|
1771
2178
|
|
|
1772
|
-
required: bool or None
|
|
2179
|
+
required : bool or None
|
|
1773
2180
|
Whether edited cells in the column need to have a value. If this is
|
|
1774
2181
|
``False`` (default), the user can submit empty values for this column.
|
|
1775
2182
|
If this is ``True``, an edited cell in this column can only be
|
|
1776
2183
|
submitted if its value is not ``None``, and a new row will only be
|
|
1777
2184
|
submitted after the user fills in this column.
|
|
1778
2185
|
|
|
1779
|
-
pinned: bool or None
|
|
2186
|
+
pinned : bool or None
|
|
1780
2187
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
1781
2188
|
left side no matter where the user scrolls. If this is ``None``
|
|
1782
2189
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
1783
2190
|
columns are not pinned.
|
|
1784
2191
|
|
|
1785
|
-
default: datetime.time or None
|
|
2192
|
+
default : datetime.time or None
|
|
1786
2193
|
Specifies the default value in this column when a new row is added by
|
|
1787
2194
|
the user. This defaults to ``None``.
|
|
1788
2195
|
|
|
1789
|
-
format: str, "localized", "iso8601", or None
|
|
2196
|
+
format : str, "localized", "iso8601", or None
|
|
1790
2197
|
A format string controlling how times are displayed.
|
|
1791
2198
|
This can be one of the following values:
|
|
1792
2199
|
|
|
@@ -1804,15 +2211,15 @@ def TimeColumn(
|
|
|
1804
2211
|
formatting from ``pandas.Styler``. The formatting does not impact the
|
|
1805
2212
|
return value when used in ``st.data_editor``.
|
|
1806
2213
|
|
|
1807
|
-
min_value: datetime.time or None
|
|
2214
|
+
min_value : datetime.time or None
|
|
1808
2215
|
The minimum time that can be entered. If this is ``None`` (default),
|
|
1809
2216
|
there will be no minimum.
|
|
1810
2217
|
|
|
1811
|
-
max_value: datetime.time or None
|
|
2218
|
+
max_value : datetime.time or None
|
|
1812
2219
|
The maximum time that can be entered. If this is ``None`` (default),
|
|
1813
2220
|
there will be no maximum.
|
|
1814
2221
|
|
|
1815
|
-
step: int, float, datetime.timedelta, or None
|
|
2222
|
+
step : int, float, datetime.timedelta, or None
|
|
1816
2223
|
The stepping interval in seconds. If this is ``None`` (default), the
|
|
1817
2224
|
step will be 1 second.
|
|
1818
2225
|
|
|
@@ -1893,11 +2300,11 @@ def DateColumn(
|
|
|
1893
2300
|
|
|
1894
2301
|
Parameters
|
|
1895
2302
|
----------
|
|
1896
|
-
label: str or None
|
|
2303
|
+
label : str or None
|
|
1897
2304
|
The label shown at the top of the column. If this is ``None``
|
|
1898
2305
|
(default), the column name is used.
|
|
1899
2306
|
|
|
1900
|
-
width: "small", "medium", "large", int, or None
|
|
2307
|
+
width : "small", "medium", "large", int, or None
|
|
1901
2308
|
The display width of the column. If this is ``None`` (default), the
|
|
1902
2309
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
1903
2310
|
one of the following:
|
|
@@ -1907,7 +2314,11 @@ def DateColumn(
|
|
|
1907
2314
|
- ``"large"``: 400px wide
|
|
1908
2315
|
- An integer specifying the width in pixels
|
|
1909
2316
|
|
|
1910
|
-
|
|
2317
|
+
If the total width of all columns is less than the width of the
|
|
2318
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
2319
|
+
columns.
|
|
2320
|
+
|
|
2321
|
+
help : str or None
|
|
1911
2322
|
A tooltip that gets displayed when hovering over the column label. If
|
|
1912
2323
|
this is ``None`` (default), no tooltip is displayed.
|
|
1913
2324
|
|
|
@@ -1915,31 +2326,31 @@ def DateColumn(
|
|
|
1915
2326
|
the Markdown directives described in the ``body`` parameter of
|
|
1916
2327
|
``st.markdown``.
|
|
1917
2328
|
|
|
1918
|
-
disabled: bool or None
|
|
2329
|
+
disabled : bool or None
|
|
1919
2330
|
Whether editing should be disabled for this column. If this is ``None``
|
|
1920
2331
|
(default), Streamlit will enable editing wherever possible.
|
|
1921
2332
|
|
|
1922
2333
|
If a column has mixed types, it may become uneditable regardless of
|
|
1923
2334
|
``disabled``.
|
|
1924
2335
|
|
|
1925
|
-
required: bool or None
|
|
2336
|
+
required : bool or None
|
|
1926
2337
|
Whether edited cells in the column need to have a value. If this is
|
|
1927
2338
|
``False`` (default), the user can submit empty values for this column.
|
|
1928
2339
|
If this is ``True``, an edited cell in this column can only be
|
|
1929
2340
|
submitted if its value is not ``None``, and a new row will only be
|
|
1930
2341
|
submitted after the user fills in this column.
|
|
1931
2342
|
|
|
1932
|
-
pinned: bool or None
|
|
2343
|
+
pinned : bool or None
|
|
1933
2344
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
1934
2345
|
left side no matter where the user scrolls. If this is ``None``
|
|
1935
2346
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
1936
2347
|
columns are not pinned.
|
|
1937
2348
|
|
|
1938
|
-
default: datetime.date or None
|
|
2349
|
+
default : datetime.date or None
|
|
1939
2350
|
Specifies the default value in this column when a new row is added by
|
|
1940
2351
|
the user. This defaults to ``None``.
|
|
1941
2352
|
|
|
1942
|
-
format: str, "localized", "distance", "iso8601", or None
|
|
2353
|
+
format : str, "localized", "distance", "iso8601", or None
|
|
1943
2354
|
A format string controlling how dates are displayed.
|
|
1944
2355
|
This can be one of the following values:
|
|
1945
2356
|
|
|
@@ -1959,15 +2370,15 @@ def DateColumn(
|
|
|
1959
2370
|
formatting from ``pandas.Styler``. The formatting does not impact the
|
|
1960
2371
|
return value when used in ``st.data_editor``.
|
|
1961
2372
|
|
|
1962
|
-
min_value: datetime.date or None
|
|
2373
|
+
min_value : datetime.date or None
|
|
1963
2374
|
The minimum date that can be entered. If this is ``None`` (default),
|
|
1964
2375
|
there will be no minimum.
|
|
1965
2376
|
|
|
1966
|
-
max_value: datetime.date or None
|
|
2377
|
+
max_value : datetime.date or None
|
|
1967
2378
|
The maximum date that can be entered. If this is ``None`` (default),
|
|
1968
2379
|
there will be no maximum.
|
|
1969
2380
|
|
|
1970
|
-
step: int or None
|
|
2381
|
+
step : int or None
|
|
1971
2382
|
The stepping interval in days. If this is ``None`` (default), the step
|
|
1972
2383
|
will be 1 day.
|
|
1973
2384
|
|
|
@@ -2044,11 +2455,11 @@ def ProgressColumn(
|
|
|
2044
2455
|
|
|
2045
2456
|
Parameters
|
|
2046
2457
|
----------
|
|
2047
|
-
label: str or None
|
|
2458
|
+
label : str or None
|
|
2048
2459
|
The label shown at the top of the column. If this is ``None``
|
|
2049
2460
|
(default), the column name is used.
|
|
2050
2461
|
|
|
2051
|
-
width: "small", "medium", "large", int, or None
|
|
2462
|
+
width : "small", "medium", "large", int, or None
|
|
2052
2463
|
The display width of the column. If this is ``None`` (default), the
|
|
2053
2464
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
2054
2465
|
one of the following:
|
|
@@ -2058,7 +2469,11 @@ def ProgressColumn(
|
|
|
2058
2469
|
- ``"large"``: 400px wide
|
|
2059
2470
|
- An integer specifying the width in pixels
|
|
2060
2471
|
|
|
2061
|
-
|
|
2472
|
+
If the total width of all columns is less than the width of the
|
|
2473
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
2474
|
+
columns.
|
|
2475
|
+
|
|
2476
|
+
help : str or None
|
|
2062
2477
|
A tooltip that gets displayed when hovering over the column label. If
|
|
2063
2478
|
this is ``None`` (default), no tooltip is displayed.
|
|
2064
2479
|
|
|
@@ -2066,7 +2481,7 @@ def ProgressColumn(
|
|
|
2066
2481
|
the Markdown directives described in the ``body`` parameter of
|
|
2067
2482
|
``st.markdown``.
|
|
2068
2483
|
|
|
2069
|
-
format: str, "plain", "localized", "percent", "dollar", "euro", "yen", "accounting", "compact", "scientific", "engineering", or None
|
|
2484
|
+
format : str, "plain", "localized", "percent", "dollar", "euro", "yen", "accounting", "compact", "scientific", "engineering", or None
|
|
2070
2485
|
A format string controlling how the numbers are displayed.
|
|
2071
2486
|
This can be one of the following values:
|
|
2072
2487
|
|
|
@@ -2093,21 +2508,21 @@ def ProgressColumn(
|
|
|
2093
2508
|
number formatting from ``pandas.Styler``. The number formatting does
|
|
2094
2509
|
not impact the return value when used in ``st.data_editor``.
|
|
2095
2510
|
|
|
2096
|
-
pinned: bool or None
|
|
2511
|
+
pinned : bool or None
|
|
2097
2512
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
2098
2513
|
left side no matter where the user scrolls. If this is ``None``
|
|
2099
2514
|
(default), Streamlit will decide: index columns are pinned, and data
|
|
2100
2515
|
columns are not pinned.
|
|
2101
2516
|
|
|
2102
|
-
min_value: int, float, or None
|
|
2517
|
+
min_value : int, float, or None
|
|
2103
2518
|
The minimum value of the progress bar. If this is ``None`` (default),
|
|
2104
2519
|
the minimum will be 0.
|
|
2105
2520
|
|
|
2106
|
-
max_value: int, float, or None
|
|
2521
|
+
max_value : int, float, or None
|
|
2107
2522
|
The maximum value of the progress bar. If this is ``None`` (default),
|
|
2108
2523
|
the maximum will be 100 for integer values and 1.0 for float values.
|
|
2109
2524
|
|
|
2110
|
-
step: int, float, or None
|
|
2525
|
+
step : int, float, or None
|
|
2111
2526
|
The precision of numbers. If this is ``None`` (default), integer columns
|
|
2112
2527
|
will have a step of 1 and float columns will have a step of 0.01.
|
|
2113
2528
|
Setting ``step`` for float columns will ensure a consistent number of
|
|
@@ -2174,11 +2589,11 @@ def JsonColumn(
|
|
|
2174
2589
|
|
|
2175
2590
|
Parameters
|
|
2176
2591
|
----------
|
|
2177
|
-
label: str or None
|
|
2592
|
+
label : str or None
|
|
2178
2593
|
The label shown at the top of the column. If this is ``None``
|
|
2179
2594
|
(default), the column name is used.
|
|
2180
2595
|
|
|
2181
|
-
width: "small", "medium", "large", int, or None
|
|
2596
|
+
width : "small", "medium", "large", int, or None
|
|
2182
2597
|
The display width of the column. If this is ``None`` (default), the
|
|
2183
2598
|
column will be sized to fit the cell contents. Otherwise, this can be
|
|
2184
2599
|
one of the following:
|
|
@@ -2188,7 +2603,11 @@ def JsonColumn(
|
|
|
2188
2603
|
- ``"large"``: 400px wide
|
|
2189
2604
|
- An integer specifying the width in pixels
|
|
2190
2605
|
|
|
2191
|
-
|
|
2606
|
+
If the total width of all columns is less than the width of the
|
|
2607
|
+
dataframe, the remaining space will be distributed evenly among all
|
|
2608
|
+
columns.
|
|
2609
|
+
|
|
2610
|
+
help : str or None
|
|
2192
2611
|
A tooltip that gets displayed when hovering over the column label. If
|
|
2193
2612
|
this is ``None`` (default), no tooltip is displayed.
|
|
2194
2613
|
|
|
@@ -2196,7 +2615,7 @@ def JsonColumn(
|
|
|
2196
2615
|
the Markdown directives described in the ``body`` parameter of
|
|
2197
2616
|
``st.markdown``.
|
|
2198
2617
|
|
|
2199
|
-
pinned: bool or None
|
|
2618
|
+
pinned : bool or None
|
|
2200
2619
|
Whether the column is pinned. A pinned column will stay visible on the
|
|
2201
2620
|
left side no matter where the user scrolls. If this is ``None``
|
|
2202
2621
|
(default), Streamlit will decide: index columns are pinned, and data
|