streamlit 1.45.1__py3-none-any.whl → 1.46.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/__init__.py +5 -1
- streamlit/auth_util.py +12 -12
- streamlit/cli_util.py +4 -3
- streamlit/column_config.py +11 -9
- streamlit/commands/echo.py +6 -4
- streamlit/commands/execution_control.py +33 -32
- streamlit/commands/experimental_query_params.py +2 -2
- streamlit/commands/logo.py +9 -4
- streamlit/commands/navigation.py +61 -18
- streamlit/commands/page_config.py +57 -47
- streamlit/components/types/base_custom_component.py +7 -7
- streamlit/components/v1/component_registry.py +7 -3
- streamlit/components/v1/components.py +1 -1
- streamlit/components/v1/custom_component.py +8 -8
- streamlit/config.py +289 -144
- streamlit/config_option.py +19 -15
- streamlit/config_util.py +29 -23
- streamlit/connections/__init__.py +2 -2
- streamlit/connections/base_connection.py +5 -5
- streamlit/connections/snowflake_connection.py +13 -11
- streamlit/connections/snowpark_connection.py +3 -3
- streamlit/connections/sql_connection.py +20 -18
- streamlit/connections/util.py +2 -2
- streamlit/cursor.py +6 -6
- streamlit/dataframe_util.py +52 -52
- streamlit/delta_generator.py +46 -48
- streamlit/delta_generator_singletons.py +3 -3
- streamlit/deprecation_util.py +6 -6
- streamlit/elements/alert.py +37 -29
- streamlit/elements/arrow.py +40 -22
- streamlit/elements/code.py +46 -13
- streamlit/elements/deck_gl_json_chart.py +38 -27
- streamlit/elements/dialog_decorator.py +3 -4
- streamlit/elements/doc_string.py +64 -58
- streamlit/elements/exception.py +23 -27
- streamlit/elements/form.py +41 -0
- streamlit/elements/graphviz_chart.py +1 -1
- streamlit/elements/heading.py +60 -9
- streamlit/elements/html.py +3 -4
- streamlit/elements/image.py +8 -9
- streamlit/elements/json.py +21 -2
- streamlit/elements/layouts.py +120 -31
- streamlit/elements/lib/built_in_chart_utils.py +96 -73
- streamlit/elements/lib/color_util.py +3 -3
- streamlit/elements/lib/column_config_utils.py +2 -4
- streamlit/elements/lib/column_types.py +14 -8
- streamlit/elements/lib/dialog.py +9 -5
- streamlit/elements/lib/image_utils.py +39 -40
- streamlit/elements/lib/js_number.py +4 -4
- streamlit/elements/lib/layout_utils.py +65 -1
- streamlit/elements/lib/mutable_status_container.py +14 -3
- streamlit/elements/lib/options_selector_utils.py +22 -12
- streamlit/elements/lib/pandas_styler_utils.py +25 -21
- streamlit/elements/lib/policies.py +6 -5
- streamlit/elements/lib/streamlit_plotly_theme.py +54 -53
- streamlit/elements/lib/subtitle_utils.py +6 -9
- streamlit/elements/lib/utils.py +20 -5
- streamlit/elements/map.py +32 -56
- streamlit/elements/markdown.py +101 -12
- streamlit/elements/media.py +78 -21
- streamlit/elements/metric.py +32 -16
- streamlit/elements/plotly_chart.py +15 -15
- streamlit/elements/progress.py +33 -15
- streamlit/elements/spinner.py +31 -6
- streamlit/elements/text.py +21 -1
- streamlit/elements/toast.py +1 -2
- streamlit/elements/vega_charts.py +54 -23
- streamlit/elements/widgets/audio_input.py +24 -7
- streamlit/elements/widgets/button.py +26 -19
- streamlit/elements/widgets/button_group.py +10 -15
- streamlit/elements/widgets/camera_input.py +27 -7
- streamlit/elements/widgets/chat.py +91 -38
- streamlit/elements/widgets/checkbox.py +45 -4
- streamlit/elements/widgets/color_picker.py +40 -17
- streamlit/elements/widgets/data_editor.py +76 -37
- streamlit/elements/widgets/file_uploader.py +42 -13
- streamlit/elements/widgets/multiselect.py +7 -10
- streamlit/elements/widgets/number_input.py +123 -47
- streamlit/elements/widgets/radio.py +59 -13
- streamlit/elements/widgets/select_slider.py +35 -30
- streamlit/elements/widgets/selectbox.py +56 -9
- streamlit/elements/widgets/slider.py +190 -99
- streamlit/elements/widgets/text_widgets.py +54 -8
- streamlit/elements/widgets/time_widgets.py +53 -14
- streamlit/elements/write.py +5 -8
- streamlit/env_util.py +2 -7
- streamlit/error_util.py +16 -9
- streamlit/errors.py +69 -48
- streamlit/external/langchain/streamlit_callback_handler.py +10 -5
- streamlit/file_util.py +27 -10
- streamlit/git_util.py +29 -24
- streamlit/hello/animation_demo.py +9 -9
- streamlit/hello/dataframe_demo.py +5 -5
- streamlit/hello/hello.py +1 -0
- streamlit/hello/mapping_demo.py +7 -8
- streamlit/hello/plotting_demo.py +3 -3
- streamlit/hello/streamlit_app.py +28 -26
- streamlit/hello/utils.py +2 -1
- streamlit/logger.py +10 -11
- streamlit/navigation/page.py +11 -8
- streamlit/proto/Audio_pb2.py +4 -3
- streamlit/proto/Audio_pb2.pyi +8 -1
- streamlit/proto/Block_pb2.py +38 -29
- streamlit/proto/Block_pb2.pyi +72 -4
- streamlit/proto/ClientState_pb2.py +4 -4
- streamlit/proto/ClientState_pb2.pyi +7 -2
- streamlit/proto/Code_pb2.py +4 -2
- streamlit/proto/Code_pb2.pyi +1 -0
- streamlit/proto/DataFrame_pb2.pyi +1 -1
- streamlit/proto/DeckGlJsonChart_pb2.pyi +1 -1
- streamlit/proto/Element_pb2.py +5 -3
- streamlit/proto/Element_pb2.pyi +20 -3
- streamlit/proto/GapSize_pb2.py +29 -0
- streamlit/proto/GapSize_pb2.pyi +70 -0
- streamlit/proto/HeightConfig_pb2.py +27 -0
- streamlit/proto/HeightConfig_pb2.pyi +48 -0
- streamlit/proto/NamedDataSet_pb2.pyi +1 -1
- streamlit/proto/Navigation_pb2.py +3 -3
- streamlit/proto/Navigation_pb2.pyi +4 -0
- streamlit/proto/NewSession_pb2.py +18 -16
- streamlit/proto/NewSession_pb2.pyi +29 -3
- streamlit/proto/PageConfig_pb2.py +7 -7
- streamlit/proto/PageConfig_pb2.pyi +21 -1
- streamlit/proto/Video_pb2.py +8 -7
- streamlit/proto/Video_pb2.pyi +8 -1
- streamlit/proto/WidthConfig_pb2.py +2 -2
- streamlit/proto/WidthConfig_pb2.pyi +15 -1
- streamlit/runtime/__init__.py +1 -1
- streamlit/runtime/app_session.py +53 -40
- streamlit/runtime/caching/__init__.py +9 -9
- streamlit/runtime/caching/cache_data_api.py +36 -30
- streamlit/runtime/caching/cache_errors.py +4 -4
- streamlit/runtime/caching/cache_resource_api.py +8 -8
- streamlit/runtime/caching/cache_utils.py +15 -14
- streamlit/runtime/caching/cached_message_replay.py +14 -8
- streamlit/runtime/caching/hashing.py +91 -97
- streamlit/runtime/caching/legacy_cache_api.py +2 -2
- streamlit/runtime/caching/storage/cache_storage_protocol.py +1 -1
- streamlit/runtime/caching/storage/dummy_cache_storage.py +1 -1
- streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py +12 -14
- streamlit/runtime/caching/storage/local_disk_cache_storage.py +6 -6
- streamlit/runtime/connection_factory.py +36 -36
- streamlit/runtime/context.py +58 -9
- streamlit/runtime/credentials.py +29 -40
- streamlit/runtime/forward_msg_queue.py +11 -11
- streamlit/runtime/fragment.py +7 -7
- streamlit/runtime/media_file_manager.py +3 -4
- streamlit/runtime/memory_media_file_storage.py +6 -5
- streamlit/runtime/memory_uploaded_file_manager.py +2 -2
- streamlit/runtime/metrics_util.py +11 -12
- streamlit/runtime/pages_manager.py +4 -6
- streamlit/runtime/runtime.py +8 -6
- streamlit/runtime/runtime_util.py +7 -6
- streamlit/runtime/scriptrunner/__init__.py +4 -4
- streamlit/runtime/scriptrunner/exec_code.py +12 -5
- streamlit/runtime/scriptrunner/magic.py +16 -12
- streamlit/runtime/scriptrunner/script_cache.py +1 -1
- streamlit/runtime/scriptrunner/script_runner.py +53 -29
- streamlit/runtime/scriptrunner_utils/exceptions.py +1 -1
- streamlit/runtime/scriptrunner_utils/script_requests.py +7 -4
- streamlit/runtime/scriptrunner_utils/script_run_context.py +10 -23
- streamlit/runtime/secrets.py +40 -35
- streamlit/runtime/session_manager.py +2 -1
- streamlit/runtime/state/__init__.py +5 -5
- streamlit/runtime/state/common.py +2 -2
- streamlit/runtime/state/query_params.py +13 -15
- streamlit/runtime/state/query_params_proxy.py +17 -13
- streamlit/runtime/state/safe_session_state.py +2 -2
- streamlit/runtime/state/session_state.py +52 -34
- streamlit/runtime/stats.py +2 -2
- streamlit/runtime/uploaded_file_manager.py +1 -1
- streamlit/runtime/websocket_session_manager.py +10 -6
- streamlit/source_util.py +8 -6
- streamlit/static/index.html +3 -17
- streamlit/static/manifest.json +1180 -0
- streamlit/static/static/css/{index.DqDwtg6_.css → index.CJVRHjQZ.css} +1 -1
- streamlit/static/static/js/{ErrorOutline.esm.DU9IrB3M.js → ErrorOutline.esm.6PVAQvlT.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.P9rKwKo8.js → FileDownload.esm.BZQHC61b.js} +1 -1
- streamlit/static/static/js/{FileHelper.D7RMkx0e.js → FileHelper.Bn1VShMJ.js} +5 -5
- streamlit/static/static/js/{FormClearHelper.B67tgll0.js → FormClearHelper.CsFEiTNN.js} +1 -1
- streamlit/static/static/js/{Hooks.ncTJktu9.js → Hooks.DguOHQL1.js} +1 -1
- streamlit/static/static/js/{InputInstructions.D-Y8geDN.js → InputInstructions.CTYn2BJQ.js} +1 -1
- streamlit/static/static/js/{ProgressBar.B-kexwwD.js → ProgressBar.CPOGBKCi.js} +2 -2
- streamlit/static/static/js/{RenderInPortalIfExists.BgaoZgep.js → RenderInPortalIfExists.BYu_CZaF.js} +1 -1
- streamlit/static/static/js/Toolbar.gXKw7ANv.js +1 -0
- streamlit/static/static/js/UploadFileInfo.0DCkpDDf.js +6 -0
- streamlit/static/static/js/{base-input.BoAa1U94.js → base-input.DBYPj91R.js} +4 -4
- streamlit/static/static/js/{checkbox.Z6iSfe5F.js → checkbox.BUm2vnNv.js} +2 -2
- streamlit/static/static/js/{createSuper.B4oGDYRm.js → createSuper.KD4RuZ-W.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.msYws2Ou.js → data-grid-overlay-editor.CUwpDfvI.js} +1 -1
- streamlit/static/static/js/{downloader.kc14n2Hv.js → downloader.CkDtclup.js} +1 -1
- streamlit/static/static/js/{es6.CxQz807-.js → es6.Dlcvh_r0.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.B19u0ONI.js → iframeResizer.contentWindow.DOXlFfve.js} +1 -1
- streamlit/static/static/js/{index.BGga-hcS.js → index.B0cuGMAB.js} +25 -25
- streamlit/static/static/js/index.BCWTclSV.js +73 -0
- streamlit/static/static/js/index.BJY_fap7.js +1 -0
- streamlit/static/static/js/index.BL3l6dnk.js +1 -0
- streamlit/static/static/js/{index.BFz9U2y0.js → index.BMZzRZjB.js} +1 -1
- streamlit/static/static/js/{index.-5ruC9At.js → index.BOzUTGDe.js} +1 -1
- streamlit/static/static/js/index.BYI5iO-o.js +1 -0
- streamlit/static/static/js/index.BYo0ywlm.js +783 -0
- streamlit/static/static/js/{index.CmTAF0dM.js → index.BYz9btsY.js} +1 -1
- streamlit/static/static/js/{index.BHGGDa8K.js → index.CCVzQz0Z.js} +2 -2
- streamlit/static/static/js/index.CD6FydK9.js +1 -0
- streamlit/static/static/js/index.CDYEqgC8.js +2 -0
- streamlit/static/static/js/{index.BRXmLIsC.js → index.CMP9c4xA.js} +1 -1
- streamlit/static/static/js/index.CN30QAPD.js +1 -0
- streamlit/static/static/js/{index.LaIasviC.js → index.CNqWQkTe.js} +1 -1
- streamlit/static/static/js/index.CaxS67Xz.js +1 -0
- streamlit/static/static/js/{index.xNQq3Ei5.js → index.CbsT4sGW.js} +1 -1
- streamlit/static/static/js/index.ChAVlxpQ.js +1 -0
- streamlit/static/static/js/{index.BqfdT8-Q.js → index.ClLMMmDd.js} +1 -1
- streamlit/static/static/js/{index.BHXxWdde.js → index.D-O9rQmV.js} +1 -1
- streamlit/static/static/js/{index.9V1KdxfP.js → index.D4k7VZZL.js} +1 -1
- streamlit/static/static/js/index.DLBi0Ar1.js +1 -0
- streamlit/static/static/js/index.DVq5XmJo.js +197 -0
- streamlit/static/static/js/{index.BoigZiu7.js → index.DZKmKXWw.js} +1 -1
- streamlit/static/static/js/index.DkaVx80F.js +1 -0
- streamlit/static/static/js/index.Dr968Klx.js +1 -0
- streamlit/static/static/js/{index.BpILzHf_.js → index.DtUYLn9j.js} +20 -20
- streamlit/static/static/js/index.DwjYSyhs.js +1 -0
- streamlit/static/static/js/index.DzrImxu4.js +1 -0
- streamlit/static/static/js/index.HyGsn4VM.js +1 -0
- streamlit/static/static/js/index.OwxC65od.js +12 -0
- streamlit/static/static/js/index.PZs7VZkC.js +1 -0
- streamlit/static/static/js/index.Voiqpj4q.js +1 -0
- streamlit/static/static/js/index.bSROvR-J.js +3 -0
- streamlit/static/static/js/index.oT9GD3l4.js +1 -0
- streamlit/static/static/js/{index.DeB9iKFW.js → index.qb-yAPH6.js} +255 -255
- streamlit/static/static/js/index.rJFy_Ygy.js +2 -0
- streamlit/static/static/js/{input.DsCfafm0.js → input.CwQtEnFN.js} +2 -2
- streamlit/static/static/js/{memory.nY_lMTtu.js → memory.C5XaFIjR.js} +1 -1
- streamlit/static/static/js/{mergeWith.B_7zmsM4.js → mergeWith.DzwwH6AG.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.CSeVhHRU.js → number-overlay-editor.Dx0XqCkD.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.nNhsvgRd.js → possibleConstructorReturn.CVfSu9Ws.js} +1 -1
- streamlit/static/static/js/{sandbox.Cgm3iuL6.js → sandbox.BT0gdMXk.js} +1 -1
- streamlit/static/static/js/{textarea.BR8rlyih.js → textarea.DNCbrtbM.js} +2 -2
- streamlit/static/static/js/{timepicker.w4XhAenH.js → timepicker.4UYJD9Ts.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.CgkEPBwD.js → toConsumableArray.DUmnaVWV.js} +1 -1
- streamlit/static/static/js/{uniqueId.j-1rlNNH.js → uniqueId.DUvh-GL8.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.zXY9CjFS.js → useBasicWidgetState.Cwd7-jJa.js} +1 -1
- streamlit/static/static/js/useOnInputChange.DvemQrOM.js +1 -0
- streamlit/static/static/js/{withFullScreenWrapper.Ov13692o.js → withFullScreenWrapper.CiQ10ByU.js} +1 -1
- streamlit/static/static/media/SourceCodeVF-Italic.ttf.Ba1oaZG1.woff2 +0 -0
- streamlit/static/static/media/SourceCodeVF-Upright.ttf.BjWn63N-.woff2 +0 -0
- streamlit/static/static/media/SourceSansVF-Italic.ttf.Bt9VkdQ3.woff2 +0 -0
- streamlit/static/static/media/SourceSansVF-Upright.ttf.BsWL4Kly.woff2 +0 -0
- streamlit/static/static/media/SourceSerifVariable-Italic.ttf.CVdzAtxO.woff2 +0 -0
- streamlit/static/static/media/SourceSerifVariable-Roman.ttf.mdpVL9bi.woff2 +0 -0
- streamlit/string_util.py +14 -19
- streamlit/temporary_directory.py +13 -4
- streamlit/testing/v1/app_test.py +15 -10
- streamlit/testing/v1/element_tree.py +157 -178
- streamlit/testing/v1/local_script_runner.py +11 -15
- streamlit/testing/v1/util.py +11 -4
- streamlit/type_util.py +8 -12
- streamlit/url_util.py +1 -1
- streamlit/user_info.py +6 -5
- streamlit/util.py +25 -1
- streamlit/vendor/pympler/asizeof.py +3 -2
- streamlit/watcher/event_based_path_watcher.py +15 -1
- streamlit/watcher/folder_black_list.py +2 -2
- streamlit/watcher/local_sources_watcher.py +64 -18
- streamlit/watcher/path_watcher.py +6 -10
- streamlit/watcher/polling_path_watcher.py +8 -7
- streamlit/watcher/util.py +7 -6
- streamlit/web/bootstrap.py +16 -14
- streamlit/web/cli.py +52 -45
- streamlit/web/server/__init__.py +7 -3
- streamlit/web/server/app_static_file_handler.py +1 -1
- streamlit/web/server/authlib_tornado_integration.py +9 -4
- streamlit/web/server/browser_websocket_handler.py +8 -2
- streamlit/web/server/component_request_handler.py +14 -10
- streamlit/web/server/media_file_handler.py +14 -7
- streamlit/web/server/oauth_authlib_routes.py +41 -9
- streamlit/web/server/oidc_mixin.py +35 -17
- streamlit/web/server/routes.py +32 -22
- streamlit/web/server/server.py +6 -18
- streamlit/web/server/server_util.py +19 -9
- streamlit/web/server/stats_request_handler.py +7 -5
- streamlit/web/server/upload_file_request_handler.py +22 -19
- streamlit/web/server/websocket_headers.py +1 -1
- {streamlit-1.45.1.dist-info → streamlit-1.46.0.dist-info}/METADATA +4 -4
- streamlit-1.46.0.dist-info/RECORD +559 -0
- {streamlit-1.45.1.dist-info → streamlit-1.46.0.dist-info}/WHEEL +1 -1
- streamlit/elements/lib/event_utils.py +0 -39
- streamlit/static/static/js/Toolbar.D9RUZv9G.js +0 -1
- streamlit/static/static/js/UploadFileInfo.C-jY39rj.js +0 -1
- streamlit/static/static/js/index.8jhZBWF2.js +0 -3
- streamlit/static/static/js/index.BCx3C6e_.js +0 -1
- streamlit/static/static/js/index.BRuTz_S4.js +0 -1
- streamlit/static/static/js/index.Bcru_ti-.js +0 -1
- streamlit/static/static/js/index.Bl1FMJRd.js +0 -1
- streamlit/static/static/js/index.C1z8KpLA.js +0 -779
- streamlit/static/static/js/index.C32I2PUe.js +0 -2
- streamlit/static/static/js/index.C5GnDRB7.js +0 -1
- streamlit/static/static/js/index.CG4qPaaW.js +0 -2
- streamlit/static/static/js/index.C_msmT1u.js +0 -1
- streamlit/static/static/js/index.CbeNTdd6.js +0 -1
- streamlit/static/static/js/index.CnGQVJcw.js +0 -12
- streamlit/static/static/js/index.CopVVq4l.js +0 -1
- streamlit/static/static/js/index.CtXupx4d.js +0 -197
- streamlit/static/static/js/index.DGmCchO7.js +0 -1
- streamlit/static/static/js/index.DH6zBk0e.js +0 -1
- streamlit/static/static/js/index.DHVlVWsm.js +0 -1
- streamlit/static/static/js/index.DRKIVBoi.js +0 -1
- streamlit/static/static/js/index.DUd-lFXx.js +0 -73
- streamlit/static/static/js/index.D_uRBA4B.js +0 -1
- streamlit/static/static/js/index.QHNfgPJd.js +0 -1
- streamlit/static/static/js/index.a-RJocYL.js +0 -1
- streamlit/static/static/js/index.cvz4B1gy.js +0 -1
- streamlit/static/static/js/index.t--hEgTQ.js +0 -6
- streamlit/static/static/js/useOnInputChange.z04u96A8.js +0 -1
- streamlit/static/static/media/SourceCodePro-Bold.CFEfr7-q.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-BoldItalic.C-LkFXxa.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-Italic.CxFOx7N-.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-Regular.CBOlD63d.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-SemiBold.CFHwW3Wd.woff2 +0 -0
- streamlit/static/static/media/SourceCodePro-SemiBoldItalic.Cg2yRu82.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Bold.-6c9oR8J.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-BoldItalic.DmM_grLY.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Italic.I1ipWe7Q.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-Regular.DZLUzqI4.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-SemiBold.sKQIyTMz.woff2 +0 -0
- streamlit/static/static/media/SourceSansPro-SemiBoldItalic.C0wP0icr.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Bold.8TUnKj4x.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-BoldItalic.CBVO7Ve7.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Italic.DkFgL2HZ.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-Regular.CNJNET2S.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-SemiBold.CHyh9GC5.woff2 +0 -0
- streamlit/static/static/media/SourceSerifPro-SemiBoldItalic.CBtz8sWN.woff2 +0 -0
- streamlit-1.45.1.dist-info/RECORD +0 -568
- {streamlit-1.45.1.data → streamlit-1.46.0.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.45.1.dist-info → streamlit-1.46.0.dist-info}/entry_points.txt +0 -0
- {streamlit-1.45.1.dist-info → streamlit-1.46.0.dist-info}/top_level.txt +0 -0
|
@@ -104,9 +104,7 @@ def _srt_to_vtt(srt_data: str | bytes) -> bytes:
|
|
|
104
104
|
# Add WebVTT file header
|
|
105
105
|
vtt_content = "WEBVTT\n\n" + vtt_data
|
|
106
106
|
# Convert the vtt content to bytes
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return vtt_content
|
|
107
|
+
return vtt_content.strip().encode("utf-8")
|
|
110
108
|
|
|
111
109
|
|
|
112
110
|
def _handle_string_or_path_data(data_or_path: str | Path) -> bytes:
|
|
@@ -123,14 +121,14 @@ def _handle_string_or_path_data(data_or_path: str | Path) -> bytes:
|
|
|
123
121
|
with open(data_or_path, "rb") as file:
|
|
124
122
|
content = file.read()
|
|
125
123
|
return _srt_to_vtt(content) if file_extension == ".srt" else content
|
|
126
|
-
|
|
127
|
-
raise ValueError(f"File {data_or_path} does not exist.")
|
|
124
|
+
if isinstance(data_or_path, Path):
|
|
125
|
+
raise ValueError(f"File {data_or_path} does not exist.") # noqa: TRY004
|
|
128
126
|
|
|
129
127
|
content_string = data_or_path.strip()
|
|
130
128
|
|
|
131
129
|
if content_string.startswith("WEBVTT") or content_string == "":
|
|
132
130
|
return content_string.encode("utf-8")
|
|
133
|
-
|
|
131
|
+
if _is_srt(content_string):
|
|
134
132
|
return _srt_to_vtt(content_string)
|
|
135
133
|
raise ValueError("The provided string neither matches valid VTT nor SRT format.")
|
|
136
134
|
|
|
@@ -173,6 +171,5 @@ def process_subtitle_data(
|
|
|
173
171
|
)
|
|
174
172
|
caching.save_media_data(subtitle_data, "text/vtt", coordinates)
|
|
175
173
|
return file_url
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return ""
|
|
174
|
+
# When running in "raw mode", we can't access the MediaFileManager.
|
|
175
|
+
return ""
|
streamlit/elements/lib/utils.py
CHANGED
|
@@ -31,6 +31,7 @@ from streamlit import config
|
|
|
31
31
|
from streamlit.errors import StreamlitDuplicateElementId, StreamlitDuplicateElementKey
|
|
32
32
|
from streamlit.proto.ChatInput_pb2 import ChatInput
|
|
33
33
|
from streamlit.proto.LabelVisibilityMessage_pb2 import LabelVisibilityMessage
|
|
34
|
+
from streamlit.proto.RootContainer_pb2 import RootContainer
|
|
34
35
|
from streamlit.runtime.scriptrunner_utils.script_run_context import (
|
|
35
36
|
ScriptRunContext,
|
|
36
37
|
get_script_run_ctx,
|
|
@@ -45,6 +46,8 @@ if TYPE_CHECKING:
|
|
|
45
46
|
from builtins import ellipsis
|
|
46
47
|
from collections.abc import Iterable
|
|
47
48
|
|
|
49
|
+
from streamlit.delta_generator import DeltaGenerator
|
|
50
|
+
|
|
48
51
|
|
|
49
52
|
Key: TypeAlias = Union[str, int]
|
|
50
53
|
|
|
@@ -70,9 +73,9 @@ def get_label_visibility_proto_value(
|
|
|
70
73
|
|
|
71
74
|
if label_visibility_string == "visible":
|
|
72
75
|
return LabelVisibilityMessage.LabelVisibilityOptions.VISIBLE
|
|
73
|
-
|
|
76
|
+
if label_visibility_string == "hidden":
|
|
74
77
|
return LabelVisibilityMessage.LabelVisibilityOptions.HIDDEN
|
|
75
|
-
|
|
78
|
+
if label_visibility_string == "collapsed":
|
|
76
79
|
return LabelVisibilityMessage.LabelVisibilityOptions.COLLAPSED
|
|
77
80
|
|
|
78
81
|
raise ValueError(f"Unknown label visibility value: {label_visibility_string}")
|
|
@@ -85,9 +88,9 @@ def get_chat_input_accept_file_proto_value(
|
|
|
85
88
|
|
|
86
89
|
if accept_file_value is False:
|
|
87
90
|
return ChatInput.AcceptFile.NONE
|
|
88
|
-
|
|
91
|
+
if accept_file_value is True:
|
|
89
92
|
return ChatInput.AcceptFile.SINGLE
|
|
90
|
-
|
|
93
|
+
if accept_file_value == "multiple":
|
|
91
94
|
return ChatInput.AcceptFile.MULTIPLE
|
|
92
95
|
|
|
93
96
|
raise ValueError(f"Unknown accept file value: {accept_file_value}")
|
|
@@ -182,6 +185,7 @@ def compute_and_register_element_id(
|
|
|
182
185
|
*,
|
|
183
186
|
user_key: str | None,
|
|
184
187
|
form_id: str | None,
|
|
188
|
+
dg: DeltaGenerator | None = None,
|
|
185
189
|
**kwargs: SAFE_VALUES | Iterable[SAFE_VALUES],
|
|
186
190
|
) -> str:
|
|
187
191
|
"""Compute and register the ID for the given element.
|
|
@@ -212,6 +216,9 @@ def compute_and_register_element_id(
|
|
|
212
216
|
The ID of the form that the element belongs to. `None` or empty string
|
|
213
217
|
if the element doesn't belong to a form or doesn't support forms.
|
|
214
218
|
|
|
219
|
+
dg : DeltaGenerator | None
|
|
220
|
+
The DeltaGenerator of each element. `None` if the element is not a widget.
|
|
221
|
+
|
|
215
222
|
kwargs : SAFE_VALUES | Iterable[SAFE_VALUES]
|
|
216
223
|
The arguments to use to compute the element ID.
|
|
217
224
|
The arguments must be stable, deterministic values.
|
|
@@ -229,6 +236,14 @@ def compute_and_register_element_id(
|
|
|
229
236
|
# pages unique IDs.
|
|
230
237
|
kwargs_to_use["active_script_hash"] = ctx.active_script_hash
|
|
231
238
|
|
|
239
|
+
if dg:
|
|
240
|
+
# If no key is provided and the widget element is inside the sidebar area
|
|
241
|
+
# add it to the kwargs
|
|
242
|
+
# allowing the same widget to be both in main area and sidebar.
|
|
243
|
+
active_dg_root_container = dg._active_dg._root_container
|
|
244
|
+
if active_dg_root_container == RootContainer.SIDEBAR and user_key is None:
|
|
245
|
+
kwargs_to_use["active_dg_root_container"] = str(active_dg_root_container)
|
|
246
|
+
|
|
232
247
|
element_id = _compute_element_id(
|
|
233
248
|
element_type,
|
|
234
249
|
user_key,
|
|
@@ -240,7 +255,7 @@ def compute_and_register_element_id(
|
|
|
240
255
|
return element_id
|
|
241
256
|
|
|
242
257
|
|
|
243
|
-
def save_for_app_testing(ctx: ScriptRunContext, k: str, v: Any):
|
|
258
|
+
def save_for_app_testing(ctx: ScriptRunContext, k: str, v: Any) -> None:
|
|
244
259
|
if config.get_option("global.appTest"):
|
|
245
260
|
try:
|
|
246
261
|
ctx.session_state[TESTING_KEY][k] = v
|
streamlit/elements/map.py
CHANGED
|
@@ -20,8 +20,8 @@ import copy
|
|
|
20
20
|
import json
|
|
21
21
|
from typing import TYPE_CHECKING, Any, Final, cast
|
|
22
22
|
|
|
23
|
-
import streamlit.elements.deck_gl_json_chart as deck_gl_json_chart
|
|
24
23
|
from streamlit import config, dataframe_util
|
|
24
|
+
from streamlit.elements import deck_gl_json_chart
|
|
25
25
|
from streamlit.elements.lib.color_util import (
|
|
26
26
|
Color,
|
|
27
27
|
IntColorTuple,
|
|
@@ -94,21 +94,26 @@ class MapMixin:
|
|
|
94
94
|
This is a wrapper around ``st.pydeck_chart`` to quickly create
|
|
95
95
|
scatterplot charts on top of a map, with auto-centering and auto-zoom.
|
|
96
96
|
|
|
97
|
-
When using this command,
|
|
98
|
-
content.
|
|
99
|
-
|
|
100
|
-
or
|
|
97
|
+
When using this command, a service called Carto_ provides the map tiles to render
|
|
98
|
+
map content. If you're using advanced PyDeck features you may need to obtain
|
|
99
|
+
an API key from Carto first. You can do that as
|
|
100
|
+
``pydeck.Deck(api_keys={"carto": YOUR_KEY})`` or by setting the CARTO_API_KEY
|
|
101
|
+
environment variable. See `PyDeck's documentation`_ for more information.
|
|
101
102
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
use of Mapbox is governed by Mapbox's Terms of Use.
|
|
103
|
+
Another common provider for map tiles is Mapbox_. If you prefer to use that,
|
|
104
|
+
you'll need to create an account at https://mapbox.com and specify your Mapbox
|
|
105
|
+
key when creating the ``pydeck.Deck`` object. You can do that as
|
|
106
|
+
``pydeck.Deck(api_keys={"mapbox": YOUR_KEY})`` or by setting the MAPBOX_API_KEY
|
|
107
|
+
environment variable.
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
https://
|
|
109
|
+
.. _Carto: https://carto.com
|
|
110
|
+
.. _Mapbox: https://mapbox.com
|
|
111
|
+
.. _PyDeck's documentation: https://deckgl.readthedocs.io/en/latest/deck.html
|
|
112
|
+
|
|
113
|
+
Carto and Mapbox are third-party products and Streamlit accepts no responsibility
|
|
114
|
+
or liability of any kind for Carto or Mapbox, or for any content or information
|
|
115
|
+
made available by Carto or Mapbox. The use of Carto or Mapbox is governed by
|
|
116
|
+
their respective Terms of Use.
|
|
112
117
|
|
|
113
118
|
Parameters
|
|
114
119
|
----------
|
|
@@ -225,23 +230,8 @@ class MapMixin:
|
|
|
225
230
|
height: 600px
|
|
226
231
|
|
|
227
232
|
"""
|
|
228
|
-
# This feature was turned off while we investigate why different
|
|
229
|
-
# map styles cause DeckGL to crash.
|
|
230
|
-
#
|
|
231
|
-
# For reference, this was the docstring for map_style:
|
|
232
|
-
#
|
|
233
|
-
# map_style : str or None
|
|
234
|
-
# One of Mapbox's map style URLs. A full list can be found here:
|
|
235
|
-
# https://docs.mapbox.com/api/maps/styles/#mapbox-styles
|
|
236
|
-
#
|
|
237
|
-
# This feature requires a Mapbox token. See the top of these docs
|
|
238
|
-
# for information on how to get one and set it up in Streamlit.
|
|
239
|
-
#
|
|
240
|
-
map_style = None
|
|
241
233
|
map_proto = DeckGlJsonChartProto()
|
|
242
|
-
deck_gl_json = to_deckgl_json(
|
|
243
|
-
data, latitude, longitude, size, color, map_style, zoom
|
|
244
|
-
)
|
|
234
|
+
deck_gl_json = to_deckgl_json(data, latitude, longitude, size, color, zoom)
|
|
245
235
|
marshall(
|
|
246
236
|
map_proto, deck_gl_json, use_container_width, width=width, height=height
|
|
247
237
|
)
|
|
@@ -259,7 +249,6 @@ def to_deckgl_json(
|
|
|
259
249
|
lon: str | None,
|
|
260
250
|
size: None | str | float,
|
|
261
251
|
color: None | str | Collection[float],
|
|
262
|
-
map_style: str | None,
|
|
263
252
|
zoom: int | None,
|
|
264
253
|
) -> str:
|
|
265
254
|
if data is None:
|
|
@@ -291,7 +280,7 @@ def to_deckgl_json(
|
|
|
291
280
|
)
|
|
292
281
|
df = df[used_columns]
|
|
293
282
|
|
|
294
|
-
|
|
283
|
+
converted_color_arg = _convert_color_arg_or_column(df, color_arg, color_col_name)
|
|
295
284
|
|
|
296
285
|
zoom, center_lat, center_lon = _get_viewport_details(
|
|
297
286
|
df, lat_col_name, lon_col_name, zoom
|
|
@@ -308,19 +297,11 @@ def to_deckgl_json(
|
|
|
308
297
|
"getRadius": size_arg,
|
|
309
298
|
"radiusMinPixels": 3,
|
|
310
299
|
"radiusUnits": "meters",
|
|
311
|
-
"getFillColor":
|
|
300
|
+
"getFillColor": converted_color_arg,
|
|
312
301
|
"data": df.to_dict("records"),
|
|
313
302
|
}
|
|
314
303
|
]
|
|
315
304
|
|
|
316
|
-
if map_style:
|
|
317
|
-
if not config.get_option("mapbox.token"):
|
|
318
|
-
raise StreamlitAPIException(
|
|
319
|
-
"You need a Mapbox token in order to select a map type. "
|
|
320
|
-
"Refer to the docs for st.map for more information."
|
|
321
|
-
)
|
|
322
|
-
default["mapStyle"] = map_style
|
|
323
|
-
|
|
324
305
|
return json.dumps(default)
|
|
325
306
|
|
|
326
307
|
|
|
@@ -352,8 +333,7 @@ def _get_lat_or_lon_col_name(
|
|
|
352
333
|
f"Map data must contain a {human_readable_name} column named: "
|
|
353
334
|
f"{formatted_allowed_col_name}. Existing columns: {formmated_col_names}"
|
|
354
335
|
)
|
|
355
|
-
|
|
356
|
-
col_name = candidate_col_name
|
|
336
|
+
col_name = candidate_col_name
|
|
357
337
|
|
|
358
338
|
# Check that the column is well-formed.
|
|
359
339
|
# IMPLEMENTATION NOTE: We can't use isnull().values.any() because .values can return
|
|
@@ -374,7 +354,7 @@ def _get_value_and_col_name(
|
|
|
374
354
|
data: DataFrame,
|
|
375
355
|
value_or_name: Any,
|
|
376
356
|
default_value: Any,
|
|
377
|
-
) -> tuple[
|
|
357
|
+
) -> tuple[str, str | None]:
|
|
378
358
|
"""Take a value_or_name passed in by the Streamlit developer and return a PyDeck
|
|
379
359
|
argument and column name for that property.
|
|
380
360
|
|
|
@@ -386,7 +366,7 @@ def _get_value_and_col_name(
|
|
|
386
366
|
- If the user passes size="my_col_123", this returns "@@=my_col_123" and "my_col_123".
|
|
387
367
|
"""
|
|
388
368
|
|
|
389
|
-
pydeck_arg: str
|
|
369
|
+
pydeck_arg: str
|
|
390
370
|
|
|
391
371
|
if isinstance(value_or_name, str) and value_or_name in data.columns:
|
|
392
372
|
col_name = value_or_name
|
|
@@ -394,17 +374,14 @@ def _get_value_and_col_name(
|
|
|
394
374
|
else:
|
|
395
375
|
col_name = None
|
|
396
376
|
|
|
397
|
-
if value_or_name is None
|
|
398
|
-
pydeck_arg = default_value
|
|
399
|
-
else:
|
|
400
|
-
pydeck_arg = value_or_name
|
|
377
|
+
pydeck_arg = default_value if value_or_name is None else value_or_name
|
|
401
378
|
|
|
402
379
|
return pydeck_arg, col_name
|
|
403
380
|
|
|
404
381
|
|
|
405
382
|
def _convert_color_arg_or_column(
|
|
406
383
|
data: DataFrame,
|
|
407
|
-
color_arg: str
|
|
384
|
+
color_arg: str,
|
|
408
385
|
color_col_name: str | None,
|
|
409
386
|
) -> None | str | IntColorTuple:
|
|
410
387
|
"""Converts color to a format accepted by PyDeck.
|
|
@@ -433,8 +410,6 @@ def _convert_color_arg_or_column(
|
|
|
433
410
|
f'Column "{color_col_name}" does not appear to contain valid colors.'
|
|
434
411
|
)
|
|
435
412
|
|
|
436
|
-
# This is guaranteed to be a str because of _get_value_and_col_name
|
|
437
|
-
assert isinstance(color_arg, str)
|
|
438
413
|
color_arg_out = color_arg
|
|
439
414
|
|
|
440
415
|
elif color_arg is not None:
|
|
@@ -457,10 +432,7 @@ def _get_viewport_details(
|
|
|
457
432
|
range_lat = abs(max_lat - min_lat)
|
|
458
433
|
|
|
459
434
|
if zoom is None:
|
|
460
|
-
|
|
461
|
-
longitude_distance = range_lon
|
|
462
|
-
else:
|
|
463
|
-
longitude_distance = range_lat
|
|
435
|
+
longitude_distance = max(range_lat, range_lon)
|
|
464
436
|
zoom = _get_zoom_level(longitude_distance)
|
|
465
437
|
|
|
466
438
|
return zoom, center_lat, center_lon
|
|
@@ -506,3 +478,7 @@ def marshall(
|
|
|
506
478
|
pydeck_proto.height = height
|
|
507
479
|
|
|
508
480
|
pydeck_proto.id = ""
|
|
481
|
+
|
|
482
|
+
mapbox_token = config.get_option("mapbox.token")
|
|
483
|
+
if mapbox_token:
|
|
484
|
+
pydeck_proto.mapbox_token = mapbox_token
|
streamlit/elements/markdown.py
CHANGED
|
@@ -16,13 +16,19 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
from typing import TYPE_CHECKING, Final, Literal, cast
|
|
18
18
|
|
|
19
|
+
from streamlit.elements.lib.layout_utils import (
|
|
20
|
+
LayoutConfig,
|
|
21
|
+
Width,
|
|
22
|
+
WidthWithoutContent,
|
|
23
|
+
validate_width,
|
|
24
|
+
)
|
|
19
25
|
from streamlit.proto.Markdown_pb2 import Markdown as MarkdownProto
|
|
20
26
|
from streamlit.runtime.metrics_util import gather_metrics
|
|
21
27
|
from streamlit.string_util import clean_text, validate_icon_or_emoji
|
|
22
28
|
from streamlit.type_util import SupportsStr, is_sympy_expression
|
|
23
29
|
|
|
24
30
|
if TYPE_CHECKING:
|
|
25
|
-
import sympy
|
|
31
|
+
import sympy
|
|
26
32
|
|
|
27
33
|
from streamlit.delta_generator import DeltaGenerator
|
|
28
34
|
|
|
@@ -37,6 +43,7 @@ class MarkdownMixin:
|
|
|
37
43
|
unsafe_allow_html: bool = False,
|
|
38
44
|
*, # keyword-only arguments:
|
|
39
45
|
help: str | None = None,
|
|
46
|
+
width: Width = "stretch",
|
|
40
47
|
) -> DeltaGenerator:
|
|
41
48
|
r"""Display string formatted as Markdown.
|
|
42
49
|
|
|
@@ -110,6 +117,18 @@ class MarkdownMixin:
|
|
|
110
117
|
including the Markdown directives described in the ``body``
|
|
111
118
|
parameter of ``st.markdown``.
|
|
112
119
|
|
|
120
|
+
width : "stretch", "content", or int
|
|
121
|
+
The width of the Markdown element. This can be one of the following:
|
|
122
|
+
|
|
123
|
+
- ``"stretch"`` (default): The width of the element matches the
|
|
124
|
+
width of the parent container.
|
|
125
|
+
- ``"content"``: The width of the element matches the width of its
|
|
126
|
+
content, but doesn't exceed the width of the parent container.
|
|
127
|
+
- An integer specifying the width in pixels: The element has a
|
|
128
|
+
fixed width. If the specified width is greater than the width of
|
|
129
|
+
the parent container, the width of the element matches the width
|
|
130
|
+
of the parent container.
|
|
131
|
+
|
|
113
132
|
Examples
|
|
114
133
|
--------
|
|
115
134
|
>>> import streamlit as st
|
|
@@ -141,7 +160,10 @@ class MarkdownMixin:
|
|
|
141
160
|
if help:
|
|
142
161
|
markdown_proto.help = help
|
|
143
162
|
|
|
144
|
-
|
|
163
|
+
validate_width(width, allow_content=True)
|
|
164
|
+
layout_config = LayoutConfig(width=width)
|
|
165
|
+
|
|
166
|
+
return self.dg._enqueue("markdown", markdown_proto, layout_config=layout_config)
|
|
145
167
|
|
|
146
168
|
@gather_metrics("caption")
|
|
147
169
|
def caption(
|
|
@@ -150,6 +172,7 @@ class MarkdownMixin:
|
|
|
150
172
|
unsafe_allow_html: bool = False,
|
|
151
173
|
*, # keyword-only arguments:
|
|
152
174
|
help: str | None = None,
|
|
175
|
+
width: Width = "stretch",
|
|
153
176
|
) -> DeltaGenerator:
|
|
154
177
|
"""Display text in small font.
|
|
155
178
|
|
|
@@ -189,6 +212,18 @@ class MarkdownMixin:
|
|
|
189
212
|
including the Markdown directives described in the ``body``
|
|
190
213
|
parameter of ``st.markdown``.
|
|
191
214
|
|
|
215
|
+
width : "stretch", "content", or int
|
|
216
|
+
The width of the caption element. This can be one of the following:
|
|
217
|
+
|
|
218
|
+
- ``"stretch"`` (default): The width of the element matches the
|
|
219
|
+
width of the parent container.
|
|
220
|
+
- ``"content"``: The width of the element matches the width of its
|
|
221
|
+
content, but doesn't exceed the width of the parent container.
|
|
222
|
+
- An integer specifying the width in pixels: The element has a
|
|
223
|
+
fixed width. If the specified width is greater than the width of
|
|
224
|
+
the parent container, the width of the element matches the width
|
|
225
|
+
of the parent container.
|
|
226
|
+
|
|
192
227
|
Examples
|
|
193
228
|
--------
|
|
194
229
|
>>> import streamlit as st
|
|
@@ -204,7 +239,11 @@ class MarkdownMixin:
|
|
|
204
239
|
caption_proto.element_type = MarkdownProto.Type.CAPTION
|
|
205
240
|
if help:
|
|
206
241
|
caption_proto.help = help
|
|
207
|
-
|
|
242
|
+
|
|
243
|
+
validate_width(width, allow_content=True)
|
|
244
|
+
layout_config = LayoutConfig(width=width)
|
|
245
|
+
|
|
246
|
+
return self.dg._enqueue("markdown", caption_proto, layout_config=layout_config)
|
|
208
247
|
|
|
209
248
|
@gather_metrics("latex")
|
|
210
249
|
def latex(
|
|
@@ -212,6 +251,7 @@ class MarkdownMixin:
|
|
|
212
251
|
body: SupportsStr | sympy.Expr,
|
|
213
252
|
*, # keyword-only arguments:
|
|
214
253
|
help: str | None = None,
|
|
254
|
+
width: Width = "stretch",
|
|
215
255
|
) -> DeltaGenerator:
|
|
216
256
|
# This docstring needs to be "raw" because of the backslashes in the
|
|
217
257
|
# example below.
|
|
@@ -235,6 +275,18 @@ class MarkdownMixin:
|
|
|
235
275
|
including the Markdown directives described in the ``body``
|
|
236
276
|
parameter of ``st.markdown``.
|
|
237
277
|
|
|
278
|
+
width : "stretch", "content", or int
|
|
279
|
+
The width of the LaTeX element. This can be one of the following:
|
|
280
|
+
|
|
281
|
+
- ``"stretch"`` (default): The width of the element matches the
|
|
282
|
+
width of the parent container.
|
|
283
|
+
- ``"content"``: The width of the element matches the width of its
|
|
284
|
+
content, but doesn't exceed the width of the parent container.
|
|
285
|
+
- An integer specifying the width in pixels: The element has a
|
|
286
|
+
fixed width. If the specified width is greater than the width of
|
|
287
|
+
the parent container, the width of the element matches the width
|
|
288
|
+
of the parent container.
|
|
289
|
+
|
|
238
290
|
Example
|
|
239
291
|
-------
|
|
240
292
|
>>> import streamlit as st
|
|
@@ -246,26 +298,43 @@ class MarkdownMixin:
|
|
|
246
298
|
... ''')
|
|
247
299
|
|
|
248
300
|
"""
|
|
301
|
+
|
|
249
302
|
if is_sympy_expression(body):
|
|
250
303
|
import sympy
|
|
251
304
|
|
|
252
305
|
body = sympy.latex(body)
|
|
253
306
|
|
|
254
307
|
latex_proto = MarkdownProto()
|
|
255
|
-
latex_proto.body = "$$\n
|
|
308
|
+
latex_proto.body = f"$$\n{clean_text(body)}\n$$"
|
|
256
309
|
latex_proto.element_type = MarkdownProto.Type.LATEX
|
|
257
310
|
if help:
|
|
258
311
|
latex_proto.help = help
|
|
259
|
-
|
|
312
|
+
|
|
313
|
+
validate_width(width, allow_content=True)
|
|
314
|
+
layout_config = LayoutConfig(width=width)
|
|
315
|
+
|
|
316
|
+
return self.dg._enqueue("markdown", latex_proto, layout_config=layout_config)
|
|
260
317
|
|
|
261
318
|
@gather_metrics("divider")
|
|
262
|
-
def divider(self) -> DeltaGenerator:
|
|
319
|
+
def divider(self, *, width: WidthWithoutContent = "stretch") -> DeltaGenerator:
|
|
263
320
|
"""Display a horizontal rule.
|
|
264
321
|
|
|
265
322
|
.. note::
|
|
266
323
|
You can achieve the same effect with st.write("---") or
|
|
267
324
|
even just "---" in your script (via magic).
|
|
268
325
|
|
|
326
|
+
Parameters
|
|
327
|
+
----------
|
|
328
|
+
width : "stretch" or int
|
|
329
|
+
The width of the divider element. This can be one of the following:
|
|
330
|
+
|
|
331
|
+
- ``"stretch"`` (default): The width of the element matches the
|
|
332
|
+
width of the parent container.
|
|
333
|
+
- An integer specifying the width in pixels: The element has a
|
|
334
|
+
fixed width. If the specified width is greater than the width of
|
|
335
|
+
the parent container, the width of the element matches the width
|
|
336
|
+
of the parent container.
|
|
337
|
+
|
|
269
338
|
Example
|
|
270
339
|
-------
|
|
271
340
|
>>> import streamlit as st
|
|
@@ -273,10 +342,15 @@ class MarkdownMixin:
|
|
|
273
342
|
>>> st.divider()
|
|
274
343
|
|
|
275
344
|
"""
|
|
345
|
+
|
|
276
346
|
divider_proto = MarkdownProto()
|
|
277
347
|
divider_proto.body = MARKDOWN_HORIZONTAL_RULE_EXPRESSION
|
|
278
348
|
divider_proto.element_type = MarkdownProto.Type.DIVIDER
|
|
279
|
-
|
|
349
|
+
|
|
350
|
+
validate_width(width, allow_content=False)
|
|
351
|
+
layout_config = LayoutConfig(width=width)
|
|
352
|
+
|
|
353
|
+
return self.dg._enqueue("markdown", divider_proto, layout_config=layout_config)
|
|
280
354
|
|
|
281
355
|
@gather_metrics("badge")
|
|
282
356
|
def badge(
|
|
@@ -294,6 +368,7 @@ class MarkdownMixin:
|
|
|
294
368
|
"grey",
|
|
295
369
|
"primary",
|
|
296
370
|
] = "blue",
|
|
371
|
+
width: Width = "content",
|
|
297
372
|
) -> DeltaGenerator:
|
|
298
373
|
"""Display a colored badge with an icon and label.
|
|
299
374
|
|
|
@@ -348,6 +423,19 @@ class MarkdownMixin:
|
|
|
348
423
|
``"primary"``, Streamlit will use the default primary accent color
|
|
349
424
|
unless you set the ``theme.primaryColor`` configuration option.
|
|
350
425
|
|
|
426
|
+
width : "content", "stretch", or int
|
|
427
|
+
The width of the badge element. This can be one of the following:
|
|
428
|
+
|
|
429
|
+
- ``"content"`` (default): The width of the element matches the
|
|
430
|
+
width of its content, but doesn't exceed the width of the parent
|
|
431
|
+
container.
|
|
432
|
+
- ``"stretch"``: The width of the element matches the width of the
|
|
433
|
+
parent container.
|
|
434
|
+
- An integer specifying the width in pixels: The element has a
|
|
435
|
+
fixed width. If the specified width is greater than the width of
|
|
436
|
+
the parent container, the width of the element matches the width
|
|
437
|
+
of the parent container.
|
|
438
|
+
|
|
351
439
|
Examples
|
|
352
440
|
--------
|
|
353
441
|
Create standalone badges with ``st.badge`` (with or without icons). If
|
|
@@ -368,10 +456,7 @@ class MarkdownMixin:
|
|
|
368
456
|
height: 220px
|
|
369
457
|
|
|
370
458
|
"""
|
|
371
|
-
if icon is not None
|
|
372
|
-
icon_str = validate_icon_or_emoji(icon) + " "
|
|
373
|
-
else:
|
|
374
|
-
icon_str = ""
|
|
459
|
+
icon_str = validate_icon_or_emoji(icon) + " " if icon is not None else ""
|
|
375
460
|
|
|
376
461
|
# Escape [ and ] characters in the label to prevent breaking the directive syntax
|
|
377
462
|
escaped_label = label.replace("[", "\\[").replace("]", "\\]")
|
|
@@ -379,7 +464,11 @@ class MarkdownMixin:
|
|
|
379
464
|
badge_proto = MarkdownProto()
|
|
380
465
|
badge_proto.body = f":{color}-badge[{icon_str}{escaped_label}]"
|
|
381
466
|
badge_proto.element_type = MarkdownProto.Type.NATIVE
|
|
382
|
-
|
|
467
|
+
|
|
468
|
+
validate_width(width, allow_content=True)
|
|
469
|
+
layout_config = LayoutConfig(width=width)
|
|
470
|
+
|
|
471
|
+
return self.dg._enqueue("markdown", badge_proto, layout_config=layout_config)
|
|
383
472
|
|
|
384
473
|
@property
|
|
385
474
|
def dg(self) -> DeltaGenerator:
|