streamlit-data-editor-plus 0.1.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.
Files changed (456) hide show
  1. streamlit/__init__.py +292 -0
  2. streamlit/__main__.py +20 -0
  3. streamlit/auth_util.py +583 -0
  4. streamlit/cli_util.py +107 -0
  5. streamlit/column_config.py +60 -0
  6. streamlit/commands/__init__.py +13 -0
  7. streamlit/commands/echo.py +128 -0
  8. streamlit/commands/execution_control.py +318 -0
  9. streamlit/commands/logo.py +250 -0
  10. streamlit/commands/navigation.py +430 -0
  11. streamlit/commands/page_config.py +335 -0
  12. streamlit/components/__init__.py +13 -0
  13. streamlit/components/lib/__init__.py +13 -0
  14. streamlit/components/lib/local_component_registry.py +84 -0
  15. streamlit/components/types/__init__.py +13 -0
  16. streamlit/components/types/base_component_registry.py +99 -0
  17. streamlit/components/types/base_custom_component.py +158 -0
  18. streamlit/components/v1/__init__.py +29 -0
  19. streamlit/components/v1/component_arrow.py +141 -0
  20. streamlit/components/v1/component_registry.py +147 -0
  21. streamlit/components/v1/components.py +38 -0
  22. streamlit/components/v1/custom_component.py +239 -0
  23. streamlit/components/v2/__init__.py +531 -0
  24. streamlit/components/v2/bidi_component/__init__.py +20 -0
  25. streamlit/components/v2/bidi_component/constants.py +29 -0
  26. streamlit/components/v2/bidi_component/main.py +537 -0
  27. streamlit/components/v2/bidi_component/serialization.py +272 -0
  28. streamlit/components/v2/bidi_component/state.py +92 -0
  29. streamlit/components/v2/component_definition_resolver.py +143 -0
  30. streamlit/components/v2/component_file_watcher.py +403 -0
  31. streamlit/components/v2/component_manager.py +439 -0
  32. streamlit/components/v2/component_manifest_handler.py +122 -0
  33. streamlit/components/v2/component_path_utils.py +233 -0
  34. streamlit/components/v2/component_registry.py +426 -0
  35. streamlit/components/v2/get_bidi_component_manager.py +51 -0
  36. streamlit/components/v2/manifest_scanner.py +620 -0
  37. streamlit/components/v2/presentation.py +198 -0
  38. streamlit/components/v2/types.py +317 -0
  39. streamlit/config.py +2977 -0
  40. streamlit/config_option.py +319 -0
  41. streamlit/config_util.py +887 -0
  42. streamlit/connections/__init__.py +32 -0
  43. streamlit/connections/base_connection.py +215 -0
  44. streamlit/connections/snowflake_connection.py +765 -0
  45. streamlit/connections/snowpark_connection.py +213 -0
  46. streamlit/connections/sql_connection.py +427 -0
  47. streamlit/connections/util.py +97 -0
  48. streamlit/cursor.py +314 -0
  49. streamlit/dataframe_util.py +1434 -0
  50. streamlit/delta_generator.py +696 -0
  51. streamlit/delta_generator_singletons.py +243 -0
  52. streamlit/deprecation_util.py +253 -0
  53. streamlit/development.py +21 -0
  54. streamlit/elements/__init__.py +13 -0
  55. streamlit/elements/alert.py +341 -0
  56. streamlit/elements/arrow.py +1065 -0
  57. streamlit/elements/balloons.py +47 -0
  58. streamlit/elements/bokeh_chart.py +75 -0
  59. streamlit/elements/code.py +154 -0
  60. streamlit/elements/deck_gl_json_chart.py +627 -0
  61. streamlit/elements/dialog_decorator.py +320 -0
  62. streamlit/elements/empty.py +130 -0
  63. streamlit/elements/exception.py +370 -0
  64. streamlit/elements/form.py +481 -0
  65. streamlit/elements/graphviz_chart.py +226 -0
  66. streamlit/elements/heading.py +407 -0
  67. streamlit/elements/help.py +565 -0
  68. streamlit/elements/html.py +189 -0
  69. streamlit/elements/iframe.py +245 -0
  70. streamlit/elements/image.py +221 -0
  71. streamlit/elements/json.py +171 -0
  72. streamlit/elements/layouts.py +1534 -0
  73. streamlit/elements/lib/__init__.py +13 -0
  74. streamlit/elements/lib/built_in_chart_utils.py +1316 -0
  75. streamlit/elements/lib/color_util.py +272 -0
  76. streamlit/elements/lib/column_config_utils.py +555 -0
  77. streamlit/elements/lib/column_types.py +2699 -0
  78. streamlit/elements/lib/dialog.py +212 -0
  79. streamlit/elements/lib/dicttools.py +152 -0
  80. streamlit/elements/lib/file_uploader_utils.py +91 -0
  81. streamlit/elements/lib/form_utils.py +77 -0
  82. streamlit/elements/lib/image_utils.py +447 -0
  83. streamlit/elements/lib/js_number.py +105 -0
  84. streamlit/elements/lib/layout_utils.py +325 -0
  85. streamlit/elements/lib/mutable_expander_container.py +73 -0
  86. streamlit/elements/lib/mutable_popover_container.py +73 -0
  87. streamlit/elements/lib/mutable_status_container.py +194 -0
  88. streamlit/elements/lib/mutable_tab_container.py +73 -0
  89. streamlit/elements/lib/options_selector_utils.py +480 -0
  90. streamlit/elements/lib/pandas_styler_utils.py +302 -0
  91. streamlit/elements/lib/policies.py +198 -0
  92. streamlit/elements/lib/shortcut_utils.py +152 -0
  93. streamlit/elements/lib/streamlit_plotly_theme.py +206 -0
  94. streamlit/elements/lib/subtitle_utils.py +175 -0
  95. streamlit/elements/lib/utils.py +274 -0
  96. streamlit/elements/map.py +526 -0
  97. streamlit/elements/markdown.py +529 -0
  98. streamlit/elements/media.py +843 -0
  99. streamlit/elements/metric.py +529 -0
  100. streamlit/elements/pdf.py +190 -0
  101. streamlit/elements/plotly_chart.py +779 -0
  102. streamlit/elements/progress.py +172 -0
  103. streamlit/elements/pyplot.py +240 -0
  104. streamlit/elements/snow.py +47 -0
  105. streamlit/elements/space.py +121 -0
  106. streamlit/elements/spinner.py +152 -0
  107. streamlit/elements/table.py +240 -0
  108. streamlit/elements/text.py +113 -0
  109. streamlit/elements/toast.py +175 -0
  110. streamlit/elements/vega_charts.py +2510 -0
  111. streamlit/elements/widgets/__init__.py +13 -0
  112. streamlit/elements/widgets/audio_input.py +334 -0
  113. streamlit/elements/widgets/button.py +1559 -0
  114. streamlit/elements/widgets/button_group.py +1061 -0
  115. streamlit/elements/widgets/camera_input.py +281 -0
  116. streamlit/elements/widgets/chat.py +1028 -0
  117. streamlit/elements/widgets/checkbox.py +420 -0
  118. streamlit/elements/widgets/color_picker.py +329 -0
  119. streamlit/elements/widgets/data_editor.py +1168 -0
  120. streamlit/elements/widgets/data_editor_plus.py +902 -0
  121. streamlit/elements/widgets/feedback.py +322 -0
  122. streamlit/elements/widgets/file_uploader.py +592 -0
  123. streamlit/elements/widgets/multiselect.py +654 -0
  124. streamlit/elements/widgets/number_input.py +719 -0
  125. streamlit/elements/widgets/radio.py +551 -0
  126. streamlit/elements/widgets/select_slider.py +568 -0
  127. streamlit/elements/widgets/selectbox.py +680 -0
  128. streamlit/elements/widgets/slider.py +1093 -0
  129. streamlit/elements/widgets/text_widgets.py +779 -0
  130. streamlit/elements/widgets/time_widgets.py +1712 -0
  131. streamlit/elements/write.py +585 -0
  132. streamlit/emojis.py +34 -0
  133. streamlit/env_util.py +56 -0
  134. streamlit/error_util.py +112 -0
  135. streamlit/errors.py +680 -0
  136. streamlit/external/__init__.py +13 -0
  137. streamlit/external/langchain/__init__.py +23 -0
  138. streamlit/external/langchain/streamlit_callback_handler.py +410 -0
  139. streamlit/file_util.py +266 -0
  140. streamlit/git_util.py +200 -0
  141. streamlit/hello/__init__.py +13 -0
  142. streamlit/hello/__pycache__/__init__.cpython-312.pyc +0 -0
  143. streamlit/hello/__pycache__/streamlit_app.cpython-312.pyc +0 -0
  144. streamlit/hello/animation_demo.py +82 -0
  145. streamlit/hello/dataframe_demo.py +71 -0
  146. streamlit/hello/hello.py +46 -0
  147. streamlit/hello/mapping_demo.py +113 -0
  148. streamlit/hello/plotting_demo.py +62 -0
  149. streamlit/hello/streamlit_app.py +57 -0
  150. streamlit/hello/utils.py +30 -0
  151. streamlit/logger.py +129 -0
  152. streamlit/material_icon_names.py +25 -0
  153. streamlit/navigation/__init__.py +13 -0
  154. streamlit/navigation/page.py +365 -0
  155. streamlit/net_util.py +125 -0
  156. streamlit/path_security.py +98 -0
  157. streamlit/platform.py +31 -0
  158. streamlit/proto/Alert_pb2.py +28 -0
  159. streamlit/proto/Alert_pb2.pyi +100 -0
  160. streamlit/proto/AppPage_pb2.py +25 -0
  161. streamlit/proto/AppPage_pb2.pyi +75 -0
  162. streamlit/proto/ArrowData_pb2.py +27 -0
  163. streamlit/proto/ArrowData_pb2.pyi +103 -0
  164. streamlit/proto/ArrowNamedDataSet_pb2.py +26 -0
  165. streamlit/proto/ArrowNamedDataSet_pb2.pyi +65 -0
  166. streamlit/proto/AudioInput_pb2.py +26 -0
  167. streamlit/proto/AudioInput_pb2.pyi +72 -0
  168. streamlit/proto/Audio_pb2.py +26 -0
  169. streamlit/proto/Audio_pb2.pyi +75 -0
  170. streamlit/proto/AuthRedirect_pb2.py +25 -0
  171. streamlit/proto/AuthRedirect_pb2.pyi +48 -0
  172. streamlit/proto/AutoRerun_pb2.py +25 -0
  173. streamlit/proto/AutoRerun_pb2.pyi +52 -0
  174. streamlit/proto/BackMsg_pb2.py +29 -0
  175. streamlit/proto/BackMsg_pb2.pyi +132 -0
  176. streamlit/proto/Balloons_pb2.py +25 -0
  177. streamlit/proto/Balloons_pb2.pyi +48 -0
  178. streamlit/proto/BidiComponent_pb2.py +32 -0
  179. streamlit/proto/BidiComponent_pb2.pyi +176 -0
  180. streamlit/proto/Block_pb2.py +62 -0
  181. streamlit/proto/Block_pb2.pyi +518 -0
  182. streamlit/proto/ButtonGroup_pb2.py +32 -0
  183. streamlit/proto/ButtonGroup_pb2.pyi +157 -0
  184. streamlit/proto/ButtonLikeIconPosition_pb2.py +25 -0
  185. streamlit/proto/ButtonLikeIconPosition_pb2.pyi +47 -0
  186. streamlit/proto/Button_pb2.py +26 -0
  187. streamlit/proto/Button_pb2.pyi +82 -0
  188. streamlit/proto/CameraInput_pb2.py +26 -0
  189. streamlit/proto/CameraInput_pb2.pyi +66 -0
  190. streamlit/proto/ChatInput_pb2.py +27 -0
  191. streamlit/proto/ChatInput_pb2.pyi +113 -0
  192. streamlit/proto/Checkbox_pb2.py +28 -0
  193. streamlit/proto/Checkbox_pb2.pyi +99 -0
  194. streamlit/proto/ClientState_pb2.py +28 -0
  195. streamlit/proto/ClientState_pb2.pyi +137 -0
  196. streamlit/proto/Code_pb2.py +25 -0
  197. streamlit/proto/Code_pb2.pyi +59 -0
  198. streamlit/proto/ColorPicker_pb2.py +26 -0
  199. streamlit/proto/ColorPicker_pb2.pyi +82 -0
  200. streamlit/proto/Common_pb2.py +49 -0
  201. streamlit/proto/Common_pb2.pyi +325 -0
  202. streamlit/proto/Components_pb2.py +33 -0
  203. streamlit/proto/Components_pb2.pyi +196 -0
  204. streamlit/proto/Dataframe_pb2.py +30 -0
  205. streamlit/proto/Dataframe_pb2.pyi +172 -0
  206. streamlit/proto/DateInput_pb2.py +26 -0
  207. streamlit/proto/DateInput_pb2.pyi +91 -0
  208. streamlit/proto/DateTimeInput_pb2.py +26 -0
  209. streamlit/proto/DateTimeInput_pb2.pyi +94 -0
  210. streamlit/proto/DeckGlJsonChart_pb2.py +27 -0
  211. streamlit/proto/DeckGlJsonChart_pb2.pyi +91 -0
  212. streamlit/proto/Delta_pb2.py +29 -0
  213. streamlit/proto/Delta_pb2.pyi +82 -0
  214. streamlit/proto/DownloadButton_pb2.py +26 -0
  215. streamlit/proto/DownloadButton_pb2.pyi +92 -0
  216. streamlit/proto/Element_pb2.py +81 -0
  217. streamlit/proto/Element_pb2.pyi +348 -0
  218. streamlit/proto/Empty_pb2.py +25 -0
  219. streamlit/proto/Empty_pb2.pyi +42 -0
  220. streamlit/proto/Exception_pb2.py +26 -0
  221. streamlit/proto/Exception_pb2.pyi +88 -0
  222. streamlit/proto/Favicon_pb2.py +25 -0
  223. streamlit/proto/Favicon_pb2.pyi +47 -0
  224. streamlit/proto/Feedback_pb2.py +27 -0
  225. streamlit/proto/Feedback_pb2.pyi +93 -0
  226. streamlit/proto/FileUploader_pb2.py +26 -0
  227. streamlit/proto/FileUploader_pb2.pyi +90 -0
  228. streamlit/proto/ForwardMsg_pb2.py +48 -0
  229. streamlit/proto/ForwardMsg_pb2.pyi +296 -0
  230. streamlit/proto/GapSize_pb2.py +27 -0
  231. streamlit/proto/GapSize_pb2.pyi +82 -0
  232. streamlit/proto/GitInfo_pb2.py +27 -0
  233. streamlit/proto/GitInfo_pb2.pyi +84 -0
  234. streamlit/proto/GraphVizChart_pb2.py +25 -0
  235. streamlit/proto/GraphVizChart_pb2.pyi +56 -0
  236. streamlit/proto/Heading_pb2.py +25 -0
  237. streamlit/proto/Heading_pb2.pyi +63 -0
  238. streamlit/proto/HeightConfig_pb2.py +25 -0
  239. streamlit/proto/HeightConfig_pb2.pyi +61 -0
  240. streamlit/proto/Help_pb2.py +27 -0
  241. streamlit/proto/Help_pb2.pyi +104 -0
  242. streamlit/proto/Html_pb2.py +25 -0
  243. streamlit/proto/Html_pb2.pyi +52 -0
  244. streamlit/proto/IFrame_pb2.py +25 -0
  245. streamlit/proto/IFrame_pb2.pyi +68 -0
  246. streamlit/proto/Image_pb2.py +27 -0
  247. streamlit/proto/Image_pb2.pyi +73 -0
  248. streamlit/proto/Json_pb2.py +25 -0
  249. streamlit/proto/Json_pb2.pyi +63 -0
  250. streamlit/proto/LabelVisibility_pb2.py +27 -0
  251. streamlit/proto/LabelVisibility_pb2.pyi +69 -0
  252. streamlit/proto/LinkButton_pb2.py +26 -0
  253. streamlit/proto/LinkButton_pb2.pyi +76 -0
  254. streamlit/proto/Logo_pb2.py +27 -0
  255. streamlit/proto/Logo_pb2.pyi +82 -0
  256. streamlit/proto/Markdown_pb2.py +27 -0
  257. streamlit/proto/Markdown_pb2.pyi +83 -0
  258. streamlit/proto/Metric_pb2.py +32 -0
  259. streamlit/proto/Metric_pb2.pyi +145 -0
  260. streamlit/proto/MetricsEvent_pb2.py +28 -0
  261. streamlit/proto/MetricsEvent_pb2.pyi +224 -0
  262. streamlit/proto/MultiSelect_pb2.py +26 -0
  263. streamlit/proto/MultiSelect_pb2.pyi +108 -0
  264. streamlit/proto/Navigation_pb2.py +28 -0
  265. streamlit/proto/Navigation_pb2.pyi +89 -0
  266. streamlit/proto/NewSession_pb2.py +47 -0
  267. streamlit/proto/NewSession_pb2.pyi +753 -0
  268. streamlit/proto/NumberInput_pb2.py +28 -0
  269. streamlit/proto/NumberInput_pb2.pyi +138 -0
  270. streamlit/proto/PageConfig_pb2.py +33 -0
  271. streamlit/proto/PageConfig_pb2.pyi +179 -0
  272. streamlit/proto/PageInfo_pb2.py +25 -0
  273. streamlit/proto/PageInfo_pb2.pyi +50 -0
  274. streamlit/proto/PageLink_pb2.py +26 -0
  275. streamlit/proto/PageLink_pb2.pyi +80 -0
  276. streamlit/proto/PageNotFound_pb2.py +25 -0
  277. streamlit/proto/PageNotFound_pb2.pyi +49 -0
  278. streamlit/proto/PageProfile_pb2.py +29 -0
  279. streamlit/proto/PageProfile_pb2.pyi +146 -0
  280. streamlit/proto/ParentMessage_pb2.py +25 -0
  281. streamlit/proto/ParentMessage_pb2.pyi +53 -0
  282. streamlit/proto/PlotlyChart_pb2.py +27 -0
  283. streamlit/proto/PlotlyChart_pb2.pyi +96 -0
  284. streamlit/proto/Progress_pb2.py +25 -0
  285. streamlit/proto/Progress_pb2.pyi +50 -0
  286. streamlit/proto/Radio_pb2.py +26 -0
  287. streamlit/proto/Radio_pb2.pyi +104 -0
  288. streamlit/proto/RootContainer_pb2.py +25 -0
  289. streamlit/proto/RootContainer_pb2.pyi +56 -0
  290. streamlit/proto/Selectbox_pb2.py +26 -0
  291. streamlit/proto/Selectbox_pb2.pyi +107 -0
  292. streamlit/proto/SessionEvent_pb2.py +26 -0
  293. streamlit/proto/SessionEvent_pb2.pyi +72 -0
  294. streamlit/proto/SessionStatus_pb2.py +25 -0
  295. streamlit/proto/SessionStatus_pb2.pyi +64 -0
  296. streamlit/proto/Skeleton_pb2.py +27 -0
  297. streamlit/proto/Skeleton_pb2.pyi +75 -0
  298. streamlit/proto/Slider_pb2.py +30 -0
  299. streamlit/proto/Slider_pb2.pyi +161 -0
  300. streamlit/proto/Snow_pb2.py +25 -0
  301. streamlit/proto/Snow_pb2.pyi +48 -0
  302. streamlit/proto/Space_pb2.py +25 -0
  303. streamlit/proto/Space_pb2.pyi +48 -0
  304. streamlit/proto/Spinner_pb2.py +25 -0
  305. streamlit/proto/Spinner_pb2.pyi +56 -0
  306. streamlit/proto/Table_pb2.py +28 -0
  307. streamlit/proto/Table_pb2.pyi +83 -0
  308. streamlit/proto/TextAlignmentConfig_pb2.py +27 -0
  309. streamlit/proto/TextAlignmentConfig_pb2.pyi +69 -0
  310. streamlit/proto/TextArea_pb2.py +26 -0
  311. streamlit/proto/TextArea_pb2.pyi +97 -0
  312. streamlit/proto/TextInput_pb2.py +28 -0
  313. streamlit/proto/TextInput_pb2.pyi +124 -0
  314. streamlit/proto/Text_pb2.py +25 -0
  315. streamlit/proto/Text_pb2.pyi +53 -0
  316. streamlit/proto/TimeInput_pb2.py +26 -0
  317. streamlit/proto/TimeInput_pb2.pyi +86 -0
  318. streamlit/proto/Toast_pb2.py +25 -0
  319. streamlit/proto/Toast_pb2.pyi +64 -0
  320. streamlit/proto/Transient_pb2.py +26 -0
  321. streamlit/proto/Transient_pb2.pyi +53 -0
  322. streamlit/proto/VegaLiteChart_pb2.py +27 -0
  323. streamlit/proto/VegaLiteChart_pb2.pyi +92 -0
  324. streamlit/proto/Video_pb2.py +30 -0
  325. streamlit/proto/Video_pb2.pyi +129 -0
  326. streamlit/proto/WidgetStates_pb2.py +31 -0
  327. streamlit/proto/WidgetStates_pb2.pyi +157 -0
  328. streamlit/proto/WidthConfig_pb2.py +25 -0
  329. streamlit/proto/WidthConfig_pb2.pyi +61 -0
  330. streamlit/proto/__init__.py +15 -0
  331. streamlit/proto/openmetrics_data_model_pb2.py +58 -0
  332. streamlit/proto/openmetrics_data_model_pb2.pyi +558 -0
  333. streamlit/py.typed +0 -0
  334. streamlit/runtime/__init__.py +50 -0
  335. streamlit/runtime/app_session.py +1302 -0
  336. streamlit/runtime/caching/__init__.py +118 -0
  337. streamlit/runtime/caching/cache_data_api.py +775 -0
  338. streamlit/runtime/caching/cache_errors.py +143 -0
  339. streamlit/runtime/caching/cache_resource_api.py +756 -0
  340. streamlit/runtime/caching/cache_type.py +33 -0
  341. streamlit/runtime/caching/cache_utils.py +601 -0
  342. streamlit/runtime/caching/cached_message_replay.py +290 -0
  343. streamlit/runtime/caching/hashing.py +655 -0
  344. streamlit/runtime/caching/legacy_cache_api.py +170 -0
  345. streamlit/runtime/caching/storage/__init__.py +29 -0
  346. streamlit/runtime/caching/storage/cache_storage_protocol.py +236 -0
  347. streamlit/runtime/caching/storage/dummy_cache_storage.py +60 -0
  348. streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +159 -0
  349. streamlit/runtime/caching/storage/local_disk_cache_storage.py +223 -0
  350. streamlit/runtime/caching/ttl_cleanup_cache.py +85 -0
  351. streamlit/runtime/connection_factory.py +498 -0
  352. streamlit/runtime/context.py +449 -0
  353. streamlit/runtime/context_util.py +49 -0
  354. streamlit/runtime/credentials.py +355 -0
  355. streamlit/runtime/download_data_util.py +53 -0
  356. streamlit/runtime/forward_msg_cache.py +101 -0
  357. streamlit/runtime/forward_msg_queue.py +263 -0
  358. streamlit/runtime/fragment.py +441 -0
  359. streamlit/runtime/media_file_manager.py +409 -0
  360. streamlit/runtime/media_file_storage.py +143 -0
  361. streamlit/runtime/memory_media_file_storage.py +201 -0
  362. streamlit/runtime/memory_session_storage.py +77 -0
  363. streamlit/runtime/memory_uploaded_file_manager.py +149 -0
  364. streamlit/runtime/metrics_util.py +612 -0
  365. streamlit/runtime/pages_manager.py +160 -0
  366. streamlit/runtime/runtime.py +775 -0
  367. streamlit/runtime/runtime_util.py +108 -0
  368. streamlit/runtime/script_data.py +46 -0
  369. streamlit/runtime/scriptrunner/__init__.py +38 -0
  370. streamlit/runtime/scriptrunner/exec_code.py +167 -0
  371. streamlit/runtime/scriptrunner/magic.py +277 -0
  372. streamlit/runtime/scriptrunner/magic_funcs.py +32 -0
  373. streamlit/runtime/scriptrunner/script_cache.py +89 -0
  374. streamlit/runtime/scriptrunner/script_runner.py +805 -0
  375. streamlit/runtime/scriptrunner_utils/__init__.py +19 -0
  376. streamlit/runtime/scriptrunner_utils/exceptions.py +44 -0
  377. streamlit/runtime/scriptrunner_utils/script_requests.py +311 -0
  378. streamlit/runtime/scriptrunner_utils/script_run_context.py +277 -0
  379. streamlit/runtime/secrets.py +533 -0
  380. streamlit/runtime/session_manager.py +430 -0
  381. streamlit/runtime/state/__init__.py +47 -0
  382. streamlit/runtime/state/common.py +256 -0
  383. streamlit/runtime/state/presentation.py +85 -0
  384. streamlit/runtime/state/query_params.py +767 -0
  385. streamlit/runtime/state/query_params_proxy.py +222 -0
  386. streamlit/runtime/state/safe_session_state.py +146 -0
  387. streamlit/runtime/state/session_state.py +1299 -0
  388. streamlit/runtime/state/session_state_proxy.py +153 -0
  389. streamlit/runtime/state/widgets.py +197 -0
  390. streamlit/runtime/stats.py +356 -0
  391. streamlit/runtime/theme_util.py +148 -0
  392. streamlit/runtime/uploaded_file_manager.py +152 -0
  393. streamlit/runtime/websocket_session_manager.py +301 -0
  394. streamlit/source_util.py +97 -0
  395. streamlit/starlette.py +34 -0
  396. streamlit/string_util.py +264 -0
  397. streamlit/temporary_directory.py +67 -0
  398. streamlit/testing/__init__.py +13 -0
  399. streamlit/testing/v1/__init__.py +17 -0
  400. streamlit/testing/v1/app_test.py +1089 -0
  401. streamlit/testing/v1/element_tree.py +2272 -0
  402. streamlit/testing/v1/local_script_runner.py +176 -0
  403. streamlit/testing/v1/util.py +61 -0
  404. streamlit/time_util.py +73 -0
  405. streamlit/type_util.py +480 -0
  406. streamlit/url_util.py +120 -0
  407. streamlit/user_info.py +698 -0
  408. streamlit/util.py +108 -0
  409. streamlit/vendor/__init__.py +0 -0
  410. streamlit/vendor/pympler/__init__.py +0 -0
  411. streamlit/vendor/pympler/asizeof.py +2870 -0
  412. streamlit/version.py +18 -0
  413. streamlit/watcher/__init__.py +28 -0
  414. streamlit/watcher/event_based_path_watcher.py +500 -0
  415. streamlit/watcher/folder_black_list.py +82 -0
  416. streamlit/watcher/local_sources_watcher.py +297 -0
  417. streamlit/watcher/path_watcher.py +244 -0
  418. streamlit/watcher/polling_path_watcher.py +138 -0
  419. streamlit/watcher/util.py +223 -0
  420. streamlit/web/__init__.py +13 -0
  421. streamlit/web/bootstrap.py +463 -0
  422. streamlit/web/cache_storage_manager_config.py +38 -0
  423. streamlit/web/cli.py +465 -0
  424. streamlit/web/server/__init__.py +30 -0
  425. streamlit/web/server/app_discovery.py +422 -0
  426. streamlit/web/server/app_static_file_handler.py +102 -0
  427. streamlit/web/server/authlib_tornado_integration.py +125 -0
  428. streamlit/web/server/bidi_component_request_handler.py +193 -0
  429. streamlit/web/server/browser_websocket_handler.py +341 -0
  430. streamlit/web/server/component_file_utils.py +105 -0
  431. streamlit/web/server/component_request_handler.py +107 -0
  432. streamlit/web/server/media_file_handler.py +148 -0
  433. streamlit/web/server/oauth_authlib_routes.py +314 -0
  434. streamlit/web/server/oidc_mixin.py +138 -0
  435. streamlit/web/server/routes.py +257 -0
  436. streamlit/web/server/server.py +555 -0
  437. streamlit/web/server/server_util.py +235 -0
  438. streamlit/web/server/starlette/__init__.py +23 -0
  439. streamlit/web/server/starlette/starlette_app.py +541 -0
  440. streamlit/web/server/starlette/starlette_app_utils.py +306 -0
  441. streamlit/web/server/starlette/starlette_auth_routes.py +584 -0
  442. streamlit/web/server/starlette/starlette_gzip_middleware.py +121 -0
  443. streamlit/web/server/starlette/starlette_path_security_middleware.py +97 -0
  444. streamlit/web/server/starlette/starlette_routes.py +884 -0
  445. streamlit/web/server/starlette/starlette_server.py +496 -0
  446. streamlit/web/server/starlette/starlette_server_config.py +55 -0
  447. streamlit/web/server/starlette/starlette_static_routes.py +181 -0
  448. streamlit/web/server/starlette/starlette_websocket.py +560 -0
  449. streamlit/web/server/stats_request_handler.py +116 -0
  450. streamlit/web/server/upload_file_request_handler.py +158 -0
  451. streamlit/web/server/websocket_headers.py +56 -0
  452. streamlit_data_editor_plus-0.1.0.dist-info/METADATA +76 -0
  453. streamlit_data_editor_plus-0.1.0.dist-info/RECORD +456 -0
  454. streamlit_data_editor_plus-0.1.0.dist-info/WHEEL +5 -0
  455. streamlit_data_editor_plus-0.1.0.dist-info/entry_points.txt +2 -0
  456. streamlit_data_editor_plus-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1534 @@
