streamlit-nightly 1.35.1.dev20240601__py2.py3-none-any.whl → 1.35.1.dev20240604__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. streamlit/commands/navigation.py +8 -5
  2. streamlit/elements/deck_gl_json_chart.py +1 -1
  3. streamlit/elements/form.py +8 -3
  4. streamlit/elements/layouts.py +11 -3
  5. streamlit/elements/lib/policies.py +28 -2
  6. streamlit/elements/map.py +6 -6
  7. streamlit/elements/plotly_chart.py +3 -0
  8. streamlit/elements/pyplot.py +6 -5
  9. streamlit/elements/vega_charts.py +26 -16
  10. streamlit/elements/widgets/button.py +28 -11
  11. streamlit/elements/widgets/camera_input.py +2 -0
  12. streamlit/elements/widgets/chat.py +7 -6
  13. streamlit/elements/widgets/checkbox.py +2 -0
  14. streamlit/elements/widgets/color_picker.py +2 -0
  15. streamlit/elements/widgets/data_editor.py +2 -2
  16. streamlit/elements/widgets/file_uploader.py +2 -0
  17. streamlit/elements/widgets/multiselect.py +2 -0
  18. streamlit/elements/widgets/number_input.py +2 -0
  19. streamlit/elements/widgets/radio.py +2 -0
  20. streamlit/elements/widgets/selectbox.py +2 -0
  21. streamlit/elements/widgets/slider.py +2 -0
  22. streamlit/elements/widgets/text_widgets.py +4 -0
  23. streamlit/elements/widgets/time_widgets.py +4 -0
  24. streamlit/elements/write.py +3 -0
  25. streamlit/hello/Hello.py +22 -28
  26. streamlit/hello/streamlit_app.py +37 -0
  27. streamlit/proto/Alert_pb2.py +12 -11
  28. streamlit/proto/Alert_pb2.pyi +4 -2
  29. streamlit/proto/AppPage_pb2.py +10 -9
  30. streamlit/proto/AppPage_pb2.pyi +4 -7
  31. streamlit/proto/ArrowNamedDataSet_pb2.py +10 -9
  32. streamlit/proto/ArrowNamedDataSet_pb2.pyi +6 -8
  33. streamlit/proto/ArrowVegaLiteChart_pb2.py +10 -9
  34. streamlit/proto/ArrowVegaLiteChart_pb2.pyi +16 -16
  35. streamlit/proto/Arrow_pb2.py +16 -15
  36. streamlit/proto/Arrow_pb2.pyi +14 -8
  37. streamlit/proto/Audio_pb2.py +10 -9
  38. streamlit/proto/Audio_pb2.pyi +4 -7
  39. streamlit/proto/AutoRerun_pb2.py +9 -8
  40. streamlit/proto/AutoRerun_pb2.pyi +4 -7
  41. streamlit/proto/BackMsg_pb2.py +10 -9
  42. streamlit/proto/BackMsg_pb2.pyi +18 -19
  43. streamlit/proto/Balloons_pb2.py +10 -9
  44. streamlit/proto/Balloons_pb2.pyi +4 -7
  45. streamlit/proto/Block_pb2.py +34 -33
  46. streamlit/proto/Block_pb2.pyi +31 -19
  47. streamlit/proto/BokehChart_pb2.py +10 -9
  48. streamlit/proto/BokehChart_pb2.pyi +4 -7
  49. streamlit/proto/Button_pb2.py +10 -9
  50. streamlit/proto/Button_pb2.pyi +4 -7
  51. streamlit/proto/CameraInput_pb2.py +10 -9
  52. streamlit/proto/CameraInput_pb2.pyi +5 -8
  53. streamlit/proto/ChatInput_pb2.py +12 -11
  54. streamlit/proto/ChatInput_pb2.pyi +4 -2
  55. streamlit/proto/Checkbox_pb2.py +12 -11
  56. streamlit/proto/Checkbox_pb2.pyi +6 -4
  57. streamlit/proto/ClientState_pb2.py +10 -9
  58. streamlit/proto/ClientState_pb2.pyi +7 -10
  59. streamlit/proto/Code_pb2.py +10 -9
  60. streamlit/proto/Code_pb2.pyi +4 -7
  61. streamlit/proto/ColorPicker_pb2.py +10 -9
  62. streamlit/proto/ColorPicker_pb2.pyi +5 -8
  63. streamlit/proto/Common_pb2.py +32 -31
  64. streamlit/proto/Common_pb2.pyi +32 -23
  65. streamlit/proto/Components_pb2.py +18 -17
  66. streamlit/proto/Components_pb2.pyi +25 -23
  67. streamlit/proto/DataFrame_pb2.py +38 -37
  68. streamlit/proto/DataFrame_pb2.pyi +52 -33
  69. streamlit/proto/DateInput_pb2.py +10 -9
  70. streamlit/proto/DateInput_pb2.pyi +10 -13
  71. streamlit/proto/DeckGlJsonChart_pb2.py +10 -9
  72. streamlit/proto/DeckGlJsonChart_pb2.pyi +4 -7
  73. streamlit/proto/Delta_pb2.py +10 -9
  74. streamlit/proto/Delta_pb2.pyi +10 -10
  75. streamlit/proto/DocString_pb2.py +12 -11
  76. streamlit/proto/DocString_pb2.pyi +9 -10
  77. streamlit/proto/DownloadButton_pb2.py +10 -9
  78. streamlit/proto/DownloadButton_pb2.pyi +4 -7
  79. streamlit/proto/Element_pb2.py +10 -9
  80. streamlit/proto/Element_pb2.pyi +10 -9
  81. streamlit/proto/Empty_pb2.py +10 -9
  82. streamlit/proto/Empty_pb2.pyi +3 -0
  83. streamlit/proto/Exception_pb2.py +10 -9
  84. streamlit/proto/Exception_pb2.pyi +8 -10
  85. streamlit/proto/Favicon_pb2.py +10 -9
  86. streamlit/proto/Favicon_pb2.pyi +4 -7
  87. streamlit/proto/FileUploader_pb2.py +10 -9
  88. streamlit/proto/FileUploader_pb2.pyi +9 -11
  89. streamlit/proto/ForwardMsg_pb2.py +16 -15
  90. streamlit/proto/ForwardMsg_pb2.pyi +36 -24
  91. streamlit/proto/GitInfo_pb2.py +12 -11
  92. streamlit/proto/GitInfo_pb2.pyi +5 -3
  93. streamlit/proto/GraphVizChart_pb2.py +10 -9
  94. streamlit/proto/GraphVizChart_pb2.pyi +4 -7
  95. streamlit/proto/Heading_pb2.py +10 -9
  96. streamlit/proto/Heading_pb2.pyi +4 -7
  97. streamlit/proto/Html_pb2.py +10 -9
  98. streamlit/proto/Html_pb2.pyi +4 -7
  99. streamlit/proto/IFrame_pb2.py +10 -9
  100. streamlit/proto/IFrame_pb2.pyi +6 -9
  101. streamlit/proto/Image_pb2.py +12 -11
  102. streamlit/proto/Image_pb2.pyi +8 -10
  103. streamlit/proto/Json_pb2.py +10 -9
  104. streamlit/proto/Json_pb2.pyi +4 -7
  105. streamlit/proto/LabelVisibilityMessage_pb2.py +12 -11
  106. streamlit/proto/LabelVisibilityMessage_pb2.pyi +4 -2
  107. streamlit/proto/LinkButton_pb2.py +10 -9
  108. streamlit/proto/LinkButton_pb2.pyi +4 -7
  109. streamlit/proto/Logo_pb2.py +10 -9
  110. streamlit/proto/Logo_pb2.pyi +4 -7
  111. streamlit/proto/Markdown_pb2.py +12 -11
  112. streamlit/proto/Markdown_pb2.pyi +4 -2
  113. streamlit/proto/Metric_pb2.py +14 -13
  114. streamlit/proto/Metric_pb2.pyi +6 -4
  115. streamlit/proto/MultiSelect_pb2.py +10 -9
  116. streamlit/proto/MultiSelect_pb2.pyi +11 -14
  117. streamlit/proto/NamedDataSet_pb2.py +10 -9
  118. streamlit/proto/NamedDataSet_pb2.pyi +6 -8
  119. streamlit/proto/Navigation_pb2.py +12 -11
  120. streamlit/proto/Navigation_pb2.pyi +7 -5
  121. streamlit/proto/NewSession_pb2.py +32 -31
  122. streamlit/proto/NewSession_pb2.pyi +52 -36
  123. streamlit/proto/NumberInput_pb2.py +12 -11
  124. streamlit/proto/NumberInput_pb2.pyi +8 -6
  125. streamlit/proto/PageConfig_pb2.py +16 -15
  126. streamlit/proto/PageConfig_pb2.pyi +8 -5
  127. streamlit/proto/PageInfo_pb2.py +10 -9
  128. streamlit/proto/PageInfo_pb2.pyi +4 -7
  129. streamlit/proto/PageLink_pb2.py +10 -9
  130. streamlit/proto/PageLink_pb2.pyi +6 -9
  131. streamlit/proto/PageNotFound_pb2.py +10 -9
  132. streamlit/proto/PageNotFound_pb2.pyi +4 -7
  133. streamlit/proto/PageProfile_pb2.py +14 -13
  134. streamlit/proto/PageProfile_pb2.pyi +15 -16
  135. streamlit/proto/PagesChanged_pb2.py +10 -9
  136. streamlit/proto/PagesChanged_pb2.pyi +4 -7
  137. streamlit/proto/ParentMessage_pb2.py +10 -9
  138. streamlit/proto/ParentMessage_pb2.pyi +4 -7
  139. streamlit/proto/PlotlyChart_pb2.py +14 -13
  140. streamlit/proto/PlotlyChart_pb2.pyi +13 -8
  141. streamlit/proto/Progress_pb2.py +10 -9
  142. streamlit/proto/Progress_pb2.pyi +4 -7
  143. streamlit/proto/Radio_pb2.py +10 -9
  144. streamlit/proto/Radio_pb2.pyi +8 -12
  145. streamlit/proto/RootContainer_pb2.py +10 -9
  146. streamlit/proto/RootContainer_pb2.pyi +2 -1
  147. streamlit/proto/Selectbox_pb2.py +10 -9
  148. streamlit/proto/Selectbox_pb2.pyi +9 -13
  149. streamlit/proto/SessionEvent_pb2.py +10 -9
  150. streamlit/proto/SessionEvent_pb2.pyi +7 -9
  151. streamlit/proto/SessionStatus_pb2.py +10 -9
  152. streamlit/proto/SessionStatus_pb2.pyi +4 -7
  153. streamlit/proto/Skeleton_pb2.py +12 -11
  154. streamlit/proto/Skeleton_pb2.pyi +6 -4
  155. streamlit/proto/Slider_pb2.py +14 -13
  156. streamlit/proto/Slider_pb2.pyi +12 -10
  157. streamlit/proto/Snow_pb2.py +10 -9
  158. streamlit/proto/Snow_pb2.pyi +4 -7
  159. streamlit/proto/Spinner_pb2.py +10 -9
  160. streamlit/proto/Spinner_pb2.pyi +4 -7
  161. streamlit/proto/TextArea_pb2.py +10 -9
  162. streamlit/proto/TextArea_pb2.pyi +6 -10
  163. streamlit/proto/TextInput_pb2.py +12 -11
  164. streamlit/proto/TextInput_pb2.pyi +7 -5
  165. streamlit/proto/Text_pb2.py +10 -9
  166. streamlit/proto/Text_pb2.pyi +4 -7
  167. streamlit/proto/TimeInput_pb2.py +10 -9
  168. streamlit/proto/TimeInput_pb2.pyi +7 -11
  169. streamlit/proto/Toast_pb2.py +10 -9
  170. streamlit/proto/Toast_pb2.pyi +4 -7
  171. streamlit/proto/VegaLiteChart_pb2.py +10 -9
  172. streamlit/proto/VegaLiteChart_pb2.pyi +9 -10
  173. streamlit/proto/Video_pb2.py +14 -13
  174. streamlit/proto/Video_pb2.pyi +10 -6
  175. streamlit/proto/WidgetStates_pb2.py +12 -11
  176. streamlit/proto/WidgetStates_pb2.pyi +11 -12
  177. streamlit/proto/openmetrics_data_model_pb2.py +42 -41
  178. streamlit/proto/openmetrics_data_model_pb2.pyi +64 -31
  179. streamlit/runtime/caching/cached_message_replay.py +14 -29
  180. streamlit/runtime/fragment.py +3 -0
  181. streamlit/runtime/scriptrunner/script_run_context.py +1 -0
  182. streamlit/runtime/secrets.py +14 -0
  183. streamlit/static/asset-manifest.json +19 -19
  184. streamlit/static/index.html +1 -1
  185. streamlit/static/static/js/{1074.73973756.chunk.js → 1074.a92bc15f.chunk.js} +1 -1
  186. streamlit/static/static/js/1307.36b77087.chunk.js +1 -0
  187. streamlit/static/static/js/1451.229b62c4.chunk.js +1 -0
  188. streamlit/static/static/js/2469.5a75ba8e.chunk.js +1 -0
  189. streamlit/static/static/js/3599.565b1eba.chunk.js +1 -0
  190. streamlit/static/static/js/{4477.1bd49702.chunk.js → 4477.87935ac8.chunk.js} +1 -1
  191. streamlit/static/static/js/4500.be0eb305.chunk.js +1 -0
  192. streamlit/static/static/js/4666.a9344a3a.chunk.js +1 -0
  193. streamlit/static/static/js/5441.87f335e6.chunk.js +1 -0
  194. streamlit/static/static/js/6013.f6083314.chunk.js +1 -0
  195. streamlit/static/static/js/{6718.802da17e.chunk.js → 6718.2e6586ef.chunk.js} +1 -1
  196. streamlit/static/static/js/7175.8f4014ec.chunk.js +1 -0
  197. streamlit/static/static/js/7602.a20a999b.chunk.js +1 -0
  198. streamlit/static/static/js/8148.1b2c085e.chunk.js +1 -0
  199. streamlit/static/static/js/8427.59805a7f.chunk.js +1 -0
  200. streamlit/static/static/js/{8492.0d93bd08.chunk.js → 8492.8ad745d1.chunk.js} +1 -1
  201. streamlit/static/static/js/8691.cb9c04cf.chunk.js +1 -0
  202. streamlit/static/static/js/main.ea823277.js +2 -0
  203. streamlit/type_util.py +7 -0
  204. streamlit/web/cli.py +2 -2
  205. streamlit/web/server/server.py +2 -2
  206. {streamlit_nightly-1.35.1.dev20240601.dist-info → streamlit_nightly-1.35.1.dev20240604.dist-info}/METADATA +5 -5
  207. {streamlit_nightly-1.35.1.dev20240601.dist-info → streamlit_nightly-1.35.1.dev20240604.dist-info}/RECORD +216 -215
  208. streamlit/static/static/js/1307.0f0cca93.chunk.js +0 -1
  209. streamlit/static/static/js/1451.3b0a3e31.chunk.js +0 -1
  210. streamlit/static/static/js/2469.09ea79bb.chunk.js +0 -1
  211. streamlit/static/static/js/4500.b6f348d1.chunk.js +0 -1
  212. streamlit/static/static/js/4666.c4b22a63.chunk.js +0 -1
  213. streamlit/static/static/js/5379.f08eddd1.chunk.js +0 -1
  214. streamlit/static/static/js/5441.1b94928f.chunk.js +0 -1
  215. streamlit/static/static/js/6013.4ba2d616.chunk.js +0 -1
  216. streamlit/static/static/js/7175.583ff733.chunk.js +0 -1
  217. streamlit/static/static/js/7602.e8abc06b.chunk.js +0 -1
  218. streamlit/static/static/js/8148.293984e0.chunk.js +0 -1
  219. streamlit/static/static/js/8427.bd0a7cf3.chunk.js +0 -1
  220. streamlit/static/static/js/8691.4211c305.chunk.js +0 -1
  221. streamlit/static/static/js/main.707da454.js +0 -2
  222. /streamlit/hello/{pages/0_Animation_Demo.py → Animation_Demo.py} +0 -0
  223. /streamlit/hello/{pages/3_DataFrame_Demo.py → Dataframe_Demo.py} +0 -0
  224. /streamlit/hello/{pages/2_Mapping_Demo.py → Mapping_Demo.py} +0 -0
  225. /streamlit/hello/{pages/1_Plotting_Demo.py → Plotting_Demo.py} +0 -0
  226. /streamlit/static/static/js/{main.707da454.js.LICENSE.txt → main.ea823277.js.LICENSE.txt} +0 -0
  227. {streamlit_nightly-1.35.1.dev20240601.data → streamlit_nightly-1.35.1.dev20240604.data}/scripts/streamlit.cmd +0 -0
  228. {streamlit_nightly-1.35.1.dev20240601.dist-info → streamlit_nightly-1.35.1.dev20240604.dist-info}/WHEEL +0 -0
  229. {streamlit_nightly-1.35.1.dev20240601.dist-info → streamlit_nightly-1.35.1.dev20240604.dist-info}/entry_points.txt +0 -0
  230. {streamlit_nightly-1.35.1.dev20240601.dist-info → streamlit_nightly-1.35.1.dev20240604.dist-info}/top_level.txt +0 -0
