streamlit-nightly 1.45.2.dev20250528__py3-none-any.whl → 1.45.2.dev20250531__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/config.py +18 -0
- streamlit/delta_generator.py +10 -14
- streamlit/elements/doc_string.py +7 -15
- streamlit/elements/form.py +14 -0
- streamlit/elements/json.py +7 -6
- streamlit/elements/layouts.py +21 -3
- streamlit/elements/lib/layout_utils.py +24 -0
- streamlit/elements/lib/mutable_status_container.py +9 -0
- streamlit/elements/markdown.py +33 -3
- streamlit/elements/progress.py +3 -12
- streamlit/elements/widgets/audio_input.py +3 -10
- streamlit/elements/widgets/camera_input.py +5 -9
- streamlit/elements/widgets/chat.py +9 -12
- streamlit/elements/widgets/data_editor.py +6 -3
- streamlit/elements/widgets/file_uploader.py +9 -9
- streamlit/elements/widgets/number_input.py +11 -12
- streamlit/elements/widgets/select_slider.py +3 -10
- streamlit/elements/widgets/selectbox.py +9 -12
- streamlit/elements/widgets/slider.py +3 -9
- streamlit/elements/widgets/text_widgets.py +13 -22
- streamlit/elements/widgets/time_widgets.py +13 -22
- streamlit/hello/hello.py +1 -0
- streamlit/hello/streamlit_app.py +27 -25
- streamlit/proto/AudioInput_pb2.py +3 -4
- streamlit/proto/AudioInput_pb2.pyi +2 -7
- streamlit/proto/Block_pb2.py +27 -27
- streamlit/proto/Block_pb2.pyi +3 -17
- streamlit/proto/CameraInput_pb2.py +3 -4
- streamlit/proto/CameraInput_pb2.pyi +2 -8
- streamlit/proto/ChatInput_pb2.py +7 -8
- streamlit/proto/ChatInput_pb2.pyi +1 -10
- streamlit/proto/Code_pb2.py +3 -4
- streamlit/proto/DateInput_pb2.py +3 -4
- streamlit/proto/DateInput_pb2.pyi +2 -8
- streamlit/proto/DocString_pb2.py +5 -6
- streamlit/proto/DocString_pb2.pyi +1 -9
- streamlit/proto/FileUploader_pb2.py +3 -4
- streamlit/proto/FileUploader_pb2.pyi +2 -8
- streamlit/proto/Json_pb2.py +3 -4
- streamlit/proto/Json_pb2.pyi +2 -9
- streamlit/proto/NewSession_pb2.py +16 -16
- streamlit/proto/NewSession_pb2.pyi +7 -2
- streamlit/proto/NumberInput_pb2.py +5 -6
- streamlit/proto/NumberInput_pb2.pyi +2 -9
- streamlit/proto/Progress_pb2.py +3 -4
- streamlit/proto/Progress_pb2.pyi +1 -7
- streamlit/proto/Selectbox_pb2.py +3 -4
- streamlit/proto/Selectbox_pb2.pyi +2 -9
- streamlit/proto/Slider_pb2.py +7 -8
- streamlit/proto/Slider_pb2.pyi +2 -8
- streamlit/proto/TextArea_pb2.py +3 -4
- streamlit/proto/TextArea_pb2.pyi +2 -9
- streamlit/proto/TextInput_pb2.py +5 -6
- streamlit/proto/TextInput_pb2.pyi +2 -9
- streamlit/proto/TimeInput_pb2.py +3 -4
- streamlit/proto/TimeInput_pb2.pyi +2 -9
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +1240 -0
- streamlit/static/static/js/{ErrorOutline.esm.CtshIbC5.js → ErrorOutline.esm.D5NgCh5m.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.A0XrMp_A.js → FileDownload.esm.NuObx1Tl.js} +1 -1
- streamlit/static/static/js/{FileHelper.BkYmOfR4.js → FileHelper.BH7o4_P9.js} +5 -5
- streamlit/static/static/js/{FormClearHelper.DvUrjO5s.js → FormClearHelper.BAxB8JFY.js} +1 -1
- streamlit/static/static/js/{Hooks.Dw0PPeMp.js → Hooks.Bjt8oBOT.js} +1 -1
- streamlit/static/static/js/{InputInstructions.BwkpOG-3.js → InputInstructions.BZZLp6t9.js} +1 -1
- streamlit/static/static/js/{ProgressBar.Po8toa5U.js → ProgressBar.BwRgGfI0.js} +2 -2
- streamlit/static/static/js/{RenderInPortalIfExists.DG7izwhP.js → RenderInPortalIfExists.C_c286r8.js} +1 -1
- streamlit/static/static/js/{Toolbar.zoRxypF9.js → Toolbar.5tXjF_eX.js} +1 -1
- streamlit/static/static/js/{base-input.3hmq5vR4.js → base-input.wfBDFTlB.js} +1 -1
- streamlit/static/static/js/{checkbox.DHVebTBP.js → checkbox.D1GhNngU.js} +1 -1
- streamlit/static/static/js/{createSuper.CCzF882j.js → createSuper.CudEEVs2.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.CRIS0V5u.js → data-grid-overlay-editor.DUTI_Rbg.js} +1 -1
- streamlit/static/static/js/{downloader.DOuJ7F43.js → downloader.BwLpAoXN.js} +1 -1
- streamlit/static/static/js/{es6.BojNhy97.js → es6.B_HLnUb9.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.CmN7IDO7.js → iframeResizer.contentWindow.BNcjOcan.js} +1 -1
- streamlit/static/static/js/{index.VVmp3qV7.js → index.3WJoJFGb.js} +1 -1
- streamlit/static/static/js/{index.CTVSiPCo.js → index.B0h616Th.js} +1 -1
- streamlit/static/static/js/{index.CLFnBokZ.js → index.B0paBg5x.js} +1 -1
- streamlit/static/static/js/index.B3vWaIrN.js +1 -0
- streamlit/static/static/js/{index.CdgLDqMc.js → index.B4PbMsBe.js} +1 -1
- streamlit/static/static/js/{index.BV-8GugV.js → index.BGKVW2u9.js} +1 -1
- streamlit/static/static/js/index.BJQPxOFd.js +12 -0
- streamlit/static/static/js/{index.B3Y99Usz.js → index.BOHEcsVb.js} +1 -1
- streamlit/static/static/js/{index.CZ6f-p0K.js → index.BPGAPI9w.js} +1 -1
- streamlit/static/static/js/{index.BXfm7UZe.js → index.Bj6uLiaA.js} +1 -1
- streamlit/static/static/js/{index.BvWDoWjf.js → index.BkvVxUIW.js} +1 -1
- streamlit/static/static/js/{index.kWUcv9pK.js → index.Bs0m0eUy.js} +1 -1
- streamlit/static/static/js/{index.YePOPnW6.js → index.BtpsTdHN.js} +176 -173
- streamlit/static/static/js/index.C1GNiWbH.js +1 -0
- streamlit/static/static/js/{index.Ih0EXMso.js → index.CL0UH4WF.js} +1 -1
- streamlit/static/static/js/{index.DkNaEiLi.js → index.CXP5ffxh.js} +1 -1
- streamlit/static/static/js/{index.Cpz3pp0B.js → index.Ca-9xoC2.js} +1 -1
- streamlit/static/static/js/{index.BgmEuudT.js → index.Cdd7Ri21.js} +1 -1
- streamlit/static/static/js/index.Cf8KcH2X.js +1 -0
- streamlit/static/static/js/{index.CWweAMBx.js → index.CfzaRR6P.js} +1 -1
- streamlit/static/static/js/{index.muQ-sA7D.js → index.CjRwuAdg.js} +1 -1
- streamlit/static/static/js/{index.BEfxU01i.js → index.CkOUlPYT.js} +1 -1
- streamlit/static/static/js/{index.BsiojTxz.js → index.CxtkoiKl.js} +1 -1
- streamlit/static/static/js/index.D3wYqvI6.js +1 -0
- streamlit/static/static/js/index.D8i27llu.js +3 -0
- streamlit/static/static/js/{index.BMWx_YQD.js → index.DA7wmIe4.js} +1 -1
- streamlit/static/static/js/index.DIG9Mo9J.js +1 -0
- streamlit/static/static/js/index.DNR4wKJg.js +1 -0
- streamlit/static/static/js/{index.DcLQo3NB.js → index.DNS8a-dx.js} +20 -20
- streamlit/static/static/js/{index.YtwVjbe-.js → index.NveskZ7j.js} +1 -1
- streamlit/static/static/js/{index.BfcdLS9y.js → index.PR2mcvVR.js} +1 -1
- streamlit/static/static/js/{index.CzMgwzgb.js → index.df4uuSoD.js} +1 -1
- streamlit/static/static/js/{index.3HscCA0Q.js → index.flyQEkeT.js} +1 -1
- streamlit/static/static/js/{index.R5J-UXhx.js → index.iF9jUtwl.js} +1 -1
- streamlit/static/static/js/{index.p5qVS5RU.js → index.jyqBAhvH.js} +1 -1
- streamlit/static/static/js/{index.HdiDLe37.js → index.sYLAHlH0.js} +1 -1
- streamlit/static/static/js/{index.whcmqOYZ.js → index.zq3LdRhj.js} +1 -1
- streamlit/static/static/js/{input.C95vVzrH.js → input.CtZjQ6Pv.js} +1 -1
- streamlit/static/static/js/{memory.lfILky3m.js → memory.Ddl3R0up.js} +1 -1
- streamlit/static/static/js/{mergeWith.CdpKbzWl.js → mergeWith.D-TqDY0-.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.D2TjUrKf.js → number-overlay-editor.Dndf05Hx.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.DQV58bYB.js → possibleConstructorReturn.DNEY6J9G.js} +1 -1
- streamlit/static/static/js/{sandbox.R1dhBCnm.js → sandbox.B_XDPkfx.js} +1 -1
- streamlit/static/static/js/{textarea.t5D4QCw3.js → textarea.BZ9lTMhV.js} +1 -1
- streamlit/static/static/js/{timepicker.BI9iPIxz.js → timepicker.D9UUwpRT.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.COyXrPhy.js → toConsumableArray.DNJjbOUS.js} +1 -1
- streamlit/static/static/js/{uniqueId.CaWObuU_.js → uniqueId.psBJ_tSg.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.Wd2TSACf.js → useBasicWidgetState.CTpx4w-3.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.CUFXty-S.js → useOnInputChange.WKTDSC4O.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.wgkD5MeK.js → withFullScreenWrapper.oyWCn2-3.js} +1 -1
- {streamlit_nightly-1.45.2.dev20250528.dist-info → streamlit_nightly-1.45.2.dev20250531.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.45.2.dev20250528.dist-info → streamlit_nightly-1.45.2.dev20250531.dist-info}/RECORD +130 -129
- streamlit/static/static/js/index.B0GUCtHl.js +0 -1
- streamlit/static/static/js/index.B6guKn0h.js +0 -1
- streamlit/static/static/js/index.CPiByGGr.js +0 -3
- streamlit/static/static/js/index.CVxkW_lc.js +0 -12
- streamlit/static/static/js/index.DH2YAEv6.js +0 -1
- streamlit/static/static/js/index.DNlMgaSP.js +0 -1
- streamlit/static/static/js/index.DP7RHJHC.js +0 -1
- streamlit/static/static/js/index.DtpZrdsz.js +0 -1
- {streamlit_nightly-1.45.2.dev20250528.data → streamlit_nightly-1.45.2.dev20250531.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.45.2.dev20250528.dist-info → streamlit_nightly-1.45.2.dev20250531.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.45.2.dev20250528.dist-info → streamlit_nightly-1.45.2.dev20250531.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.45.2.dev20250528.dist-info → streamlit_nightly-1.45.2.dev20250531.dist-info}/top_level.txt +0 -0
streamlit/config.py
CHANGED
@@ -1225,6 +1225,24 @@ _create_theme_options(
|
|
1225
1225
|
""",
|
1226
1226
|
)
|
1227
1227
|
|
1228
|
+
_create_theme_options(
|
1229
|
+
"buttonRadius",
|
1230
|
+
categories=["theme", CustomThemeCategories.SIDEBAR],
|
1231
|
+
description="""
|
1232
|
+
The radius used as basis for the corners of buttons.
|
1233
|
+
|
1234
|
+
This can be one of the following:
|
1235
|
+
- "none"
|
1236
|
+
- "small"
|
1237
|
+
- "medium"
|
1238
|
+
- "large"
|
1239
|
+
- "full"
|
1240
|
+
- ...or the number in pixels or rem. For example, you can use "10px",
|
1241
|
+
"0.5rem", or "2rem". To follow best practices, use rem instead of
|
1242
|
+
pixels when specifying a numeric size.
|
1243
|
+
""",
|
1244
|
+
)
|
1245
|
+
|
1228
1246
|
_create_theme_options(
|
1229
1247
|
"borderColor",
|
1230
1248
|
categories=["theme", CustomThemeCategories.SIDEBAR],
|
streamlit/delta_generator.py
CHANGED
@@ -63,6 +63,10 @@ from streamlit.elements.image import ImageMixin
|
|
63
63
|
from streamlit.elements.json import JsonMixin
|
64
64
|
from streamlit.elements.layouts import LayoutsMixin
|
65
65
|
from streamlit.elements.lib.form_utils import FormData, current_form_id
|
66
|
+
from streamlit.elements.lib.layout_utils import (
|
67
|
+
get_height_config,
|
68
|
+
get_width_config,
|
69
|
+
)
|
66
70
|
from streamlit.elements.map import MapMixin
|
67
71
|
from streamlit.elements.markdown import MarkdownMixin
|
68
72
|
from streamlit.elements.media import MediaMixin
|
@@ -480,22 +484,14 @@ class DeltaGenerator(
|
|
480
484
|
|
481
485
|
if layout_config:
|
482
486
|
if layout_config.height:
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
)
|
487
|
-
elif layout_config.height == "content":
|
488
|
-
msg.delta.new_element.height_config.use_content = True
|
489
|
-
else:
|
490
|
-
msg.delta.new_element.height_config.use_stretch = True
|
487
|
+
msg.delta.new_element.height_config.CopyFrom(
|
488
|
+
get_height_config(layout_config.height)
|
489
|
+
)
|
491
490
|
|
492
491
|
if layout_config.width:
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
msg.delta.new_element.width_config.use_content = True
|
497
|
-
else:
|
498
|
-
msg.delta.new_element.width_config.use_stretch = True
|
492
|
+
msg.delta.new_element.width_config.CopyFrom(
|
493
|
+
get_width_config(layout_config.width)
|
494
|
+
)
|
499
495
|
|
500
496
|
# Only enqueue message and fill in metadata if there's a container.
|
501
497
|
msg_was_enqueued = False
|
streamlit/elements/doc_string.py
CHANGED
@@ -24,10 +24,9 @@ import types
|
|
24
24
|
from typing import TYPE_CHECKING, Any, Final, cast
|
25
25
|
|
26
26
|
import streamlit
|
27
|
-
from streamlit.elements.lib.layout_utils import validate_width
|
27
|
+
from streamlit.elements.lib.layout_utils import LayoutConfig, validate_width
|
28
28
|
from streamlit.proto.DocString_pb2 import DocString as DocStringProto
|
29
29
|
from streamlit.proto.DocString_pb2 import Member as MemberProto
|
30
|
-
from streamlit.proto.WidthConfig_pb2 import WidthConfig
|
31
30
|
from streamlit.runtime.metrics_util import gather_metrics
|
32
31
|
from streamlit.runtime.scriptrunner.script_runner import (
|
33
32
|
__file__ as SCRIPTRUNNER_FILENAME, # noqa: N812
|
@@ -125,9 +124,12 @@ class HelpMixin:
|
|
125
124
|
doc_string_proto = DocStringProto()
|
126
125
|
|
127
126
|
validate_width(width, allow_content=False)
|
128
|
-
|
127
|
+
layout_config = LayoutConfig(width=width)
|
128
|
+
_marshall(doc_string_proto, obj)
|
129
129
|
|
130
|
-
return self.dg._enqueue(
|
130
|
+
return self.dg._enqueue(
|
131
|
+
"doc_string", doc_string_proto, layout_config=layout_config
|
132
|
+
)
|
131
133
|
|
132
134
|
@property
|
133
135
|
def dg(self) -> DeltaGenerator:
|
@@ -135,9 +137,7 @@ class HelpMixin:
|
|
135
137
|
return cast("DeltaGenerator", self)
|
136
138
|
|
137
139
|
|
138
|
-
def _marshall(
|
139
|
-
doc_string_proto: DocStringProto, obj: Any, width: WidthWithoutContent = "stretch"
|
140
|
-
) -> None:
|
140
|
+
def _marshall(doc_string_proto: DocStringProto, obj: Any) -> None:
|
141
141
|
"""Construct a DocString object.
|
142
142
|
|
143
143
|
See DeltaGenerator.help for docs.
|
@@ -159,14 +159,6 @@ def _marshall(
|
|
159
159
|
|
160
160
|
doc_string_proto.members.extend(_get_members(obj))
|
161
161
|
|
162
|
-
# Set width configuration
|
163
|
-
width_config = WidthConfig()
|
164
|
-
if isinstance(width, int):
|
165
|
-
width_config.pixel_width = width
|
166
|
-
else:
|
167
|
-
width_config.use_stretch = True
|
168
|
-
doc_string_proto.width_config.CopyFrom(width_config)
|
169
|
-
|
170
162
|
|
171
163
|
def _get_name(obj: object) -> str | None:
|
172
164
|
# Try to get the fully-qualified name of the object.
|
streamlit/elements/form.py
CHANGED
@@ -17,6 +17,14 @@ import textwrap
|
|
17
17
|
from typing import TYPE_CHECKING, Literal, cast
|
18
18
|
|
19
19
|
from streamlit.elements.lib.form_utils import FormData, current_form_id, is_in_form
|
20
|
+
from streamlit.elements.lib.layout_utils import (
|
21
|
+
Height,
|
22
|
+
Width,
|
23
|
+
get_height_config,
|
24
|
+
get_width_config,
|
25
|
+
validate_height,
|
26
|
+
validate_width,
|
27
|
+
)
|
20
28
|
from streamlit.elements.lib.policies import (
|
21
29
|
check_cache_replay_rules,
|
22
30
|
check_session_state_rules,
|
@@ -67,6 +75,8 @@ class FormMixin:
|
|
67
75
|
*,
|
68
76
|
enter_to_submit: bool = True,
|
69
77
|
border: bool = True,
|
78
|
+
width: Width = "stretch",
|
79
|
+
height: Height = "content",
|
70
80
|
) -> DeltaGenerator:
|
71
81
|
"""Create a form that batches elements together with a "Submit" button.
|
72
82
|
|
@@ -181,6 +191,10 @@ class FormMixin:
|
|
181
191
|
block_proto.form.clear_on_submit = clear_on_submit
|
182
192
|
block_proto.form.enter_to_submit = enter_to_submit
|
183
193
|
block_proto.form.border = border
|
194
|
+
validate_width(width, allow_content=True)
|
195
|
+
block_proto.width_config.CopyFrom(get_width_config(width))
|
196
|
+
validate_height(height, allow_content=True)
|
197
|
+
block_proto.height_config.CopyFrom(get_height_config(height))
|
184
198
|
block_dg = self.dg._block(block_proto)
|
185
199
|
|
186
200
|
# Attach the form's button info to the newly-created block's
|
streamlit/elements/json.py
CHANGED
@@ -19,7 +19,11 @@ import types
|
|
19
19
|
from collections import ChainMap, UserDict
|
20
20
|
from typing import TYPE_CHECKING, Any, cast
|
21
21
|
|
22
|
-
from streamlit.elements.lib.layout_utils import
|
22
|
+
from streamlit.elements.lib.layout_utils import (
|
23
|
+
LayoutConfig,
|
24
|
+
WidthWithoutContent,
|
25
|
+
validate_width,
|
26
|
+
)
|
23
27
|
from streamlit.proto.Json_pb2 import Json as JsonProto
|
24
28
|
from streamlit.runtime.metrics_util import gather_metrics
|
25
29
|
from streamlit.type_util import (
|
@@ -139,12 +143,9 @@ class JsonMixin:
|
|
139
143
|
)
|
140
144
|
|
141
145
|
validate_width(width)
|
142
|
-
|
143
|
-
json_proto.width_config.pixel_width = width
|
144
|
-
else:
|
145
|
-
json_proto.width_config.use_stretch = True
|
146
|
+
layout_config = LayoutConfig(width=width)
|
146
147
|
|
147
|
-
return self.dg._enqueue("json", json_proto)
|
148
|
+
return self.dg._enqueue("json", json_proto, layout_config=layout_config)
|
148
149
|
|
149
150
|
@property
|
150
151
|
def dg(self) -> DeltaGenerator:
|
streamlit/elements/layouts.py
CHANGED
@@ -20,6 +20,11 @@ from typing import TYPE_CHECKING, Literal, Union, cast
|
|
20
20
|
from typing_extensions import TypeAlias
|
21
21
|
|
22
22
|
from streamlit.delta_generator_singletons import get_dg_singleton_instance
|
23
|
+
from streamlit.elements.lib.layout_utils import (
|
24
|
+
WidthWithoutContent,
|
25
|
+
get_width_config,
|
26
|
+
validate_width,
|
27
|
+
)
|
23
28
|
from streamlit.elements.lib.utils import Key, compute_and_register_element_id, to_key
|
24
29
|
from streamlit.errors import (
|
25
30
|
StreamlitAPIException,
|
@@ -160,7 +165,9 @@ class LayoutsMixin:
|
|
160
165
|
|
161
166
|
height_config = HeightConfig()
|
162
167
|
height_config.pixel_height = height
|
163
|
-
|
168
|
+
# Use block-level height_config instead of flex_container
|
169
|
+
block_proto.height_config.CopyFrom(height_config)
|
170
|
+
|
164
171
|
if border is None:
|
165
172
|
# If border is None, we activated the
|
166
173
|
# border as default setting for scrolling
|
@@ -398,7 +405,12 @@ class LayoutsMixin:
|
|
398
405
|
return [row._block(column_proto(w / total_weight)) for w in weights]
|
399
406
|
|
400
407
|
@gather_metrics("tabs")
|
401
|
-
def tabs(
|
408
|
+
def tabs(
|
409
|
+
self,
|
410
|
+
tabs: Sequence[str],
|
411
|
+
*,
|
412
|
+
width: WidthWithoutContent = "stretch",
|
413
|
+
) -> Sequence[DeltaGenerator]:
|
402
414
|
r"""Insert containers separated into tabs.
|
403
415
|
|
404
416
|
Inserts a number of multi-element containers as tabs.
|
@@ -499,6 +511,8 @@ class LayoutsMixin:
|
|
499
511
|
|
500
512
|
block_proto = BlockProto()
|
501
513
|
block_proto.tab_container.SetInParent()
|
514
|
+
validate_width(width)
|
515
|
+
block_proto.width_config.CopyFrom(get_width_config(width))
|
502
516
|
tab_container = self.dg._block(block_proto)
|
503
517
|
return tuple(tab_container._block(tab_proto(tab_label)) for tab_label in tabs)
|
504
518
|
|
@@ -509,6 +523,7 @@ class LayoutsMixin:
|
|
509
523
|
expanded: bool = False,
|
510
524
|
*,
|
511
525
|
icon: str | None = None,
|
526
|
+
width: WidthWithoutContent = "stretch",
|
512
527
|
) -> DeltaGenerator:
|
513
528
|
r"""Insert a multi-element container that can be expanded/collapsed.
|
514
529
|
|
@@ -611,6 +626,8 @@ class LayoutsMixin:
|
|
611
626
|
block_proto = BlockProto()
|
612
627
|
block_proto.allow_empty = False
|
613
628
|
block_proto.expandable.CopyFrom(expandable_proto)
|
629
|
+
validate_width(width)
|
630
|
+
block_proto.width_config.CopyFrom(get_width_config(width))
|
614
631
|
|
615
632
|
return self.dg._block(block_proto=block_proto)
|
616
633
|
|
@@ -761,6 +778,7 @@ class LayoutsMixin:
|
|
761
778
|
*,
|
762
779
|
expanded: bool = False,
|
763
780
|
state: Literal["running", "complete", "error"] = "running",
|
781
|
+
width: WidthWithoutContent = "stretch",
|
764
782
|
) -> StatusContainer:
|
765
783
|
r"""Insert a status container to display output from long-running tasks.
|
766
784
|
|
@@ -863,7 +881,7 @@ class LayoutsMixin:
|
|
863
881
|
|
864
882
|
"""
|
865
883
|
return get_dg_singleton_instance().status_container_cls._create(
|
866
|
-
self.dg, label, expanded=expanded, state=state
|
884
|
+
self.dg, label, expanded=expanded, state=state, width=width
|
867
885
|
)
|
868
886
|
|
869
887
|
def _dialog(
|
@@ -19,6 +19,8 @@ from typing import Literal, Union
|
|
19
19
|
from typing_extensions import TypeAlias
|
20
20
|
|
21
21
|
from streamlit.errors import StreamlitInvalidHeightError, StreamlitInvalidWidthError
|
22
|
+
from streamlit.proto.HeightConfig_pb2 import HeightConfig
|
23
|
+
from streamlit.proto.WidthConfig_pb2 import WidthConfig
|
22
24
|
|
23
25
|
WidthWithoutContent: TypeAlias = Union[int, Literal["stretch"]]
|
24
26
|
Width: TypeAlias = Union[int, Literal["stretch", "content"]]
|
@@ -89,3 +91,25 @@ def validate_height(height: Height, allow_content: bool = False) -> None:
|
|
89
91
|
|
90
92
|
elif height <= 0:
|
91
93
|
raise StreamlitInvalidHeightError(height, allow_content)
|
94
|
+
|
95
|
+
|
96
|
+
def get_width_config(width: Width) -> WidthConfig:
|
97
|
+
width_config = WidthConfig()
|
98
|
+
if isinstance(width, int):
|
99
|
+
width_config.pixel_width = width
|
100
|
+
elif width == "content":
|
101
|
+
width_config.use_content = True
|
102
|
+
else:
|
103
|
+
width_config.use_stretch = True
|
104
|
+
return width_config
|
105
|
+
|
106
|
+
|
107
|
+
def get_height_config(height: Height) -> HeightConfig:
|
108
|
+
height_config = HeightConfig()
|
109
|
+
if isinstance(height, int):
|
110
|
+
height_config.pixel_height = height
|
111
|
+
elif height == "content":
|
112
|
+
height_config.use_content = True
|
113
|
+
else:
|
114
|
+
height_config.use_stretch = True
|
115
|
+
return height_config
|
@@ -20,6 +20,11 @@ from typing import TYPE_CHECKING, Literal, cast
|
|
20
20
|
from typing_extensions import Self, TypeAlias
|
21
21
|
|
22
22
|
from streamlit.delta_generator import DeltaGenerator
|
23
|
+
from streamlit.elements.lib.layout_utils import (
|
24
|
+
WidthWithoutContent,
|
25
|
+
get_width_config,
|
26
|
+
validate_width,
|
27
|
+
)
|
23
28
|
from streamlit.errors import StreamlitAPIException
|
24
29
|
from streamlit.proto.Block_pb2 import Block as BlockProto
|
25
30
|
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
@@ -40,6 +45,7 @@ class StatusContainer(DeltaGenerator):
|
|
40
45
|
label: str,
|
41
46
|
expanded: bool = False,
|
42
47
|
state: States = "running",
|
48
|
+
width: WidthWithoutContent = "stretch",
|
43
49
|
) -> StatusContainer:
|
44
50
|
expandable_proto = BlockProto.Expandable()
|
45
51
|
expandable_proto.expanded = expanded
|
@@ -60,6 +66,9 @@ class StatusContainer(DeltaGenerator):
|
|
60
66
|
block_proto.allow_empty = True
|
61
67
|
block_proto.expandable.CopyFrom(expandable_proto)
|
62
68
|
|
69
|
+
validate_width(width=width)
|
70
|
+
block_proto.width_config.CopyFrom(get_width_config(width))
|
71
|
+
|
63
72
|
delta_path: list[int] = (
|
64
73
|
parent._active_dg._cursor.delta_path if parent._active_dg._cursor else []
|
65
74
|
)
|
streamlit/elements/markdown.py
CHANGED
@@ -16,6 +16,12 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
from typing import TYPE_CHECKING, Final, Literal, cast
|
18
18
|
|
19
|
+
from streamlit.elements.lib.layout_utils import (
|
20
|
+
LayoutConfig,
|
21
|
+
Width,
|
22
|
+
WidthWithoutContent,
|
23
|
+
validate_width,
|
24
|
+
)
|
19
25
|
from streamlit.proto.Markdown_pb2 import Markdown as MarkdownProto
|
20
26
|
from streamlit.runtime.metrics_util import gather_metrics
|
21
27
|
from streamlit.string_util import clean_text, validate_icon_or_emoji
|
@@ -212,6 +218,7 @@ class MarkdownMixin:
|
|
212
218
|
body: SupportsStr | sympy.Expr,
|
213
219
|
*, # keyword-only arguments:
|
214
220
|
help: str | None = None,
|
221
|
+
width: Width = "stretch",
|
215
222
|
) -> DeltaGenerator:
|
216
223
|
# This docstring needs to be "raw" because of the backslashes in the
|
217
224
|
# example below.
|
@@ -235,6 +242,12 @@ class MarkdownMixin:
|
|
235
242
|
including the Markdown directives described in the ``body``
|
236
243
|
parameter of ``st.markdown``.
|
237
244
|
|
245
|
+
width : int or "stretch" or "content"
|
246
|
+
The width of the LaTeX expression. If "stretch" (default), the
|
247
|
+
expression will take up the full width of the container. If "content",
|
248
|
+
the expression will take up only as much width as needed. If an integer,
|
249
|
+
the width will be set to that number of pixels.
|
250
|
+
|
238
251
|
Example
|
239
252
|
-------
|
240
253
|
>>> import streamlit as st
|
@@ -246,6 +259,7 @@ class MarkdownMixin:
|
|
246
259
|
... ''')
|
247
260
|
|
248
261
|
"""
|
262
|
+
|
249
263
|
if is_sympy_expression(body):
|
250
264
|
import sympy
|
251
265
|
|
@@ -256,12 +270,23 @@ class MarkdownMixin:
|
|
256
270
|
latex_proto.element_type = MarkdownProto.Type.LATEX
|
257
271
|
if help:
|
258
272
|
latex_proto.help = help
|
259
|
-
|
273
|
+
|
274
|
+
validate_width(width, allow_content=True)
|
275
|
+
layout_config = LayoutConfig(width=width)
|
276
|
+
|
277
|
+
return self.dg._enqueue("markdown", latex_proto, layout_config=layout_config)
|
260
278
|
|
261
279
|
@gather_metrics("divider")
|
262
|
-
def divider(self) -> DeltaGenerator:
|
280
|
+
def divider(self, *, width: WidthWithoutContent = "stretch") -> DeltaGenerator:
|
263
281
|
"""Display a horizontal rule.
|
264
282
|
|
283
|
+
Parameters
|
284
|
+
----------
|
285
|
+
width : int or "stretch"
|
286
|
+
The width of the divider. If "stretch" (default), the divider will
|
287
|
+
take up the full width of the container. If an integer, the width
|
288
|
+
will be set to that number of pixels.
|
289
|
+
|
265
290
|
.. note::
|
266
291
|
You can achieve the same effect with st.write("---") or
|
267
292
|
even just "---" in your script (via magic).
|
@@ -273,10 +298,15 @@ class MarkdownMixin:
|
|
273
298
|
>>> st.divider()
|
274
299
|
|
275
300
|
"""
|
301
|
+
|
276
302
|
divider_proto = MarkdownProto()
|
277
303
|
divider_proto.body = MARKDOWN_HORIZONTAL_RULE_EXPRESSION
|
278
304
|
divider_proto.element_type = MarkdownProto.Type.DIVIDER
|
279
|
-
|
305
|
+
|
306
|
+
validate_width(width, allow_content=False)
|
307
|
+
layout_config = LayoutConfig(width=width)
|
308
|
+
|
309
|
+
return self.dg._enqueue("markdown", divider_proto, layout_config=layout_config)
|
280
310
|
|
281
311
|
@gather_metrics("badge")
|
282
312
|
def badge(
|
streamlit/elements/progress.py
CHANGED
@@ -19,10 +19,9 @@ from typing import TYPE_CHECKING, Union, cast
|
|
19
19
|
|
20
20
|
from typing_extensions import TypeAlias
|
21
21
|
|
22
|
-
from streamlit.elements.lib.layout_utils import validate_width
|
22
|
+
from streamlit.elements.lib.layout_utils import LayoutConfig, validate_width
|
23
23
|
from streamlit.errors import StreamlitAPIException
|
24
24
|
from streamlit.proto.Progress_pb2 import Progress as ProgressProto
|
25
|
-
from streamlit.proto.WidthConfig_pb2 import WidthConfig
|
26
25
|
from streamlit.string_util import clean_text
|
27
26
|
|
28
27
|
if TYPE_CHECKING:
|
@@ -158,18 +157,10 @@ class ProgressMixin:
|
|
158
157
|
if text is not None:
|
159
158
|
progress_proto.text = text
|
160
159
|
|
161
|
-
width_config = WidthConfig()
|
162
|
-
|
163
160
|
validate_width(width)
|
161
|
+
layout_config = LayoutConfig(width=width)
|
164
162
|
|
165
|
-
|
166
|
-
width_config.pixel_width = width
|
167
|
-
else:
|
168
|
-
width_config.use_stretch = True
|
169
|
-
|
170
|
-
progress_proto.width_config.CopyFrom(width_config)
|
171
|
-
|
172
|
-
return self.dg._enqueue("progress", progress_proto)
|
163
|
+
return self.dg._enqueue("progress", progress_proto, layout_config=layout_config)
|
173
164
|
|
174
165
|
@property
|
175
166
|
def dg(self) -> DeltaGenerator:
|
@@ -22,7 +22,7 @@ from typing_extensions import TypeAlias
|
|
22
22
|
|
23
23
|
from streamlit.elements.lib.file_uploader_utils import enforce_filename_restriction
|
24
24
|
from streamlit.elements.lib.form_utils import current_form_id
|
25
|
-
from streamlit.elements.lib.layout_utils import validate_width
|
25
|
+
from streamlit.elements.lib.layout_utils import LayoutConfig, validate_width
|
26
26
|
from streamlit.elements.lib.policies import (
|
27
27
|
check_widget_policies,
|
28
28
|
maybe_raise_label_warnings,
|
@@ -38,7 +38,6 @@ from streamlit.elements.widgets.file_uploader import _get_upload_files
|
|
38
38
|
from streamlit.proto.AudioInput_pb2 import AudioInput as AudioInputProto
|
39
39
|
from streamlit.proto.Common_pb2 import FileUploaderState as FileUploaderStateProto
|
40
40
|
from streamlit.proto.Common_pb2 import UploadedFileInfo as UploadedFileInfoProto
|
41
|
-
from streamlit.proto.WidthConfig_pb2 import WidthConfig
|
42
41
|
from streamlit.runtime.metrics_util import gather_metrics
|
43
42
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
44
43
|
from streamlit.runtime.state import (
|
@@ -254,14 +253,8 @@ class AudioInputMixin:
|
|
254
253
|
if label and help is not None:
|
255
254
|
audio_input_proto.help = dedent(help)
|
256
255
|
|
257
|
-
# Set width configuration
|
258
256
|
validate_width(width)
|
259
|
-
|
260
|
-
if isinstance(width, int):
|
261
|
-
width_config.pixel_width = width
|
262
|
-
else:
|
263
|
-
width_config.use_stretch = True
|
264
|
-
audio_input_proto.width_config.CopyFrom(width_config)
|
257
|
+
layout_config = LayoutConfig(width=width)
|
265
258
|
|
266
259
|
serde = AudioInputSerde()
|
267
260
|
|
@@ -276,7 +269,7 @@ class AudioInputMixin:
|
|
276
269
|
value_type="file_uploader_state_value",
|
277
270
|
)
|
278
271
|
|
279
|
-
self.dg._enqueue("audio_input", audio_input_proto)
|
272
|
+
self.dg._enqueue("audio_input", audio_input_proto, layout_config=layout_config)
|
280
273
|
|
281
274
|
if isinstance(audio_input_state.value, DeletedFile):
|
282
275
|
return None
|
@@ -22,7 +22,7 @@ from typing_extensions import TypeAlias
|
|
22
22
|
|
23
23
|
from streamlit.elements.lib.file_uploader_utils import enforce_filename_restriction
|
24
24
|
from streamlit.elements.lib.form_utils import current_form_id
|
25
|
-
from streamlit.elements.lib.layout_utils import validate_width
|
25
|
+
from streamlit.elements.lib.layout_utils import LayoutConfig, validate_width
|
26
26
|
from streamlit.elements.lib.policies import (
|
27
27
|
check_widget_policies,
|
28
28
|
maybe_raise_label_warnings,
|
@@ -38,7 +38,6 @@ from streamlit.elements.widgets.file_uploader import _get_upload_files
|
|
38
38
|
from streamlit.proto.CameraInput_pb2 import CameraInput as CameraInputProto
|
39
39
|
from streamlit.proto.Common_pb2 import FileUploaderState as FileUploaderStateProto
|
40
40
|
from streamlit.proto.Common_pb2 import UploadedFileInfo as UploadedFileInfoProto
|
41
|
-
from streamlit.proto.WidthConfig_pb2 import WidthConfig
|
42
41
|
from streamlit.runtime.metrics_util import gather_metrics
|
43
42
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
44
43
|
from streamlit.runtime.state import (
|
@@ -249,12 +248,7 @@ class CameraInputMixin:
|
|
249
248
|
camera_input_proto.help = dedent(help)
|
250
249
|
|
251
250
|
validate_width(width)
|
252
|
-
|
253
|
-
if isinstance(width, int):
|
254
|
-
width_config.pixel_width = width
|
255
|
-
else:
|
256
|
-
width_config.use_stretch = True
|
257
|
-
camera_input_proto.width_config.CopyFrom(width_config)
|
251
|
+
layout_config = LayoutConfig(width=width)
|
258
252
|
|
259
253
|
serde = CameraInputSerde()
|
260
254
|
|
@@ -269,7 +263,9 @@ class CameraInputMixin:
|
|
269
263
|
value_type="file_uploader_state_value",
|
270
264
|
)
|
271
265
|
|
272
|
-
self.dg._enqueue(
|
266
|
+
self.dg._enqueue(
|
267
|
+
"camera_input", camera_input_proto, layout_config=layout_config
|
268
|
+
)
|
273
269
|
|
274
270
|
if isinstance(camera_input_state.value, DeletedFile):
|
275
271
|
return None
|
@@ -34,6 +34,7 @@ from streamlit.elements.lib.file_uploader_utils import (
|
|
34
34
|
from streamlit.elements.lib.form_utils import is_in_form
|
35
35
|
from streamlit.elements.lib.image_utils import AtomicImage, WidthBehavior, image_to_url
|
36
36
|
from streamlit.elements.lib.layout_utils import (
|
37
|
+
LayoutConfig,
|
37
38
|
Width,
|
38
39
|
WidthWithoutContent,
|
39
40
|
validate_width,
|
@@ -350,11 +351,11 @@ class ChatMixin:
|
|
350
351
|
width_config.use_content = True
|
351
352
|
else:
|
352
353
|
width_config.use_stretch = True
|
353
|
-
message_container_proto.width_config.CopyFrom(width_config)
|
354
354
|
|
355
355
|
block_proto = BlockProto()
|
356
356
|
block_proto.allow_empty = True
|
357
357
|
block_proto.chat_message.CopyFrom(message_container_proto)
|
358
|
+
block_proto.width_config.CopyFrom(width_config)
|
358
359
|
|
359
360
|
return self.dg._block(block_proto=block_proto)
|
360
361
|
|
@@ -582,8 +583,6 @@ class ChatMixin:
|
|
582
583
|
writes_allowed=False,
|
583
584
|
)
|
584
585
|
|
585
|
-
validate_width(width)
|
586
|
-
|
587
586
|
if accept_file not in {True, False, "multiple"}:
|
588
587
|
raise StreamlitAPIException(
|
589
588
|
"The `accept_file` parameter must be a boolean or 'multiple'."
|
@@ -645,13 +644,6 @@ class ChatMixin:
|
|
645
644
|
chat_input_proto.file_type[:] = file_type if file_type is not None else []
|
646
645
|
chat_input_proto.max_upload_size_mb = config.get_option("server.maxUploadSize")
|
647
646
|
|
648
|
-
width_config = WidthConfig()
|
649
|
-
if isinstance(width, int):
|
650
|
-
width_config.pixel_width = width
|
651
|
-
else:
|
652
|
-
width_config.use_stretch = True
|
653
|
-
chat_input_proto.width_config.CopyFrom(width_config)
|
654
|
-
|
655
647
|
serde = ChatInputSerde(
|
656
648
|
accept_files=bool(accept_file),
|
657
649
|
allowed_types=file_type,
|
@@ -667,6 +659,9 @@ class ChatMixin:
|
|
667
659
|
value_type="chat_input_value",
|
668
660
|
)
|
669
661
|
|
662
|
+
validate_width(width)
|
663
|
+
layout_config = LayoutConfig(width=width)
|
664
|
+
|
670
665
|
chat_input_proto.disabled = disabled
|
671
666
|
if widget_state.value_changed and widget_state.value is not None:
|
672
667
|
chat_input_proto.value = widget_state.value
|
@@ -678,10 +673,12 @@ class ChatMixin:
|
|
678
673
|
# We need to enqueue the chat input into the bottom container
|
679
674
|
# instead of the currently active dg.
|
680
675
|
get_dg_singleton_instance().bottom_dg._enqueue(
|
681
|
-
"chat_input", chat_input_proto
|
676
|
+
"chat_input", chat_input_proto, layout_config=layout_config
|
682
677
|
)
|
683
678
|
else:
|
684
|
-
self.dg._enqueue(
|
679
|
+
self.dg._enqueue(
|
680
|
+
"chat_input", chat_input_proto, layout_config=layout_config
|
681
|
+
)
|
685
682
|
|
686
683
|
return widget_state.value if not widget_state.value_changed else None
|
687
684
|
|
@@ -270,8 +270,11 @@ def _apply_cell_edits(
|
|
270
270
|
# The edited cell is part of the index
|
271
271
|
# TODO(lukasmasuch): To support multi-index in the future:
|
272
272
|
# use a tuple of values here instead of a single value
|
273
|
-
df.index
|
274
|
-
|
273
|
+
old_idx_value = df.index[row_pos]
|
274
|
+
new_idx_value = _parse_value(value, dataframe_schema[INDEX_IDENTIFIER])
|
275
|
+
df.rename(
|
276
|
+
index={old_idx_value: new_idx_value},
|
277
|
+
inplace=True, # noqa: PD002
|
275
278
|
)
|
276
279
|
else:
|
277
280
|
col_pos = df.columns.get_loc(col_name)
|
@@ -697,7 +700,7 @@ class DataEditorMixin:
|
|
697
700
|
- A string to set the display label of the column.
|
698
701
|
|
699
702
|
- One of the column types defined under ``st.column_config``, e.g.
|
700
|
-
``st.column_config.NumberColumn("Dollar values
|
703
|
+
``st.column_config.NumberColumn("Dollar values", format="$ %d")`` to show
|
701
704
|
a column as dollar amounts. See more info on the available column types
|
702
705
|
and config options `here <https://docs.streamlit.io/develop/api-reference/data/st.column_config>`_.
|
703
706
|
|
@@ -26,7 +26,11 @@ from streamlit.elements.lib.file_uploader_utils import (
|
|
26
26
|
normalize_upload_file_type,
|
27
27
|
)
|
28
28
|
from streamlit.elements.lib.form_utils import current_form_id
|
29
|
-
from streamlit.elements.lib.layout_utils import
|
29
|
+
from streamlit.elements.lib.layout_utils import (
|
30
|
+
LayoutConfig,
|
31
|
+
WidthWithoutContent,
|
32
|
+
validate_width,
|
33
|
+
)
|
30
34
|
from streamlit.elements.lib.policies import (
|
31
35
|
check_widget_policies,
|
32
36
|
maybe_raise_label_warnings,
|
@@ -41,7 +45,6 @@ from streamlit.elements.lib.utils import (
|
|
41
45
|
from streamlit.proto.Common_pb2 import FileUploaderState as FileUploaderStateProto
|
42
46
|
from streamlit.proto.Common_pb2 import UploadedFileInfo as UploadedFileInfoProto
|
43
47
|
from streamlit.proto.FileUploader_pb2 import FileUploader as FileUploaderProto
|
44
|
-
from streamlit.proto.WidthConfig_pb2 import WidthConfig
|
45
48
|
from streamlit.runtime.metrics_util import gather_metrics
|
46
49
|
from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
|
47
50
|
from streamlit.runtime.state import (
|
@@ -487,14 +490,11 @@ class FileUploaderMixin:
|
|
487
490
|
)
|
488
491
|
|
489
492
|
validate_width(width)
|
490
|
-
|
491
|
-
if isinstance(width, int):
|
492
|
-
width_config.pixel_width = width
|
493
|
-
else:
|
494
|
-
width_config.use_stretch = True
|
495
|
-
file_uploader_proto.width_config.CopyFrom(width_config)
|
493
|
+
layout_config = LayoutConfig(width=width)
|
496
494
|
|
497
|
-
self.dg._enqueue(
|
495
|
+
self.dg._enqueue(
|
496
|
+
"file_uploader", file_uploader_proto, layout_config=layout_config
|
497
|
+
)
|
498
498
|
|
499
499
|
if isinstance(widget_state.value, DeletedFile):
|
500
500
|
return None
|