1
+ # Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2026)
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
17
+ from collections.abc import Sequence
18
+ from dataclasses import dataclass
19
+ from typing import TYPE_CHECKING, Literal, TypeAlias, cast
20
+
21
+ from streamlit.delta_generator_singletons import get_dg_singleton_instance
22
+ from streamlit.elements.lib.layout_utils import (
23
+ Gap,
24
+ Height,
25
+ HorizontalAlignment,
26
+ VerticalAlignment,
27
+ Width,
28
+ WidthWithoutContent,
29
+ get_align,
30
+ get_gap_size,
31
+ get_height_config,
32
+ get_justify,
33
+ get_width_config,
34
+ validate_height,
35
+ validate_horizontal_alignment,
36
+ validate_vertical_alignment,
37
+ validate_width,
38
+ )
39
+ from streamlit.elements.lib.policies import check_widget_policies
40
+ from streamlit.elements.lib.utils import Key, compute_and_register_element_id, to_key
41
+ from streamlit.errors import (
42
+ StreamlitAPIException,
43
+ StreamlitInvalidColumnSpecError,
44
+ StreamlitInvalidVerticalAlignmentError,
45
+ StreamlitValueError,
46
+ )
47
+ from streamlit.proto.Block_pb2 import Block as BlockProto
48
+ from streamlit.proto.GapSize_pb2 import GapConfig
49
+ from streamlit.runtime.metrics_util import gather_metrics
50
+ from streamlit.runtime.scriptrunner import get_script_run_ctx
51
+ from streamlit.runtime.state import register_widget
52
+ from streamlit.string_util import validate_icon_or_emoji
53
+
54
+ if TYPE_CHECKING:
55
+ from streamlit.delta_generator import DeltaGenerator
56
+ from streamlit.elements.lib.dialog import Dialog
57
+ from streamlit.elements.lib.mutable_expander_container import ExpanderContainer
58
+ from streamlit.elements.lib.mutable_popover_container import PopoverContainer
59
+ from streamlit.elements.lib.mutable_status_container import StatusContainer
60
+ from streamlit.elements.lib.mutable_tab_container import TabContainer
61
+ from streamlit.runtime.state import WidgetCallback
62
+
63
+ SpecType: TypeAlias = int | Sequence[int | float]
64
+
65
+
66
+ @dataclass
67
+ class _ExpanderSerde:
68
+ """Serializer/deserializer for expander widget state."""
69
+
70
+ expanded: bool
71
+
72
+ def serialize(self, v: bool) -> bool:
73
+ return bool(v)
74
+
75
+ def deserialize(self, ui_value: bool | None) -> bool:
76
+ return ui_value if ui_value is not None else self.expanded
77
+
78
+
79
+ @dataclass
80
+ class _PopoverSerde:
81
+ """Serializer/deserializer for popover widget state."""
82
+
83
+ def serialize(self, v: bool) -> bool:
84
+ return bool(v)
85
+
86
+ def deserialize(self, ui_value: bool | None) -> bool:
87
+ return ui_value if ui_value is not None else False
88
+
89
+
90
+ @dataclass
91
+ class _TabsSerde:
92
+ """Serializer/deserializer for tabs widget state (active tab label)."""
93
+
94
+ default_label: str
95
+
96
+ def serialize(self, v: str) -> str:
97
+ return str(v)
98
+
99
+ def deserialize(self, ui_value: str | None) -> str:
100
+ return ui_value if ui_value is not None else self.default_label
101
+
102
+
103
+ class LayoutsMixin:
104
+ @gather_metrics("container")
105
+ def container(
106
+ self,
107
+ *,
108
+ border: bool | None = None,
109
+ key: Key | None = None,
110
+ width: Width = "stretch",
111
+ height: Height = "content",
112
+ horizontal: bool = False,
113
+ horizontal_alignment: HorizontalAlignment = "left",
114
+ vertical_alignment: VerticalAlignment = "top",
115
+ gap: Gap | None = "small",
116
+ ) -> DeltaGenerator:
117
+ """Insert a multi-element container.
118
+
119
+ Inserts an invisible container into your app that can be used to hold
120
+ multiple elements. This allows you to, for example, insert multiple
121
+ elements into your app out of order.
122
+
123
+ To add elements to the returned container, you can use the ``with``
124
+ notation (preferred) or just call commands directly on the returned
125
+ object. See examples below.
126
+
127
+ Parameters
128
+ ----------
129
+ border : bool or None
130
+ Whether to show a border around the container. If ``None`` (default), a
131
+ border is shown if the container is set to a fixed height and not
132
+ shown otherwise.
133
+
134
+ key : str or None
135
+ An optional string to give this container a stable identity.
136
+
137
+ Additionally, if ``key`` is provided, it will be used as CSS
138
+ class name prefixed with ``st-key-``.
139
+
140
+ width : "stretch", "content", or int
141
+ The width of the container. This can be one of the following:
142
+
143
+ - ``"stretch"`` (default): The width of the container matches the
144
+ width of the parent container.
145
+ - ``"content"``: The width of the container matches the width of
146
+ its content.
147
+ - An integer specifying the width in pixels: The container has a
148
+ fixed width. If the specified width is greater than the width of
149
+ the parent container, the width of the container matches the width
150
+ of the parent container.
151
+
152
+ height : "content", "stretch", or int
153
+ The height of the container. This can be one of the following:
154
+
155
+ - ``"content"`` (default): The height of the container matches the
156
+ height of its content.
157
+ - ``"stretch"``: The height of the container matches the height of
158
+ its content or the height of the parent container, whichever is
159
+ larger. If the container is not in a parent container, the height
160
+ of the container matches the height of its content.
161
+ - An integer specifying the height in pixels: The container has a
162
+ fixed height. If the content is larger than the specified
163
+ height, scrolling is enabled.
164
+
165
+ .. note::
166
+ Use scrolling containers sparingly. If you use scrolling
167
+ containers, avoid heights that exceed 500 pixels. Otherwise,
168
+ the scroll surface of the container might cover the majority of
169
+ the screen on mobile devices, which makes it hard to scroll the
170
+ rest of the app.
171
+
172
+ horizontal : bool
173
+ Whether to use horizontal flexbox layout. If this is ``False``
174
+ (default), the container's elements are laid out vertically. If
175
+ this is ``True``, the container's elements are laid out
176
+ horizontally and will overflow to the next line if they don't fit
177
+ within the container's width.
178
+
179
+ horizontal_alignment : "left", "center", "right", or "distribute"
180
+ The horizontal alignment of the elements inside the container. This
181
+ can be one of the following:
182
+
183
+ - ``"left"`` (default): Elements are aligned to the left side of
184
+ the container.
185
+ - ``"center"``: Elements are horizontally centered inside the
186
+ container.
187
+ - ``"right"``: Elements are aligned to the right side of the
188
+ container.
189
+ - ``"distribute"``: Elements are distributed evenly in the
190
+ container. This increases the horizontal gap between elements to
191
+ fill the width of the container. A standalone element is aligned
192
+ to the left.
193
+
194
+ When ``horizontal`` is ``False``, ``"distribute"`` aligns the
195
+ elements the same as ``"left"``.
196
+
197
+ vertical_alignment : "top", "center", "bottom", or "distribute"
198
+ The vertical alignment of the elements inside the container. This
199
+ can be one of the following:
200
+
201
+ - ``"top"`` (default): Elements are aligned to the top of the
202
+ container.
203
+ - ``"center"``: Elements are vertically centered inside the
204
+ container.
205
+ - ``"bottom"``: Elements are aligned to the bottom of the
206
+ container.
207
+ - ``"distribute"``: Elements are distributed evenly in the
208
+ container. This increases the vertical gap between elements to
209
+ fill the height of the container. A standalone element is aligned
210
+ to the top.
211
+
212
+ When ``horizontal`` is ``True``, ``"distribute"`` aligns the
213
+ elements the same as ``"top"``.
214
+
215
+ gap : "xxsmall", "xsmall", "small", "medium", "large", "xlarge", "xxlarge", or None
216
+ The minimum gap size between the elements inside the container.
217
+ This can be one of the following:
218
+
219
+ - ``"xxsmall"``: 0.25rem gap between the elements.
220
+ - ``"xsmall"``: 0.5rem gap between the elements.
221
+ - ``"small"`` (default): 1rem gap between the elements.
222
+ - ``"medium"``: 2rem gap between the elements.
223
+ - ``"large"``: 4rem gap between the elements.
224
+ - ``"xlarge"``: 6rem gap between the elements.
225
+ - ``"xxlarge"``: 8rem gap between the elements.
226
+ - ``None``: No gap between the elements.
227
+
228
+ The rem unit is relative to the ``theme.baseFontSize``
229
+ configuration option.
230
+
231
+ The minimum gap applies to both the vertical and horizontal gaps
232
+ between the elements. Elements may have larger gaps in one
233
+ direction if you use a distributed horizontal alignment or fixed
234
+ height.
235
+
236
+ Examples
237
+ --------
238
+ **Example 1: Inserting elements using ``with`` notation**
239
+
240
+ You can use the ``with`` statement to insert any element into a
241
+ container.
242
+
243
+ >>> import streamlit as st
244
+ >>>
245
+ >>> with st.container():
246
+ ... st.write("This is inside the container")
247
+ ...
248
+ ... # You can call any Streamlit command, including custom components:
249
+ ... st.bar_chart(np.random.randn(50, 3))
250
+ >>>
251
+ >>> st.write("This is outside the container")
252
+
253
+ .. output::
254
+ https://doc-container1.streamlit.app/
255
+ height: 520px
256
+
257
+ **Example 2: Inserting elements out of order**
258
+
259
+ When you create a container, its position in the app remains fixed and
260
+ you can add elements to it at any time. This allows you to insert
261
+ elements out of order in your app. You can also write to the container
262
+ by calling commands directly on the container object.
263
+
264
+ >>> import streamlit as st
265
+ >>>
266
+ >>> container = st.container(border=True)
267
+ >>> container.write("This is inside the container")
268
+ >>> st.write("This is outside the container")
269
+ >>>
270
+ >>> container.write("This is inside too")
271
+
272
+ .. output::
273
+ https://doc-container2.streamlit.app/
274
+ height: 300px
275
+
276
+ **Example 3: Grid layout with columns and containers**
277
+
278
+ You can create a grid with a fixed number of elements per row by using
279
+ columns and containers.
280
+
281
+ >>> import streamlit as st
282
+ >>>
283
+ >>> row1 = st.columns(3)
284
+ >>> row2 = st.columns(3)
285
+ >>>
286
+ >>> for col in row1 + row2:
287
+ >>> tile = col.container(height=120)
288
+ >>> tile.title(":balloon:")
289
+
290
+ .. output::
291
+ https://doc-container3.streamlit.app/
292
+ height: 350px
293
+
294
+ **Example 4: Vertically scrolling container**
295
+
296
+ You can create a vertically scrolling container by setting a fixed
297
+ height.
298
+
299
+ >>> import streamlit as st
300
+ >>>
301
+ >>> long_text = "Lorem ipsum. " * 1000
302
+ >>>
303
+ >>> with st.container(height=300):
304
+ >>> st.markdown(long_text)
305
+
306
+ .. output::
307
+ https://doc-container4.streamlit.app/
308
+ height: 400px
309
+
310
+ **Example 5: Horizontal container**
311
+
312
+ You can create a row of widgets using a horizontal container. Use
313
+ ``horizontal_alignment`` to specify the alignment of the elements.
314
+
315
+ >>> import streamlit as st
316
+ >>>
317
+ >>> flex = st.container(horizontal=True, horizontal_alignment="right")
318
+ >>>
319
+ >>> for card in range(3):
320
+ >>> flex.button(f"Button {card + 1}")
321
+
322
+ .. output::
323
+ https://doc-container5.streamlit.app/
324
+ height: 250px
325
+
326
+ """
327
+ key = to_key(key)
328
+ block_proto = BlockProto()
329
+ block_proto.allow_empty = False
330
+ block_proto.flex_container.border = border or False
331
+ block_proto.flex_container.gap_config.gap_size = get_gap_size(
332
+ gap, "st.container"
333
+ )
334
+
335
+ validate_horizontal_alignment(horizontal_alignment)
336
+ validate_vertical_alignment(vertical_alignment)
337
+ if horizontal:
338
+ block_proto.flex_container.wrap = True
339
+ block_proto.flex_container.direction = (
340
+ BlockProto.FlexContainer.Direction.HORIZONTAL
341
+ )
342
+ block_proto.flex_container.justify = get_justify(horizontal_alignment)
343
+ block_proto.flex_container.align = get_align(vertical_alignment)
344
+ else:
345
+ block_proto.flex_container.wrap = False
346
+ block_proto.flex_container.direction = (
347
+ BlockProto.FlexContainer.Direction.VERTICAL
348
+ )
349
+ block_proto.flex_container.justify = get_justify(vertical_alignment)
350
+ block_proto.flex_container.align = get_align(horizontal_alignment)
351
+
352
+ validate_width(width, allow_content=True)
353
+ block_proto.width_config.CopyFrom(get_width_config(width))
354
+
355
+ if isinstance(height, int) or border:
356
+ block_proto.allow_empty = True
357
+
358
+ if border is not None:
359
+ block_proto.flex_container.border = border
360
+ elif isinstance(height, int):
361
+ block_proto.flex_container.border = True
362
+ else:
363
+ block_proto.flex_container.border = False
364
+
365
+ validate_height(height, allow_content=True)
366
+ block_proto.height_config.CopyFrom(get_height_config(height))
367
+
368
+ if key:
369
+ # At the moment, the ID is only used for extracting the
370
+ # key on the frontend and setting it as CSS class.
371
+ # There are plans to use the ID for other container features
372
+ # in the future. This might require including more container
373
+ # parameters in the ID calculation.
374
+ block_proto.id = compute_and_register_element_id(
375
+ "container", user_key=key, dg=None, key_as_main_identity=False
376
+ )
377
+
378
+ return self.dg._block(block_proto)
379
+
380
+ @gather_metrics("columns")
381
+ def columns(
382
+ self,
383
+ spec: SpecType,
384
+ *,
385
+ gap: Gap | None = "small",
386
+ vertical_alignment: Literal["top", "center", "bottom"] = "top",
387
+ border: bool = False,
388
+ width: WidthWithoutContent = "stretch",
389
+ ) -> list[DeltaGenerator]:
390
+ """Insert containers laid out as side-by-side columns.
391
+
392
+ Inserts a number of multi-element containers laid out side-by-side and
393
+ returns a list of container objects.
394
+
395
+ To add elements to the returned containers, you can use the ``with`` notation
396
+ (preferred) or just call methods directly on the returned object. See
397
+ examples below.
398
+
399
+ .. note::
400
+ To follow best design practices and maintain a good appearance on
401
+ all screen sizes, don't nest columns more than once.
402
+
403
+ Parameters
404
+ ----------
405
+ spec : int or Iterable of numbers
406
+ Controls the number and width of columns to insert. Can be one of:
407
+
408
+ - An integer that specifies the number of columns. All columns have equal
409
+ width in this case.
410
+ - An Iterable of numbers (int or float) that specify the relative width of
411
+ each column. E.g. ``[0.7, 0.3]`` creates two columns where the first
412
+ one takes up 70% of the available with and the second one takes up 30%.
413
+ Or ``[1, 2, 3]`` creates three columns where the second one is two times
414
+ the width of the first one, and the third one is three times that width.
415
+
416
+ gap : "xxsmall", "xsmall", "small", "medium", "large", "xlarge", "xxlarge", or None
417
+ The size of the gap between the columns. This can be one of the
418
+ following:
419
+
420
+ - ``"xxsmall"``: 0.25rem gap between the columns.
421
+ - ``"xsmall"``: 0.5rem gap between the columns.
422
+ - ``"small"`` (default): 1rem gap between the columns.
423
+ - ``"medium"``: 2rem gap between the columns.
424
+ - ``"large"``: 4rem gap between the columns.
425
+ - ``"xlarge"``: 6rem gap between the columns.
426
+ - ``"xxlarge"``: 8rem gap between the columns.
427
+ - ``None``: No gap between the columns.
428
+
429
+ The rem unit is relative to the ``theme.baseFontSize``
430
+ configuration option.
431
+
432
+ vertical_alignment : "top", "center", or "bottom"
433
+ The vertical alignment of the content inside the columns. The
434
+ default is ``"top"``.
435
+
436
+ border : bool
437
+ Whether to show a border around the column containers. If this is
438
+ ``False`` (default), no border is shown. If this is ``True``, a
439
+ border is shown around each column.
440
+
441
+ width : "stretch" or int
442
+ The width of the column group. This can be one of the following:
443
+
444
+ - ``"stretch"`` (default): The width of the column group matches the
445
+ width of the parent container.
446
+ - An integer specifying the width in pixels: The column group has a
447
+ fixed width. If the specified width is greater than the width of
448
+ the parent container, the width of the column group matches the
449
+ width of the parent container.
450
+
451
+ Returns
452
+ -------
453
+ list of containers
454
+ A list of container objects.
455
+
456
+ Examples
457
+ --------
458
+ **Example 1: Use context management**
459
+
460
+ You can use the ``with`` statement to insert any element into a column:
461
+
462
+ >>> import streamlit as st
463
+ >>>
464
+ >>> col1, col2, col3 = st.columns(3)
465
+ >>>
466
+ >>> with col1:
467
+ ... st.header("A cat")
468
+ ... st.image("https://static.streamlit.io/examples/cat.jpg")
469
+ >>>
470
+ >>> with col2:
471
+ ... st.header("A dog")
472
+ ... st.image("https://static.streamlit.io/examples/dog.jpg")
473
+ >>>
474
+ >>> with col3:
475
+ ... st.header("An owl")
476
+ ... st.image("https://static.streamlit.io/examples/owl.jpg")
477
+
478
+ .. output::
479
+ https://doc-columns1.streamlit.app/
480
+ height: 620px
481
+
482
+
483
+ **Example 2: Use commands as container methods**
484
+
485
+ You can just call methods directly on the returned objects:
486
+
487
+ >>> import streamlit as st
488
+ >>> from numpy.random import default_rng as rng
489
+ >>>
490
+ >>> df = rng(0).standard_normal((10, 1))
491
+ >>> col1, col2 = st.columns([3, 1])
492
+ >>>
493
+ >>> col1.subheader("A wide column with a chart")
494
+ >>> col1.line_chart(df)
495
+ >>>
496
+ >>> col2.subheader("A narrow column with the data")
497
+ >>> col2.write(df)
498
+
499
+ .. output::
500
+ https://doc-columns2.streamlit.app/
501
+ height: 550px
502
+
503
+ **Example 3: Align widgets**
504
+
505
+ Use ``vertical_alignment="bottom"`` to align widgets.
506
+
507
+ >>> import streamlit as st
508
+ >>>
509
+ >>> left, middle, right = st.columns(3, vertical_alignment="bottom")
510
+ >>>
511
+ >>> left.text_input("Write something")
512
+ >>> middle.button("Click me", use_container_width=True)
513
+ >>> right.checkbox("Check me")
514
+
515
+ .. output::
516
+ https://doc-columns-bottom-widgets.streamlit.app/
517
+ height: 200px
518
+
519
+ **Example 4: Use vertical alignment to create grids**
520
+
521
+ Adjust vertical alignment to customize your grid layouts.
522
+
523
+ >>> import streamlit as st
524
+ >>>
525
+ >>> vertical_alignment = st.selectbox(
526
+ >>> "Vertical alignment", ["top", "center", "bottom"], index=2
527
+ >>> )
528
+ >>>
529
+ >>> left, middle, right = st.columns(3, vertical_alignment=vertical_alignment)
530
+ >>> left.image("https://static.streamlit.io/examples/cat.jpg")
531
+ >>> middle.image("https://static.streamlit.io/examples/dog.jpg")
532
+ >>> right.image("https://static.streamlit.io/examples/owl.jpg")
533
+
534
+ .. output::
535
+ https://doc-columns-vertical-alignment.streamlit.app/
536
+ height: 600px
537
+
538
+ **Example 5: Add borders**
539
+
540
+ Add borders to your columns instead of nested containers for consistent
541
+ heights.
542
+
543
+ >>> import streamlit as st
544
+ >>>
545
+ >>> left, middle, right = st.columns(3, border=True)
546
+ >>>
547
+ >>> left.markdown("Lorem ipsum " * 10)
548
+ >>> middle.markdown("Lorem ipsum " * 5)
549
+ >>> right.markdown("Lorem ipsum ")
550
+
551
+ .. output::
552
+ https://doc-columns-borders.streamlit.app/
553
+ height: 250px
554
+
555
+ """
556
+ weights = spec
557
+ if isinstance(weights, int):
558
+ # If the user provided a single number, expand into equal weights.
559
+ # E.g. (1,) * 3 => (1, 1, 1)
560
+ # NOTE: A negative/zero spec will expand into an empty tuple.
561
+ weights = (1,) * weights
562
+
563
+ if len(weights) == 0 or any(weight <= 0 for weight in weights):
564
+ raise StreamlitInvalidColumnSpecError()
565
+
566
+ vertical_alignment_mapping: dict[
567
+ str, BlockProto.Column.VerticalAlignment.ValueType
568
+ ] = {
569
+ "top": BlockProto.Column.VerticalAlignment.TOP,
570
+ "center": BlockProto.Column.VerticalAlignment.CENTER,
571
+ "bottom": BlockProto.Column.VerticalAlignment.BOTTOM,
572
+ }
573
+
574
+ if vertical_alignment not in vertical_alignment_mapping:
575
+ raise StreamlitInvalidVerticalAlignmentError(
576
+ vertical_alignment=vertical_alignment,
577
+ element_type="st.columns",
578
+ )
579
+
580
+ gap_size = get_gap_size(gap, "st.columns")
581
+ gap_config = GapConfig()
582
+ gap_config.gap_size = gap_size
583
+
584
+ def column_proto(normalized_weight: float) -> BlockProto:
585
+ col_proto = BlockProto()
586
+ col_proto.column.weight = normalized_weight
587
+ col_proto.column.gap_config.CopyFrom(gap_config)
588
+ col_proto.column.vertical_alignment = vertical_alignment_mapping[
589
+ vertical_alignment
590
+ ]
591
+ col_proto.column.show_border = border
592
+ col_proto.allow_empty = True
593
+ return col_proto
594
+
595
+ block_proto = BlockProto()
596
+ block_proto.flex_container.direction = (
597
+ BlockProto.FlexContainer.Direction.HORIZONTAL
598
+ )
599
+ block_proto.flex_container.wrap = True
600
+ block_proto.flex_container.gap_config.CopyFrom(gap_config)
601
+ block_proto.flex_container.scale = 1
602
+ block_proto.flex_container.align = BlockProto.FlexContainer.Align.STRETCH
603
+
604
+ validate_width(width=width)
605
+ block_proto.width_config.CopyFrom(get_width_config(width=width))
606
+
607
+ row = self.dg._block(block_proto)
608
+ total_weight = sum(weights)
609
+ return [row._block(column_proto(w / total_weight)) for w in weights]
610
+
611
+ @gather_metrics("tabs")
612
+ def tabs(
613
+ self,
614
+ tabs: Sequence[str],
615
+ *,
616
+ width: WidthWithoutContent = "stretch",
617
+ default: str | None = None,
618
+ key: Key | None = None,
619
+ on_change: Literal["ignore", "rerun"] | None = None,
620
+ ) -> Sequence[TabContainer]:
621
+ r"""Insert containers separated into tabs.
622
+
623
+ Inserts a number of multi-element containers as tabs.
624
+ Tabs are a navigational element that allows users to easily
625
+ move between groups of related content.
626
+
627
+ To add elements to the returned containers, you can use the ``with`` notation
628
+ (preferred) or just call methods directly on the returned object. See
629
+ the examples below.
630
+
631
+ .. note::
632
+ By default, all tab content is computed and sent to the frontend
633
+ regardless of which tab is selected. Use ``on_change="rerun"`` to
634
+ enable lazy execution, where only the active tab's content runs.
635
+ Each tab's ``.open`` property indicates whether it is the currently
636
+ active tab, letting you conditionally render expensive content.
637
+
638
+ Parameters
639
+ ----------
640
+ tabs : list of str
641
+ Creates a tab for each string in the list. The first tab is selected
642
+ by default. The string is used as the name of the tab and can
643
+ optionally contain GitHub-flavored Markdown of the following types:
644
+ Bold, Italics, Strikethroughs, Inline Code, Links, and Images.
645
+ Images display like icons, with a max height equal to the font
646
+ height.
647
+
648
+ Unsupported Markdown elements are unwrapped so only their children
649
+ (text contents) render. Display unsupported elements as literal
650
+ characters by backslash-escaping them. E.g.,
651
+ ``"1\. Not an ordered list"``.
652
+
653
+ See the ``body`` parameter of |st.markdown|_ for additional,
654
+ supported Markdown directives.
655
+
656
+ .. |st.markdown| replace:: ``st.markdown``
657
+ .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
658
+
659
+ width : "stretch" or int
660
+ The width of the tab container. This can be one of the following:
661
+
662
+ - ``"stretch"`` (default): The width of the container matches the
663
+ width of the parent container.
664
+ - An integer specifying the width in pixels: The container has a
665
+ fixed width. If the specified width is greater than the width of
666
+ the parent container, the width of the container matches the width
667
+ of the parent container.
668
+
669
+ default : str or None
670
+ The default tab to select. If this is ``None`` (default), the first
671
+ tab is selected. If this is a string, it must be one of the tab
672
+ labels. If two tabs have the same label as ``default``, the first
673
+ one is selected.
674
+
675
+ key : str or int
676
+ An optional string or integer to use as the unique key for the
677
+ widget. If this is omitted, a key will be generated for the widget
678
+ based on its content. No two widgets may have the same key.
679
+
680
+ When ``on_change`` is set to ``"rerun"``, the active tab label is
681
+ also accessible via ``st.session_state[key]``.
682
+
683
+ on_change : "ignore", "rerun", or None
684
+ How the tabs should respond to user tab changes. This controls
685
+ whether tabs track state and trigger reruns when switched.
686
+ ``on_change`` can be one of the following:
687
+
688
+ - ``None`` (default): Current behavior — always execute all tabs,
689
+ no state tracking. The ``.open`` attribute will return ``None``
690
+ for all tabs.
691
+ - ``"ignore"``: Equivalent to ``None`` — no state tracking.
692
+ - ``"rerun"``: Streamlit will rerun the app when the user switches
693
+ tabs. The ``.open`` attribute will return ``True`` for the active
694
+ tab and ``False`` for inactive tabs. Allows lazy execution of
695
+ tab content.
696
+
697
+ Returns
698
+ -------
699
+ Sequence of TabContainers
700
+ A sequence of container objects. Each container is a specialized
701
+ subclass of DeltaGenerator.
702
+
703
+ Examples
704
+ --------
705
+ *Example 1: Use context management*
706
+
707
+ You can use ``with`` notation to insert any element into a tab:
708
+
709
+ >>> import streamlit as st
710
+ >>>
711
+ >>> tab1, tab2, tab3 = st.tabs(["Cat", "Dog", "Owl"])
712
+ >>>
713
+ >>> with tab1:
714
+ ... st.header("A cat")
715
+ ... st.image("https://static.streamlit.io/examples/cat.jpg", width=200)
716
+ >>> with tab2:
717
+ ... st.header("A dog")
718
+ ... st.image("https://static.streamlit.io/examples/dog.jpg", width=200)
719
+ >>> with tab3:
720
+ ... st.header("An owl")
721
+ ... st.image("https://static.streamlit.io/examples/owl.jpg", width=200)
722
+
723
+ .. output::
724
+ https://doc-tabs1.streamlit.app/
725
+ height: 620px
726
+
727
+ *Example 2: Call methods directly*
728
+
729
+ You can call methods directly on the returned objects:
730
+
731
+ >>> import streamlit as st
732
+ >>> from numpy.random import default_rng as rng
733
+ >>>
734
+ >>> df = rng(0).standard_normal((10, 1))
735
+ >>>
736
+ >>> tab1, tab2 = st.tabs(["📈 Chart", "🗃 Data"])
737
+ >>>
738
+ >>> tab1.subheader("A tab with a chart")
739
+ >>> tab1.line_chart(df)
740
+ >>>
741
+ >>> tab2.subheader("A tab with the data")
742
+ >>> tab2.write(df)
743
+
744
+ .. output::
745
+ https://doc-tabs2.streamlit.app/
746
+ height: 700px
747
+
748
+ *Example 3: Set the default tab and style the tab labels*
749
+
750
+ Use the ``default`` parameter to set the default tab. You can also use
751
+ Markdown in the tab labels.
752
+
753
+ >>> import streamlit as st
754
+ >>>
755
+ >>> tab1, tab2, tab3 = st.tabs(
756
+ ... [":cat: Cat", ":dog: Dog", ":rainbow[Owl]"], default=":rainbow[Owl]"
757
+ ... )
758
+ >>>
759
+ >>> with tab1:
760
+ >>> st.header("A cat")
761
+ >>> st.image("https://static.streamlit.io/examples/cat.jpg", width=200)
762
+ >>> with tab2:
763
+ >>> st.header("A dog")
764
+ >>> st.image("https://static.streamlit.io/examples/dog.jpg", width=200)
765
+ >>> with tab3:
766
+ >>> st.header("An owl")
767
+ >>> st.image("https://static.streamlit.io/examples/owl.jpg", width=200)
768
+
769
+ .. output::
770
+ https://doc-tabs3.streamlit.app/
771
+ height: 620px
772
+
773
+ """
774
+ if not tabs:
775
+ raise StreamlitAPIException(
776
+ "The input argument to st.tabs must contain at least one tab label."
777
+ )
778
+
779
+ if default and default not in tabs:
780
+ raise StreamlitAPIException(
781
+ f"The default tab '{default}' is not in the list of tabs."
782
+ )
783
+
784
+ if any(not isinstance(tab, str) for tab in tabs):
785
+ raise StreamlitAPIException(
786
+ "The tabs input list to st.tabs is only allowed to contain strings."
787
+ )
788
+
789
+ if on_change is not None and on_change not in {"ignore", "rerun"}:
790
+ raise StreamlitValueError("on_change", ["'rerun'", "'ignore'", "None"])
791
+
792
+ key = to_key(key)
793
+ default_index = tabs.index(default) if default else 0
794
+ is_stateful = on_change is not None and on_change != "ignore"
795
+
796
+ element_id: str | None = None
797
+ current_tab_label = tabs[default_index]
798
+
799
+ if is_stateful:
800
+ # TODO: Set on_change and enable_check_callback_rules correctly
801
+ # when user-defined callbacks are supported for tabs.
802
+ check_widget_policies(
803
+ self.dg,
804
+ key,
805
+ on_change=None,
806
+ default_value=None,
807
+ writes_allowed=True,
808
+ enable_check_callback_rules=False,
809
+ )
810
+
811
+ ctx = get_script_run_ctx()
812
+
813
+ element_id = compute_and_register_element_id(
814
+ "tabs",
815
+ user_key=key,
816
+ key_as_main_identity=False,
817
+ dg=self.dg,
818
+ tabs=tuple(tabs),
819
+ width=width,
820
+ default=default,
821
+ )
822
+
823
+ serde = _TabsSerde(default_label=tabs[default_index])
824
+
825
+ tabs_state = register_widget(
826
+ element_id,
827
+ deserializer=serde.deserialize,
828
+ serializer=serde.serialize,
829
+ ctx=ctx,
830
+ value_type="string_value",
831
+ )
832
+
833
+ current_tab_label = tabs_state.value
834
+ # Validate that the label exists in the tab list
835
+ if current_tab_label not in tabs:
836
+ current_tab_label = tabs[default_index]
837
+
838
+ def tab_proto(label: str) -> BlockProto:
839
+ tab_proto = BlockProto()
840
+ tab_proto.tab.label = label
841
+ tab_proto.allow_empty = True
842
+ return tab_proto
843
+
844
+ block_proto = BlockProto()
845
+ block_proto.tab_container.SetInParent()
846
+ validate_width(width)
847
+ block_proto.width_config.CopyFrom(get_width_config(width))
848
+
849
+ # Compute the current tab index from the label
850
+ try:
851
+ current_tab_index = tabs.index(current_tab_label)
852
+ except ValueError:
853
+ current_tab_index = default_index
854
+
855
+ block_proto.tab_container.default_tab_index = current_tab_index
856
+
857
+ if is_stateful and element_id is not None:
858
+ block_proto.tab_container.id = element_id
859
+
860
+ tab_cls = get_dg_singleton_instance().tab_container_cls
861
+ tab_container = self.dg._block(block_proto)
862
+
863
+ tab_dgs: list[TabContainer] = []
864
+ for tab_label in tabs:
865
+ tab_dg = cast(
866
+ "TabContainer",
867
+ tab_container._block(tab_proto(tab_label), dg_type=tab_cls),
868
+ )
869
+ if is_stateful:
870
+ tab_dg.open = tab_label == current_tab_label
871
+ tab_dgs.append(tab_dg)
872
+
873
+ return tuple(tab_dgs)
874
+
875
+ @gather_metrics("expander")
876
+ def expander(
877
+ self,
878
+ label: str,
879
+ expanded: bool = False,
880
+ *,
881
+ key: Key | None = None,
882
+ icon: str | None = None,
883
+ width: WidthWithoutContent = "stretch",
884
+ on_change: Literal["ignore", "rerun"] = "ignore",
885
+ ) -> ExpanderContainer:
886
+ r"""Insert a multi-element container that can be expanded/collapsed.
887
+
888
+ Inserts a container into your app that can be used to hold multiple elements
889
+ and can be expanded or collapsed by the user. When collapsed, all that is
890
+ visible is the provided label.
891
+
892
+ To add elements to the returned container, you can use the ``with`` notation
893
+ (preferred) or just call methods directly on the returned object. See
894
+ examples below.
895
+
896
+ .. note::
897
+ All content within the expander is computed and sent to the
898
+ frontend, even if the expander is closed.
899
+
900
+ To follow best design practices and maintain a good appearance on
901
+ all screen sizes, don't nest expanders.
902
+
903
+ Parameters
904
+ ----------
905
+ label : str
906
+ A string to use as the header for the expander. The label can optionally
907
+ contain GitHub-flavored Markdown of the following types: Bold, Italics,
908
+ Strikethroughs, Inline Code, Links, and Images. Images display like
909
+ icons, with a max height equal to the font height.
910
+
911
+ Unsupported Markdown elements are unwrapped so only their children
912
+ (text contents) render. Display unsupported elements as literal
913
+ characters by backslash-escaping them. E.g.,
914
+ ``"1\. Not an ordered list"``.
915
+
916
+ See the ``body`` parameter of |st.markdown|_ for additional,
917
+ supported Markdown directives.
918
+
919
+ .. |st.markdown| replace:: ``st.markdown``
920
+ .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
921
+
922
+ expanded : bool
923
+ If True, initializes the expander in "expanded" state. Defaults to
924
+ False (collapsed).
925
+
926
+ key : str or int
927
+ An optional string or integer to use as the unique key for the
928
+ widget. Only used when ``on_change`` is set to ``"rerun"``.
929
+ If this is omitted, a key will be generated for the widget
930
+ based on its content. No two widgets may have the same key.
931
+
932
+ If ``key`` is provided along with ``on_change="rerun"``, it will
933
+ also be used as a CSS class name prefixed with ``st-key-``, and
934
+ the expanded state is accessible via ``st.session_state[key]``.
935
+
936
+ icon : str, None
937
+ An optional emoji or icon to display next to the expander label. If ``icon``
938
+ is ``None`` (default), no icon is displayed. If ``icon`` is a
939
+ string, the following options are valid:
940
+
941
+ - A single-character emoji. For example, you can set ``icon="🚨"``
942
+ or ``icon="🔥"``. Emoji short codes are not supported.
943
+
944
+ - An icon from the Material Symbols library (rounded style) in the
945
+ format ``":material/icon_name:"`` where "icon_name" is the name
946
+ of the icon in snake case.
947
+
948
+ For example, ``icon=":material/thumb_up:"`` will display the
949
+ Thumb Up icon. Find additional icons in the `Material Symbols \
950
+ <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
951
+ font library.
952
+
953
+ - ``"spinner"``: Displays a spinner as an icon.
954
+
955
+ width : "stretch" or int
956
+ The width of the expander container. This can be one of the following:
957
+
958
+ - ``"stretch"`` (default): The width of the container matches the
959
+ width of the parent container.
960
+ - An integer specifying the width in pixels: The container has a
961
+ fixed width. If the specified width is greater than the width of
962
+ the parent container, the width of the container matches the width
963
+ of the parent container.
964
+
965
+ on_change : "ignore" or "rerun"
966
+ How the expander should respond to user toggle events. This controls
967
+ whether the expander tracks state and triggers reruns when toggled.
968
+ ``on_change`` can be one of the following:
969
+
970
+ - ``"ignore"`` (default): Streamlit will not track the expander's
971
+ state. The ``.open`` attribute will return ``None``. The expander
972
+ can be used inside ``@st.cache_data`` decorated functions.
973
+
974
+ - ``"rerun"``: Streamlit will rerun the app when the user expands
975
+ or collapses the expander. The ``.open`` attribute will return
976
+ the current state (``True`` if expanded, ``False`` if collapsed).
977
+ The expander cannot be used inside ``@st.cache_data`` decorated
978
+ functions.
979
+
980
+ Examples
981
+ --------
982
+ You can use the ``with`` notation to insert any element into an expander
983
+
984
+ >>> import streamlit as st
985
+ >>>
986
+ >>> st.bar_chart({"data": [1, 5, 2, 6, 2, 1]})
987
+ >>>
988
+ >>> with st.expander("See explanation"):
989
+ ... st.write('''
990
+ ... The chart above shows some numbers I picked for you.
991
+ ... I rolled actual dice for these, so they're *guaranteed* to
992
+ ... be random.
993
+ ... ''')
994
+ ... st.image("https://static.streamlit.io/examples/dice.jpg")
995
+
996
+ .. output::
997
+ https://doc-expander.streamlit.app/
998
+ height: 750px
999
+
1000
+ Or you can just call methods directly on the returned objects:
1001
+
1002
+ >>> import streamlit as st
1003
+ >>>
1004
+ >>> st.bar_chart({"data": [1, 5, 2, 6, 2, 1]})
1005
+ >>>
1006
+ >>> expander = st.expander("See explanation")
1007
+ >>> expander.write('''
1008
+ ... The chart above shows some numbers I picked for you.
1009
+ ... I rolled actual dice for these, so they're *guaranteed* to
1010
+ ... be random.
1011
+ ... ''')
1012
+ >>> expander.image("https://static.streamlit.io/examples/dice.jpg")
1013
+
1014
+ .. output::
1015
+ https://doc-expander.streamlit.app/
1016
+ height: 750px
1017
+
1018
+ """
1019
+ if label is None:
1020
+ raise StreamlitAPIException("A label is required for an expander")
1021
+
1022
+ if on_change not in {"ignore", "rerun"}:
1023
+ raise StreamlitValueError("on_change", ["'rerun'", "'ignore'"])
1024
+
1025
+ key = to_key(key)
1026
+ is_stateful = on_change == "rerun"
1027
+
1028
+ current_expanded = expanded
1029
+ element_id: str | None = None
1030
+
1031
+ if is_stateful:
1032
+ # TODO: Set on_change and enable_check_callback_rules correctly
1033
+ # when user-defined callbacks are supported for expanders.
1034
+ check_widget_policies(
1035
+ self.dg,
1036
+ key,
1037
+ on_change=None,
1038
+ default_value=None,
1039
+ writes_allowed=True,
1040
+ enable_check_callback_rules=False,
1041
+ )
1042
+
1043
+ ctx = get_script_run_ctx()
1044
+
1045
+ element_id = compute_and_register_element_id(
1046
+ "expander",
1047
+ user_key=key,
1048
+ key_as_main_identity=False,
1049
+ dg=self.dg,
1050
+ label=label,
1051
+ expanded=expanded,
1052
+ icon=icon,
1053
+ width=width,
1054
+ )
1055
+
1056
+ serde = _ExpanderSerde(expanded=expanded)
1057
+
1058
+ expander_state = register_widget(
1059
+ element_id,
1060
+ deserializer=serde.deserialize,
1061
+ serializer=serde.serialize,
1062
+ ctx=ctx,
1063
+ value_type="bool_value",
1064
+ )
1065
+
1066
+ current_expanded = expander_state.value
1067
+ expandable_proto = BlockProto.Expandable()
1068
+ expandable_proto.expanded = current_expanded
1069
+ expandable_proto.label = label
1070
+ if icon is not None:
1071
+ expandable_proto.icon = validate_icon_or_emoji(icon)
1072
+
1073
+ if is_stateful and element_id is not None:
1074
+ expandable_proto.id = element_id
1075
+
1076
+ block_proto = BlockProto()
1077
+ block_proto.allow_empty = True
1078
+ if element_id is not None:
1079
+ block_proto.id = element_id
1080
+ block_proto.expandable.CopyFrom(expandable_proto)
1081
+ validate_width(width)
1082
+ block_proto.width_config.CopyFrom(get_width_config(width))
1083
+
1084
+ expander_dg = cast(
1085
+ "ExpanderContainer",
1086
+ self.dg._block(
1087
+ block_proto=block_proto,
1088
+ dg_type=get_dg_singleton_instance().expander_container_cls,
1089
+ ),
1090
+ )
1091
+
1092
+ if is_stateful:
1093
+ expander_dg.open = current_expanded
1094
+
1095
+ return expander_dg
1096
+
1097
+ @gather_metrics("popover")
1098
+ def popover(
1099
+ self,
1100
+ label: str,
1101
+ *,
1102
+ type: Literal["primary", "secondary", "tertiary"] = "secondary",
1103
+ help: str | None = None,
1104
+ icon: str | None = None,
1105
+ disabled: bool = False,
1106
+ use_container_width: bool | None = None,
1107
+ width: Width = "content",
1108
+ key: Key | None = None,
1109
+ on_change: Literal["ignore", "rerun"] = "ignore",
1110
+ ) -> PopoverContainer:
1111
+ r"""Insert a popover container.
1112
+
1113
+ Inserts a multi-element container as a popover. It consists of a button-like
1114
+ element and a container that opens when the button is clicked.
1115
+
1116
+ By default, opening and closing the popover will not trigger a rerun.
1117
+ Use ``on_change="rerun"`` to trigger a rerun when the popover is
1118
+ opened or closed. Each popover's ``.open`` property indicates whether
1119
+ it is currently open, letting you conditionally render content.
1120
+ Interacting with widgets inside of an open popover will rerun the
1121
+ app while keeping the popover open. Clicking outside of the popover
1122
+ will close it.
1123
+
1124
+ To add elements to the returned container, you can use the "with"
1125
+ notation (preferred) or just call methods directly on the returned object.
1126
+ See examples below.
1127
+
1128
+ .. note::
1129
+ To follow best design practices, don't nest popovers.
1130
+
1131
+ Parameters
1132
+ ----------
1133
+ label : str
1134
+ The label of the button that opens the popover container.
1135
+ The label can optionally contain GitHub-flavored Markdown of the
1136
+ following types: Bold, Italics, Strikethroughs, Inline Code, Links,
1137
+ and Images. Images display like icons, with a max height equal to
1138
+ the font height.
1139
+
1140
+ Unsupported Markdown elements are unwrapped so only their children
1141
+ (text contents) render. Display unsupported elements as literal
1142
+ characters by backslash-escaping them. E.g.,
1143
+ ``"1\. Not an ordered list"``.
1144
+
1145
+ See the ``body`` parameter of |st.markdown|_ for additional,
1146
+ supported Markdown directives.
1147
+
1148
+ .. |st.markdown| replace:: ``st.markdown``
1149
+ .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
1150
+
1151
+ help : str or None
1152
+ A tooltip that gets displayed when the popover button is hovered
1153
+ over. If this is ``None`` (default), no tooltip is displayed.
1154
+
1155
+ The tooltip can optionally contain GitHub-flavored Markdown,
1156
+ including the Markdown directives described in the ``body``
1157
+ parameter of ``st.markdown``.
1158
+
1159
+ type : "primary", "secondary", or "tertiary"
1160
+ An optional string that specifies the button type. This can be one
1161
+ of the following:
1162
+
1163
+ - ``"primary"``: The button's background is the app's primary color
1164
+ for additional emphasis.
1165
+ - ``"secondary"`` (default): The button's background coordinates
1166
+ with the app's background color for normal emphasis.
1167
+ - ``"tertiary"``: The button is plain text without a border or
1168
+ background for subtlety.
1169
+
1170
+ icon : str
1171
+ An optional emoji or icon to display next to the button label. If ``icon``
1172
+ is ``None`` (default), no icon is displayed. If ``icon`` is a
1173
+ string, the following options are valid:
1174
+
1175
+ - A single-character emoji. For example, you can set ``icon="🚨"``
1176
+ or ``icon="🔥"``. Emoji short codes are not supported.
1177
+
1178
+ - An icon from the Material Symbols library (rounded style) in the
1179
+ format ``":material/icon_name:"`` where "icon_name" is the name
1180
+ of the icon in snake case.
1181
+
1182
+ For example, ``icon=":material/thumb_up:"`` will display the
1183
+ Thumb Up icon. Find additional icons in the `Material Symbols \
1184
+ <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
1185
+ font library.
1186
+
1187
+ - ``"spinner"``: Displays a spinner as an icon.
1188
+
1189
+ disabled : bool
1190
+ An optional boolean that disables the popover button if set to
1191
+ ``True``. The default is ``False``.
1192
+
1193
+ use_container_width : bool
1194
+ Whether to expand the button's width to fill its parent container.
1195
+ If ``use_container_width`` is ``False`` (default), Streamlit sizes
1196
+ the button to fit its content. If ``use_container_width`` is
1197
+ ``True``, the width of the button matches its parent container.
1198
+
1199
+ In both cases, if the content of the button is wider than the
1200
+ parent container, the content will line wrap.
1201
+
1202
+ The popover container's minimum width matches the width of its
1203
+ button. The popover container may be wider than its button to fit
1204
+ the container's content.
1205
+
1206
+ .. deprecated::
1207
+ ``use_container_width`` is deprecated and will be removed in a
1208
+ future release. For ``use_container_width=True``, use
1209
+ ``width="stretch"``. For ``use_container_width=False``, use
1210
+ ``width="content"``.
1211
+
1212
+ width : int, "stretch", or "content"
1213
+ The width of the button. This can be one of the following:
1214
+
1215
+ - ``"content"`` (default): The width of the button matches the
1216
+ width of its content, but doesn't exceed the width of the parent
1217
+ container.
1218
+ - ``"stretch"``: The width of the button matches the width of the
1219
+ parent container.
1220
+ - An integer specifying the width in pixels: The button has a
1221
+ fixed width. If the specified width is greater than the width of
1222
+ the parent container, the width of the button matches the width
1223
+ of the parent container.
1224
+
1225
+ The popover container's minimum width matches the width of its
1226
+ button. The popover container may be wider than its button to fit
1227
+ the container's contents.
1228
+
1229
+ key : str or int
1230
+ An optional string or integer to use as the unique key for the
1231
+ widget. If this is omitted, a key will be generated for the widget
1232
+ based on its content. No two widgets may have the same key.
1233
+
1234
+ When ``on_change`` is set to ``"rerun"``, the open/closed state
1235
+ is also accessible via ``st.session_state[key]``.
1236
+
1237
+ on_change : "ignore" or "rerun"
1238
+ How the popover should respond to user open/close events. This
1239
+ controls whether the popover tracks state and triggers reruns.
1240
+ ``on_change`` can be one of the following:
1241
+
1242
+ - ``"ignore"`` (default): Streamlit will not track the popover's
1243
+ state. The ``.open`` attribute will return ``None``. The popover
1244
+ can be used inside ``@st.cache_data`` decorated functions.
1245
+
1246
+ - ``"rerun"``: Streamlit will rerun the app when the user opens or
1247
+ closes the popover. The ``.open`` attribute will return the
1248
+ current state (``True`` if open, ``False`` if closed). The
1249
+ popover cannot be used inside ``@st.cache_data`` decorated
1250
+ functions.
1251
+
1252
+ Examples
1253
+ --------
1254
+ You can use the ``with`` notation to insert any element into a popover:
1255
+
1256
+ >>> import streamlit as st
1257
+ >>>
1258
+ >>> with st.popover("Open popover"):
1259
+ >>> st.markdown("Hello World 👋")
1260
+ >>> name = st.text_input("What's your name?")
1261
+ >>>
1262
+ >>> st.write("Your name:", name)
1263
+
1264
+ .. output::
1265
+ https://doc-popover.streamlit.app/
1266
+ height: 400px
1267
+
1268
+ Or you can just call methods directly on the returned objects:
1269
+
1270
+ >>> import streamlit as st
1271
+ >>>
1272
+ >>> popover = st.popover("Filter items")
1273
+ >>> red = popover.checkbox("Show red items.", True)
1274
+ >>> blue = popover.checkbox("Show blue items.", True)
1275
+ >>>
1276
+ >>> if red:
1277
+ ... st.write(":red[This is a red item.]")
1278
+ >>> if blue:
1279
+ ... st.write(":blue[This is a blue item.]")
1280
+
1281
+ .. output::
1282
+ https://doc-popover2.streamlit.app/
1283
+ height: 400px
1284
+
1285
+ """
1286
+ if label is None:
1287
+ raise StreamlitAPIException("A label is required for a popover")
1288
+
1289
+ if use_container_width is not None:
1290
+ width = "stretch" if use_container_width else "content"
1291
+
1292
+ # Checks whether the entered button type is one of the allowed options
1293
+ if type not in {"primary", "secondary", "tertiary"}:
1294
+ raise StreamlitAPIException(
1295
+ 'The type argument to st.popover must be "primary", "secondary", or "tertiary". '
1296
+ f'\nThe argument passed was "{type}".'
1297
+ )
1298
+
1299
+ if on_change not in {"ignore", "rerun"}:
1300
+ raise StreamlitValueError("on_change", ["'rerun'", "'ignore'"])
1301
+
1302
+ key = to_key(key)
1303
+ is_stateful = on_change == "rerun"
1304
+
1305
+ current_open = False
1306
+ element_id: str | None = None
1307
+
1308
+ if is_stateful:
1309
+ # TODO: Set on_change and enable_check_callback_rules correctly
1310
+ # when user-defined callbacks are supported for popovers.
1311
+ check_widget_policies(
1312
+ self.dg,
1313
+ key,
1314
+ on_change=None,
1315
+ default_value=None,
1316
+ writes_allowed=True,
1317
+ enable_check_callback_rules=False,
1318
+ )
1319
+
1320
+ ctx = get_script_run_ctx()
1321
+
1322
+ element_id = compute_and_register_element_id(
1323
+ "popover",
1324
+ user_key=key,
1325
+ key_as_main_identity=False,
1326
+ dg=self.dg,
1327
+ label=label,
1328
+ type=type,
1329
+ help=help,
1330
+ icon=icon,
1331
+ disabled=disabled,
1332
+ width=width,
1333
+ )
1334
+
1335
+ serde = _PopoverSerde()
1336
+
1337
+ popover_state = register_widget(
1338
+ element_id,
1339
+ deserializer=serde.deserialize,
1340
+ serializer=serde.serialize,
1341
+ ctx=ctx,
1342
+ value_type="bool_value",
1343
+ )
1344
+
1345
+ current_open = popover_state.value
1346
+
1347
+ popover_proto = BlockProto.Popover()
1348
+ popover_proto.label = label
1349
+ popover_proto.disabled = disabled
1350
+ popover_proto.type = type
1351
+ popover_proto.open = current_open
1352
+ if help:
1353
+ popover_proto.help = str(help)
1354
+ if icon is not None:
1355
+ popover_proto.icon = validate_icon_or_emoji(icon)
1356
+
1357
+ if is_stateful and element_id is not None:
1358
+ popover_proto.id = element_id
1359
+
1360
+ block_proto = BlockProto()
1361
+ block_proto.allow_empty = True
1362
+ block_proto.popover.CopyFrom(popover_proto)
1363
+
1364
+ validate_width(width, allow_content=True)
1365
+ block_proto.width_config.CopyFrom(get_width_config(width))
1366
+
1367
+ popover_dg = cast(
1368
+ "PopoverContainer",
1369
+ self.dg._block(
1370
+ block_proto=block_proto,
1371
+ dg_type=get_dg_singleton_instance().popover_container_cls,
1372
+ ),
1373
+ )
1374
+
1375
+ if is_stateful:
1376
+ popover_dg.open = current_open
1377
+
1378
+ return popover_dg
1379
+
1380
+ @gather_metrics("status")
1381
+ def status(
1382
+ self,
1383
+ label: str,
1384
+ *,
1385
+ expanded: bool = False,
1386
+ state: Literal["running", "complete", "error"] = "running",
1387
+ width: WidthWithoutContent = "stretch",
1388
+ ) -> StatusContainer:
1389
+ r"""Insert a status container to display output from long-running tasks.
1390
+
1391
+ Inserts a container into your app that is typically used to show the status and
1392
+ details of a process or task. The container can hold multiple elements and can
1393
+ be expanded or collapsed by the user similar to ``st.expander``.
1394
+ When collapsed, all that is visible is the status icon and label.
1395
+
1396
+ The label, state, and expanded state can all be updated by calling ``.update()``
1397
+ on the returned object. To add elements to the returned container, you can
1398
+ use ``with`` notation (preferred) or just call methods directly on the returned
1399
+ object.
1400
+
1401
+ By default, ``st.status()`` initializes in the "running" state. When called using
1402
+ ``with`` notation, it automatically updates to the "complete" state at the end
1403
+ of the "with" block. See examples below for more details.
1404
+
1405
+ .. note::
1406
+ All content within the status container is computed and sent to the
1407
+ frontend, even if the status container is closed.
1408
+
1409
+ To follow best design practices and maintain a good appearance on
1410
+ all screen sizes, don't nest status containers.
1411
+
1412
+ Parameters
1413
+ ----------
1414
+ label : str
1415
+ The initial label of the status container. The label can optionally
1416
+ contain GitHub-flavored Markdown of the following types: Bold, Italics,
1417
+ Strikethroughs, Inline Code, Links, and Images. Images display like
1418
+ icons, with a max height equal to the font height.
1419
+
1420
+ Unsupported Markdown elements are unwrapped so only their children
1421
+ (text contents) render. Display unsupported elements as literal
1422
+ characters by backslash-escaping them. E.g.,
1423
+ ``"1\. Not an ordered list"``.
1424
+
1425
+ See the ``body`` parameter of |st.markdown|_ for additional,
1426
+ supported Markdown directives.
1427
+
1428
+ .. |st.markdown| replace:: ``st.markdown``
1429
+ .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
1430
+
1431
+ expanded : bool
1432
+ If True, initializes the status container in "expanded" state. Defaults to
1433
+ False (collapsed).
1434
+
1435
+ state : "running", "complete", or "error"
1436
+ The initial state of the status container which determines which icon is
1437
+ shown:
1438
+
1439
+ - ``running`` (default): A spinner icon is shown.
1440
+ - ``complete``: A checkmark icon is shown.
1441
+ - ``error``: An error icon is shown.
1442
+
1443
+ width : "stretch" or int
1444
+ The width of the status container. This can be one of the following:
1445
+
1446
+ - ``"stretch"`` (default): The width of the container matches the
1447
+ width of the parent container.
1448
+ - An integer specifying the width in pixels: The container has a
1449
+ fixed width. If the specified width is greater than the width of
1450
+ the parent container, the width of the container matches the width
1451
+ of the parent container.
1452
+
1453
+ Returns
1454
+ -------
1455
+ StatusContainer
1456
+ A mutable status container that can hold multiple elements. The label, state,
1457
+ and expanded state can be updated after creation via ``.update()``.
1458
+
1459
+ Examples
1460
+ --------
1461
+ You can use the ``with`` notation to insert any element into an status container:
1462
+
1463
+ >>> import time
1464
+ >>> import streamlit as st
1465
+ >>>
1466
+ >>> with st.status("Downloading data..."):
1467
+ ... st.write("Searching for data...")
1468
+ ... time.sleep(2)
1469
+ ... st.write("Found URL.")
1470
+ ... time.sleep(1)
1471
+ ... st.write("Downloading data...")
1472
+ ... time.sleep(1)
1473
+ >>>
1474
+ >>> st.button("Rerun")
1475
+
1476
+ .. output::
1477
+ https://doc-status.streamlit.app/
1478
+ height: 300px
1479
+
1480
+ You can also use ``.update()`` on the container to change the label, state,
1481
+ or expanded state:
1482
+
1483
+ >>> import time
1484
+ >>> import streamlit as st
1485
+ >>>
1486
+ >>> with st.status("Downloading data...", expanded=True) as status:
1487
+ ... st.write("Searching for data...")
1488
+ ... time.sleep(2)
1489
+ ... st.write("Found URL.")
1490
+ ... time.sleep(1)
1491
+ ... st.write("Downloading data...")
1492
+ ... time.sleep(1)
1493
+ ... status.update(
1494
+ ... label="Download complete!", state="complete", expanded=False
1495
+ ... )
1496
+ >>>
1497
+ >>> st.button("Rerun")
1498
+
1499
+ .. output::
1500
+ https://doc-status-update.streamlit.app/
1501
+ height: 300px
1502
+
1503
+ """
1504
+ return get_dg_singleton_instance().status_container_cls._create(
1505
+ self.dg, label, expanded=expanded, state=state, width=width
1506
+ )
1507
+
1508
+ def _dialog(
1509
+ self,
1510
+ title: str,
1511
+ *,
1512
+ dismissible: bool = True,
1513
+ width: Literal["small", "large", "medium"] = "small",
1514
+ icon: str | None = None,
1515
+ on_dismiss: Literal["ignore", "rerun"] | WidgetCallback = "ignore",
1516
+ ) -> Dialog:
1517
+ """Inserts the dialog container.
1518
+
1519
+ Marked as internal because it is used by the dialog_decorator and is not supposed to be used directly.
1520
+ The dialog_decorator also has a more descriptive docstring since it is user-facing.
1521
+ """
1522
+ return get_dg_singleton_instance().dialog_container_cls._create(
1523
+ self.dg,
1524
+ title,
1525
+ dismissible=dismissible,
1526
+ width=width,
1527
+ icon=icon,
1528
+ on_dismiss=on_dismiss,
1529
+ )
1530
+
1531
+ @property
1532
+ def dg(self) -> DeltaGenerator:
1533
+ """Get our DeltaGenerator."""
1534
+ return cast("DeltaGenerator", self)