@@ -55,7 +55,7 @@ def navigation(
55
55
  pages: list[StreamlitPage] | dict[SectionHeader, list[StreamlitPage]],
56
56
  *,
57
57
  position: Literal["sidebar", "hidden"] = "sidebar",
58
- ) -> StreamlitPage | None:
58
+ ) -> StreamlitPage:
59
59
  """
60
60
  Configure the available pages in a multipage app.
61
61
 
@@ -91,10 +91,6 @@ def navigation(
91
91
  >>> st.title("My Awesome App")
92
92
  >>> pg.run()
93
93
  """
94
- ctx = get_script_run_ctx()
95
- if not ctx:
96
- return None
97
-
98
94
  nav_sections = {"": pages} if isinstance(pages, list) else pages
99
95
  page_list = pages_from_nav_sections(nav_sections)
100
96
 
@@ -162,6 +158,13 @@ def navigation(
162
158
  p.section_header = section_header
163
159
  p.url_pathname = page.url_path
164
160
 
161
+ ctx = get_script_run_ctx()
162
+ if not ctx:
163
+ # This should never run in Streamlit, but we want to make sure that
164
+ # the function always returns a page
165
+ default_page._can_be_called = True
166
+ return default_page
167
+
165
168
  # Inform our page manager about the set of pages we have
166
169
  ctx.pages_manager.set_pages(pagehash_to_pageinfo)
167
170
  found_page = ctx.pages_manager.get_page_script(
@@ -72,7 +72,7 @@ class PydeckMixin:
72
72
  ----------
73
73
  pydeck_obj: pydeck.Deck or None
74
74
  Object specifying the PyDeck chart to draw.
75
- use_container_width: bool
75
+ use_container_width : bool
76
76
  Whether to override the figure's native width with the width of
77
77
  the parent container. If ``use_container_width`` is ``False``
78
78
  (default), Streamlit sets the width of the chart to fit its contents
@@ -272,9 +272,14 @@ class FormMixin:
272
272
  disabled : bool
273
273
  An optional boolean, which disables the button if set to True. The
274
274
  default is False.
275
- use_container_width: bool
276
- An optional boolean, which makes the button stretch its width to match the parent container.
277
-
275
+ use_container_width : bool
276
+ Whether to expand the button's width to fill its parent container.
277
+ If ``use_container_width`` is ``False`` (default), Streamlit sizes
278
+ the button to fit its contents. If ``use_container_width`` is
279
+ ``True``, the width of the button matches its parent container.
280
+
281
+ In both cases, if the contents of the button are wider than the
282
+ parent container, the contents will line wrap.
278
283
 
279
284
  Returns
280
285
  -------
@@ -545,9 +545,17 @@ class LayoutsMixin:
545
545
  True. The default is False.
546
546
 
547
547
  use_container_width : bool
548
- An optional boolean, which makes the popover button stretch its width
549
- to match the parent container. This only affects the button and not
550
- the width of the popover container.
548
+ Whether to expand the button's width to fill its parent container.
549
+ If ``use_container_width`` is ``False`` (default), Streamlit sizes
550
+ the button to fit its contents. If ``use_container_width`` is
551
+ ``True``, the width of the button matches its parent container.
552
+
553
+ In both cases, if the contents of the button are wider than the
554
+ parent container, the contents will line wrap.
555
+
556
+ The popover containter's minimimun width matches the width of its
557
+ button. The popover container may be wider than its button to fit
558
+ the container's contents.
551
559
 
552
560
  Examples
553
561
  --------
@@ -111,8 +111,6 @@ def check_cache_replay_rules() -> None:
111
111
  function to check for those as well. And rename it to check_widget_usage_rules.
112
112
  """
113
113
  if runtime.exists():
114
- # from streamlit.runtime.scriptrunner.script_run_context import get_script_run_ctx
115
-
116
114
  ctx = get_script_run_ctx()
117
115
  if ctx and ctx.disallow_cached_widget_usage:
118
116
  from streamlit import exception
@@ -120,3 +118,31 @@ def check_cache_replay_rules() -> None:
120
118
  # We use an exception here to show a proper stack trace
121
119
  # that indicates to the user where the issue is.
122
120
  exception(CachedWidgetWarning())
121
+
122
+
123
+ _fragment_writes_widget_to_outside_error = (
124
+ "Fragments cannot write to elements outside of their container."
125
+ )
126
+
127
+
128
+ def check_fragment_path_policy(dg: DeltaGenerator):
129
+ ctx = get_script_run_ctx()
130
+ # Check is only relevant for fragments
131
+ if ctx is None or ctx.current_fragment_id is None:
132
+ return
133
+
134
+ current_fragment_delta_path = ctx.current_fragment_delta_path
135
+ current_cursor = dg._active_dg._cursor
136
+ if current_cursor is None:
137
+ return
138
+
139
+ current_cursor_delta_path = current_cursor.delta_path
140
+
141
+ # the elements delta path cannot be smaller than the fragment's delta path if it is inside of the fragment
142
+ if len(current_cursor_delta_path) < len(current_fragment_delta_path):
143
+ raise StreamlitAPIException(_fragment_writes_widget_to_outside_error)
144
+
145
+ # all path indices of the fragment-path must occur in the inner-elements delta path, otherwise it is outside of the fragment container
146
+ for index, path_index in enumerate(current_fragment_delta_path):
147
+ if current_cursor_delta_path[index] != path_index:
148
+ raise StreamlitAPIException(_fragment_writes_widget_to_outside_error)
streamlit/elements/map.py CHANGED
@@ -165,13 +165,13 @@ class MapMixin:
165
165
  Zoom level as specified in
166
166
  https://wiki.openstreetmap.org/wiki/Zoom_levels.
167
167
 
168
- use_container_width: bool
168
+ use_container_width : bool
169
169
  Whether to override the map's native width with the width of
170
- the parent container. If ``use_container_width`` is ``False``
171
- (default), Streamlit sets the width of the chart to fit its contents
172
- according to the plotting library, up to the width of the parent
173
- container. If ``use_container_width`` is ``True``, Streamlit sets
174
- the width of the map to match the width of the parent container.
170
+ the parent container. If ``use_container_width`` is ``True``
171
+ (default), Streamlit sets the width of the map to match the width
172
+ of the parent container. If ``use_container_width`` is ``False``,
173
+ Streamlit sets the width of the chart to fit its contents according
174
+ to the plotting library, up to the width of the parent container.
175
175
 
176
176
  Examples
177
177
  --------
@@ -41,6 +41,7 @@ from streamlit.elements.lib.event_utils import AttributeDictionary
41
41
  from streamlit.elements.lib.policies import (
42
42
  check_cache_replay_rules,
43
43
  check_callback_rules,
44
+ check_fragment_path_policy,
44
45
  check_session_state_rules,
45
46
  )
46
47
  from streamlit.elements.lib.streamlit_plotly_theme import (
@@ -467,6 +468,8 @@ class PlotlyMixin:
467
468
 
468
469
  if is_selection_activated:
469
470
  # Run some checks that are only relevant when selections are activated
471
+
472
+ check_fragment_path_policy(self.dg)
470
473
  check_cache_replay_rules()
471
474
  if callable(on_select):
472
475
  check_callback_rules(self.dg, on_select)
@@ -61,11 +61,12 @@ class PyplotMixin:
61
61
 
62
62
  use_container_width : bool
63
63
  Whether to override the figure's native width with the width of
64
- the parent container. If ``use_container_width`` is ``False``
65
- (default), Streamlit sets the width of the chart to fit its contents
66
- according to the plotting library, up to the width of the parent
67
- container. If ``use_container_width`` is ``True``, Streamlit sets
68
- the width of the figure to match the width of the parent container.
64
+ the parent container. If ``use_container_width`` is ``True``
65
+ (default), Streamlit sets the width of the figure to match the
66
+ width of the parent container. If ``use_container_width`` is
67
+ ``False``, Streamlit sets the width of the chart to fit its
68
+ contents according to the plotting library, up to the width of the
69
+ parent container.
69
70
 
70
71
  **kwargs : any
71
72
  Arguments to pass to Matplotlib's savefig function.
@@ -46,6 +46,7 @@ from streamlit.elements.lib.event_utils import AttributeDictionary
46
46
  from streamlit.elements.lib.policies import (
47
47
  check_cache_replay_rules,
48
48
  check_callback_rules,
49
+ check_fragment_path_policy,
49
50
  check_session_state_rules,
50
51
  )
51
52
  from streamlit.errors import StreamlitAPIException
@@ -641,6 +642,8 @@ class VegaChartsMixin:
641
642
  parent container, Streamlit sets the chart width to match the width
642
643
  of the parent container.
643
644
 
645
+ To use ``width``, you must set ``use_container_width=False``.
646
+
644
647
  height : int or None
645
648
  Desired height of the chart expressed in pixels. If ``height`` is
646
649
  ``None`` (default), Streamlit sets the height of the chart to fit
@@ -648,10 +651,10 @@ class VegaChartsMixin:
648
651
 
649
652
  use_container_width : bool
650
653
  Whether to override ``width`` with the width of the parent
651
- container. If ``use_container_width`` is ``False`` (default),
652
- Streamlit sets the chart's width according to ``width``. If
653
- ``use_container_width`` is ``True``, Streamlit sets the width of
654
- the chart to match the width of the parent container.
654
+ container. If ``use_container_width`` is ``True`` (default),
655
+ Streamlit sets the width of the chart to match the width of the
656
+ parent container. If ``use_container_width`` is ``False``,
657
+ Streamlit sets the chart's width according to ``width``.
655
658
 
656
659
  Examples
657
660
  --------
@@ -813,6 +816,8 @@ class VegaChartsMixin:
813
816
  parent container, Streamlit sets the chart width to match the width
814
817
  of the parent container.
815
818
 
819
+ To use ``width``, you must set ``use_container_width=False``.
820
+
816
821
  height : int or None
817
822
  Desired height of the chart expressed in pixels. If ``height`` is
818
823
  ``None`` (default), Streamlit sets the height of the chart to fit
@@ -820,10 +825,10 @@ class VegaChartsMixin:
820
825
 
821
826
  use_container_width : bool
822
827
  Whether to override ``width`` with the width of the parent
823
- container. If ``use_container_width`` is ``False`` (default),
824
- Streamlit sets the chart's width according to ``width``. If
825
- ``use_container_width`` is ``True``, Streamlit sets the width of
826
- the chart to match the width of the parent container.
828
+ container. If ``use_container_width`` is ``True`` (default),
829
+ Streamlit sets the width of the chart to match the width of the
830
+ parent container. If ``use_container_width`` is ``False``,
831
+ Streamlit sets the chart's width according to ``width``.
827
832
 
828
833
  Examples
829
834
  --------
@@ -985,6 +990,8 @@ class VegaChartsMixin:
985
990
  parent container, Streamlit sets the chart width to match the width
986
991
  of the parent container.
987
992
 
993
+ To use ``width``, you must set ``use_container_width=False``.
994
+
988
995
  height : int or None
989
996
  Desired height of the chart expressed in pixels. If ``height`` is
990
997
  ``None`` (default), Streamlit sets the height of the chart to fit
@@ -992,10 +999,10 @@ class VegaChartsMixin:
992
999
 
993
1000
  use_container_width : bool
994
1001
  Whether to override ``width`` with the width of the parent
995
- container. If ``use_container_width`` is ``False`` (default),
996
- Streamlit sets the chart's width according to ``width``. If
997
- ``use_container_width`` is ``True``, Streamlit sets the width of
998
- the chart to match the width of the parent container.
1002
+ container. If ``use_container_width`` is ``True`` (default),
1003
+ Streamlit sets the width of the chart to match the width of the
1004
+ parent container. If ``use_container_width`` is ``False``,
1005
+ Streamlit sets the chart's width according to ``width``.
999
1006
 
1000
1007
  Examples
1001
1008
  --------
@@ -1169,6 +1176,8 @@ class VegaChartsMixin:
1169
1176
  parent container, Streamlit sets the chart width to match the width
1170
1177
  of the parent container.
1171
1178
 
1179
+ To use ``width``, you must set ``use_container_width=False``.
1180
+
1172
1181
  height : int or None
1173
1182
  Desired height of the chart expressed in pixels. If ``height`` is
1174
1183
  ``None`` (default), Streamlit sets the height of the chart to fit
@@ -1176,10 +1185,10 @@ class VegaChartsMixin:
1176
1185
 
1177
1186
  use_container_width : bool
1178
1187
  Whether to override ``width`` with the width of the parent
1179
- container. If ``use_container_width`` is ``False`` (default),
1180
- Streamlit sets the chart's width according to ``width``. If
1181
- ``use_container_width`` is ``True``, Streamlit sets the width of
1182
- the chart to match the width of the parent container.
1188
+ container. If ``use_container_width`` is ``True`` (default),
1189
+ Streamlit sets the width of the chart to match the width of the
1190
+ parent container. If ``use_container_width`` is ``False``,
1191
+ Streamlit sets the chart's width according to ``width``.
1183
1192
 
1184
1193
  Examples
1185
1194
  --------
@@ -1656,6 +1665,7 @@ class VegaChartsMixin:
1656
1665
  if is_selection_activated:
1657
1666
  # Run some checks that are only relevant when selections are activated
1658
1667
 
1668
+ check_fragment_path_policy(self.dg)
1659
1669
  check_cache_replay_rules()
1660
1670
  if callable(on_select):
1661
1671
  check_callback_rules(self.dg, on_select)
@@ -27,6 +27,7 @@ from streamlit.elements.form import current_form_id, is_in_form
27
27
  from streamlit.elements.lib.policies import (
28
28
  check_cache_replay_rules,
29
29
  check_callback_rules,
30
+ check_fragment_path_policy,
30
31
  check_session_state_rules,
31
32
  )
32
33
  from streamlit.errors import StreamlitAPIException
@@ -135,8 +136,14 @@ class ButtonMixin:
135
136
  disabled : bool
136
137
  An optional boolean, which disables the button if set to True. The
137
138
  default is False.
138
- use_container_width: bool
139
- An optional boolean, which makes the button stretch its width to match the parent container.
139
+ use_container_width : bool
140
+ Whether to expand the button's width to fill its parent container.
141
+ If ``use_container_width`` is ``False`` (default), Streamlit sizes
142
+ the button to fit its contents. If ``use_container_width`` is
143
+ ``True``, the width of the button matches its parent container.
144
+
145
+ In both cases, if the contents of the button are wider than the
146
+ parent container, the contents will line wrap.
140
147
 
141
148
  Returns
142
149
  -------
@@ -269,10 +276,14 @@ class ButtonMixin:
269
276
  disabled : bool
270
277
  An optional boolean, which disables the download button if set to
271
278
  True. The default is False.
272
- use_container_width: bool
273
- An optional boolean, which makes the button stretch its width to match the
274
- parent container.
279
+ use_container_width : bool
280
+ Whether to expand the button's width to fill its parent container.
281
+ If ``use_container_width`` is ``False`` (default), Streamlit sizes
282
+ the button to fit its contents. If ``use_container_width`` is
283
+ ``True``, the width of the button matches its parent container.
275
284
 
285
+ In both cases, if the contents of the button are wider than the
286
+ parent container, the contents will line wrap.
276
287
 
277
288
  Returns
278
289
  -------
@@ -411,9 +422,14 @@ class ButtonMixin:
411
422
  disabled : bool
412
423
  An optional boolean, which disables the link button if set to
413
424
  True. The default is False.
414
- use_container_width: bool
415
- An optional boolean, which makes the button stretch its width to match the
416
- parent container.
425
+ use_container_width : bool
426
+ Whether to expand the button's width to fill its parent container.
427
+ If ``use_container_width`` is ``False`` (default), Streamlit sizes
428
+ the button to fit its contents. If ``use_container_width`` is
429
+ ``True``, the width of the button matches its parent container.
430
+
431
+ In both cases, if the contents of the button are wider than the
432
+ parent container, the contents will line wrap.
417
433
 
418
434
  Example
419
435
  -------
@@ -517,9 +533,9 @@ class ButtonMixin:
517
533
  An optional boolean, which disables the page link if set to
518
534
  ``True``. The default is ``False``.
519
535
  use_container_width : bool
520
- An optional boolean, which makes the link stretch its width to
521
- match the parent container. The default is ``True`` for page links
522
- in the sidebar, and ``False`` for those in the main app.
536
+ Whether to expand the link's width to fill its parent container.
537
+ The default is ``True`` for page links in the sidebar and ``False``
538
+ for those in the main app.
523
539
 
524
540
  Example
525
541
  -------
@@ -745,6 +761,7 @@ class ButtonMixin:
745
761
  ) -> bool:
746
762
  key = to_key(key)
747
763
 
764
+ check_fragment_path_policy(self.dg)
748
765
  if not is_form_submitter:
749
766
  check_callback_rules(self.dg, on_click)
750
767
  check_cache_replay_rules()
@@ -24,6 +24,7 @@ from streamlit.elements.form import current_form_id
24
24
  from streamlit.elements.lib.policies import (
25
25
  check_cache_replay_rules,
26
26
  check_callback_rules,
27
+ check_fragment_path_policy,
27
28
  check_session_state_rules,
28
29
  )
29
30
  from streamlit.elements.lib.utils import get_label_visibility_proto_value
@@ -200,6 +201,7 @@ class CameraInputMixin:
200
201
  ) -> UploadedFile | None:
201
202
  key = to_key(key)
202
203
 
204
+ check_fragment_path_policy(self.dg)
203
205
  check_cache_replay_rules()
204
206
  check_callback_rules(self.dg, on_change)
205
207
  check_session_state_rules(default_value=None, key=key, writes_allowed=False)
@@ -21,6 +21,12 @@ from typing import TYPE_CHECKING, Literal, cast
21
21
  from streamlit import runtime
22
22
  from streamlit.elements.form import is_in_form
23
23
  from streamlit.elements.image import AtomicImage, WidthBehaviour, image_to_url
24
+ from streamlit.elements.lib.policies import (
25
+ check_cache_replay_rules,
26
+ check_callback_rules,
27
+ check_fragment_path_policy,
28
+ check_session_state_rules,
29
+ )
24
30
  from streamlit.errors import StreamlitAPIException
25
31
  from streamlit.proto.Block_pb2 import Block as BlockProto
26
32
  from streamlit.proto.ChatInput_pb2 import ChatInput as ChatInputProto
@@ -311,12 +317,7 @@ class ChatMixin:
311
317
  default = ""
312
318
  key = to_key(key)
313
319
 
314
- from streamlit.elements.lib.policies import (
315
- check_cache_replay_rules,
316
- check_callback_rules,
317
- check_session_state_rules,
318
- )
319
-
320
+ check_fragment_path_policy(self.dg)
320
321
  check_cache_replay_rules()
321
322
  check_callback_rules(self.dg, on_submit)
322
323
  check_session_state_rules(default_value=default, key=key, writes_allowed=False)
@@ -22,6 +22,7 @@ from streamlit.elements.form import current_form_id
22
22
  from streamlit.elements.lib.policies import (
23
23
  check_cache_replay_rules,
24
24
  check_callback_rules,
25
+ check_fragment_path_policy,
25
26
  check_session_state_rules,
26
27
  )
27
28
  from streamlit.elements.lib.utils import get_label_visibility_proto_value
@@ -282,6 +283,7 @@ class CheckboxMixin:
282
283
  ) -> bool:
283
284
  key = to_key(key)
284
285
 
286
+ check_fragment_path_policy(self.dg)
285
287
  check_cache_replay_rules()
286
288
  check_callback_rules(self.dg, on_change)
287
289
  check_session_state_rules(
@@ -24,6 +24,7 @@ from streamlit.elements.form import current_form_id
24
24
  from streamlit.elements.lib.policies import (
25
25
  check_cache_replay_rules,
26
26
  check_callback_rules,
27
+ check_fragment_path_policy,
27
28
  check_session_state_rules,
28
29
  )
29
30
  from streamlit.elements.lib.utils import get_label_visibility_proto_value
@@ -174,6 +175,7 @@ class ColorPickerMixin:
174
175
  ) -> str:
175
176
  key = to_key(key)
176
177
 
178
+ check_fragment_path_policy(self.dg)
177
179
  check_cache_replay_rules()
178
180
  check_callback_rules(self.dg, on_change)
179
181
  check_session_state_rules(default_value=value, key=key)
@@ -58,6 +58,7 @@ from streamlit.elements.lib.pandas_styler_utils import marshall_styler
58
58
  from streamlit.elements.lib.policies import (
59
59
  check_cache_replay_rules,
60
60
  check_callback_rules,
61
+ check_fragment_path_policy,
61
62
  check_session_state_rules,
62
63
  )
63
64
  from streamlit.errors import StreamlitAPIException
@@ -791,10 +792,9 @@ class DataEditorMixin:
791
792
  import pandas as pd
792
793
  import pyarrow as pa
793
794
 
794
- # Import here to avoid cyclic import warning
795
-
796
795
  key = to_key(key)
797
796
 
797
+ check_fragment_path_policy(self.dg)
798
798
  check_cache_replay_rules()
799
799
  check_callback_rules(self.dg, on_change)
800
800
  check_session_state_rules(default_value=None, key=key, writes_allowed=False)
@@ -25,6 +25,7 @@ from streamlit.elements.form import current_form_id
25
25
  from streamlit.elements.lib.policies import (
26
26
  check_cache_replay_rules,
27
27
  check_callback_rules,
28
+ check_fragment_path_policy,
28
29
  check_session_state_rules,
29
30
  )
30
31
  from streamlit.elements.lib.utils import get_label_visibility_proto_value
@@ -403,6 +404,7 @@ class FileUploaderMixin:
403
404
  ) -> UploadedFile | list[UploadedFile] | None:
404
405
  key = to_key(key)
405
406
 
407
+ check_fragment_path_policy(self.dg)
406
408
  check_cache_replay_rules()
407
409
  check_callback_rules(self.dg, on_change)
408
410
  check_session_state_rules(default_value=None, key=key, writes_allowed=False)
@@ -22,6 +22,7 @@ from streamlit.elements.form import current_form_id
22
22
  from streamlit.elements.lib.policies import (
23
23
  check_cache_replay_rules,
24
24
  check_callback_rules,
25
+ check_fragment_path_policy,
25
26
  check_session_state_rules,
26
27
  )
27
28
  from streamlit.elements.lib.utils import (
@@ -293,6 +294,7 @@ class MultiSelectMixin:
293
294
  ) -> list[T]:
294
295
  key = to_key(key)
295
296
 
297
+ check_fragment_path_policy(self.dg)
296
298
  check_cache_replay_rules()
297
299
  check_callback_rules(self.dg, on_change)
298
300
  check_session_state_rules(default_value=default, key=key)
@@ -25,6 +25,7 @@ from streamlit.elements.form import current_form_id
25
25
  from streamlit.elements.lib.policies import (
26
26
  check_cache_replay_rules,
27
27
  check_callback_rules,
28
+ check_fragment_path_policy,
28
29
  check_session_state_rules,
29
30
  )
30
31
  from streamlit.elements.lib.utils import get_label_visibility_proto_value
@@ -283,6 +284,7 @@ class NumberInputMixin:
283
284
  ) -> Number | None:
284
285
  key = to_key(key)
285
286
 
287
+ check_fragment_path_policy(self.dg)
286
288
  check_cache_replay_rules()
287
289
  check_callback_rules(self.dg, on_change)
288
290
  check_session_state_rules(
@@ -22,6 +22,7 @@ from streamlit.elements.form import current_form_id
22
22
  from streamlit.elements.lib.policies import (
23
23
  check_cache_replay_rules,
24
24
  check_callback_rules,
25
+ check_fragment_path_policy,
25
26
  check_session_state_rules,
26
27
  )
27
28
  from streamlit.elements.lib.utils import (
@@ -257,6 +258,7 @@ class RadioMixin:
257
258
  ) -> T | None:
258
259
  key = to_key(key)
259
260
 
261
+ check_fragment_path_policy(self.dg)
260
262
  check_cache_replay_rules()
261
263
  check_callback_rules(self.dg, on_change)
262
264
  check_session_state_rules(default_value=None if index == 0 else index, key=key)
@@ -21,6 +21,7 @@ from streamlit.elements.form import current_form_id
21
21
  from streamlit.elements.lib.policies import (
22
22
  check_cache_replay_rules,
23
23
  check_callback_rules,
24
+ check_fragment_path_policy,
24
25
  check_session_state_rules,
25
26
  )
26
27
  from streamlit.elements.lib.utils import (
@@ -237,6 +238,7 @@ class SelectboxMixin:
237
238
  ) -> T | None:
238
239
  key = to_key(key)
239
240
 
241
+ check_fragment_path_policy(self.dg)
240
242
  check_cache_replay_rules()
241
243
  check_callback_rules(self.dg, on_change)
242
244
  check_session_state_rules(default_value=None if index == 0 else index, key=key)
@@ -26,6 +26,7 @@ from streamlit.elements.form import current_form_id
26
26
  from streamlit.elements.lib.policies import (
27
27
  check_cache_replay_rules,
28
28
  check_callback_rules,
29
+ check_fragment_path_policy,
29
30
  check_session_state_rules,
30
31
  )
31
32
  from streamlit.elements.lib.utils import get_label_visibility_proto_value
@@ -369,6 +370,7 @@ class SliderMixin:
369
370
  ) -> SliderReturn:
370
371
  key = to_key(key)
371
372
 
373
+ check_fragment_path_policy(self.dg)
372
374
  check_cache_replay_rules()
373
375
  check_callback_rules(self.dg, on_change)
374
376
  check_session_state_rules(default_value=value, key=key)
@@ -22,6 +22,7 @@ from streamlit.elements.form import current_form_id
22
22
  from streamlit.elements.lib.policies import (
23
23
  check_cache_replay_rules,
24
24
  check_callback_rules,
25
+ check_fragment_path_policy,
25
26
  check_session_state_rules,
26
27
  )
27
28
  from streamlit.elements.lib.utils import get_label_visibility_proto_value
@@ -259,6 +260,8 @@ class TextWidgetsMixin:
259
260
  ctx: ScriptRunContext | None = None,
260
261
  ) -> str | None:
261
262
  key = to_key(key)
263
+
264
+ check_fragment_path_policy(self.dg)
262
265
  check_cache_replay_rules()
263
266
  check_callback_rules(self.dg, on_change)
264
267
  check_session_state_rules(default_value=None if value == "" else value, key=key)
@@ -528,6 +531,7 @@ class TextWidgetsMixin:
528
531
  ) -> str | None:
529
532
  key = to_key(key)
530
533
 
534
+ check_fragment_path_policy(self.dg)
531
535
  check_cache_replay_rules()
532
536
  check_callback_rules(self.dg, on_change)
533
537
  check_session_state_rules(default_value=None if value == "" else value, key=key)
@@ -36,6 +36,7 @@ from streamlit.elements.form import current_form_id
36
36
  from streamlit.elements.lib.policies import (
37
37
  check_cache_replay_rules,
38
38
  check_callback_rules,
39
+ check_fragment_path_policy,
39
40
  check_session_state_rules,
40
41
  )
41
42
  from streamlit.elements.lib.utils import get_label_visibility_proto_value
@@ -427,6 +428,8 @@ class TimeWidgetsMixin:
427
428
  ctx: ScriptRunContext | None = None,
428
429
  ) -> time | None:
429
430
  key = to_key(key)
431
+
432
+ check_fragment_path_policy(self.dg)
430
433
  check_cache_replay_rules()
431
434
  check_callback_rules(self.dg, on_change)
432
435
  check_session_state_rules(
@@ -691,6 +694,7 @@ class TimeWidgetsMixin:
691
694
  ) -> DateWidgetReturn:
692
695
  key = to_key(key)
693
696
 
697
+ check_fragment_path_policy(self.dg)
694
698
  check_cache_replay_rules()
695
699
  check_callback_rules(self.dg, on_change)
696
700
  check_session_state_rules(
@@ -483,6 +483,9 @@ class WriteMixin:
483
483
  ):
484
484
  # We either explicitly allow HTML or infer it's not HTML
485
485
  self.dg.markdown(repr_html, unsafe_allow_html=unsafe_allow_html)
486
+ elif type_util.is_streamlit_secrets_class(arg):
487
+ flush_buffer()
488
+ self.dg.json(arg.to_dict())
486
489
  else:
487
490
  stringified_arg = str(arg)
488
491