streamlit 1.51.0__py3-none-any.whl → 1.52.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 +1 -0
- streamlit/commands/execution_control.py +89 -14
- streamlit/components/v1/component_arrow.py +7 -7
- streamlit/components/v2/__init__.py +59 -3
- streamlit/components/v2/bidi_component/main.py +161 -13
- streamlit/components/v2/bidi_component/serialization.py +13 -6
- streamlit/components/v2/component_manager.py +11 -3
- streamlit/components/v2/component_registry.py +18 -1
- streamlit/components/v2/types.py +2 -2
- streamlit/connections/snowflake_connection.py +1 -1
- streamlit/connections/snowpark_connection.py +1 -1
- streamlit/dataframe_util.py +18 -18
- streamlit/delta_generator.py +7 -0
- streamlit/delta_generator_singletons.py +8 -14
- streamlit/elements/alert.py +16 -0
- streamlit/elements/arrow.py +36 -6
- streamlit/elements/bokeh_chart.py +10 -78
- streamlit/elements/code.py +2 -2
- streamlit/elements/deck_gl_json_chart.py +1 -1
- streamlit/elements/exception.py +1 -1
- streamlit/elements/form.py +27 -0
- streamlit/elements/heading.py +60 -5
- streamlit/elements/html.py +13 -2
- streamlit/elements/image.py +1 -1
- streamlit/elements/layouts.py +28 -22
- streamlit/elements/lib/built_in_chart_utils.py +49 -16
- streamlit/elements/lib/color_util.py +1 -1
- streamlit/elements/lib/column_config_utils.py +6 -5
- streamlit/elements/lib/layout_utils.py +50 -0
- streamlit/elements/lib/pandas_styler_utils.py +17 -9
- streamlit/elements/lib/shortcut_utils.py +152 -0
- streamlit/elements/markdown.py +50 -3
- streamlit/elements/metric.py +31 -1
- streamlit/elements/plotly_chart.py +75 -6
- streamlit/elements/spinner.py +1 -1
- streamlit/elements/text.py +20 -3
- streamlit/elements/toast.py +2 -0
- streamlit/elements/vega_charts.py +17 -1
- streamlit/elements/widgets/audio_input.py +8 -7
- streamlit/elements/widgets/button.py +279 -40
- streamlit/elements/widgets/button_group.py +27 -2
- streamlit/elements/widgets/camera_input.py +1 -1
- streamlit/elements/widgets/chat.py +300 -42
- streamlit/elements/widgets/color_picker.py +7 -0
- streamlit/elements/widgets/data_editor.py +68 -28
- streamlit/elements/widgets/file_uploader.py +4 -1
- streamlit/elements/widgets/number_input.py +2 -0
- streamlit/elements/widgets/text_widgets.py +2 -0
- streamlit/elements/widgets/time_widgets.py +581 -9
- streamlit/errors.py +22 -0
- streamlit/git_util.py +1 -1
- streamlit/navigation/page.py +7 -0
- streamlit/net_util.py +2 -2
- streamlit/proto/Alert_pb2.pyi +3 -3
- streamlit/proto/AppPage_pb2.pyi +7 -1
- streamlit/proto/ArrowData_pb2.pyi +7 -1
- streamlit/proto/ArrowNamedDataSet_pb2.pyi +7 -1
- streamlit/proto/ArrowVegaLiteChart_pb2.pyi +7 -1
- streamlit/proto/Arrow_pb2.py +10 -10
- streamlit/proto/Arrow_pb2.pyi +19 -12
- streamlit/proto/AudioInput_pb2.pyi +7 -1
- streamlit/proto/Audio_pb2.pyi +7 -1
- streamlit/proto/AuthRedirect_pb2.pyi +7 -1
- streamlit/proto/AutoRerun_pb2.pyi +7 -1
- streamlit/proto/BackMsg_pb2.py +4 -2
- streamlit/proto/BackMsg_pb2.pyi +34 -4
- streamlit/proto/Balloons_pb2.pyi +7 -1
- streamlit/proto/BidiComponent_pb2.pyi +10 -4
- streamlit/proto/Block_pb2.pyi +35 -35
- streamlit/proto/BokehChart_pb2.pyi +7 -1
- streamlit/proto/ButtonGroup_pb2.pyi +9 -9
- streamlit/proto/Button_pb2.py +2 -2
- streamlit/proto/Button_pb2.pyi +11 -2
- streamlit/proto/CameraInput_pb2.pyi +7 -1
- streamlit/proto/ChatInput_pb2.py +6 -6
- streamlit/proto/ChatInput_pb2.pyi +18 -6
- streamlit/proto/Checkbox_pb2.pyi +3 -3
- streamlit/proto/ClientState_pb2.pyi +10 -4
- streamlit/proto/Code_pb2.pyi +7 -1
- streamlit/proto/ColorPicker_pb2.pyi +7 -1
- streamlit/proto/Common_pb2.py +3 -3
- streamlit/proto/Common_pb2.pyi +35 -23
- streamlit/proto/Components_pb2.pyi +19 -13
- streamlit/proto/DataFrame_pb2.pyi +55 -49
- streamlit/proto/DateInput_pb2.pyi +7 -1
- streamlit/proto/DateTimeInput_pb2.py +28 -0
- streamlit/proto/DateTimeInput_pb2.pyi +92 -0
- streamlit/proto/DeckGlJsonChart_pb2.pyi +3 -3
- streamlit/proto/Delta_pb2.pyi +7 -1
- streamlit/proto/DocString_pb2.pyi +10 -4
- streamlit/proto/DownloadButton_pb2.py +2 -2
- streamlit/proto/DownloadButton_pb2.pyi +16 -2
- streamlit/proto/Element_pb2.py +5 -3
- streamlit/proto/Element_pb2.pyi +23 -5
- streamlit/proto/Empty_pb2.pyi +7 -1
- streamlit/proto/Exception_pb2.pyi +7 -1
- streamlit/proto/Favicon_pb2.pyi +7 -1
- streamlit/proto/FileUploader_pb2.pyi +7 -1
- streamlit/proto/ForwardMsg_pb2.py +12 -10
- streamlit/proto/ForwardMsg_pb2.pyi +42 -15
- streamlit/proto/GapSize_pb2.pyi +4 -4
- streamlit/proto/GitInfo_pb2.pyi +3 -3
- streamlit/proto/GraphVizChart_pb2.pyi +7 -1
- streamlit/proto/Heading_pb2.pyi +7 -1
- streamlit/proto/HeightConfig_pb2.pyi +7 -1
- streamlit/proto/Html_pb2.py +2 -2
- streamlit/proto/Html_pb2.pyi +11 -2
- streamlit/proto/IFrame_pb2.pyi +7 -1
- streamlit/proto/Image_pb2.pyi +10 -4
- streamlit/proto/Json_pb2.pyi +7 -1
- streamlit/proto/LabelVisibilityMessage_pb2.pyi +3 -3
- streamlit/proto/LinkButton_pb2.py +2 -2
- streamlit/proto/LinkButton_pb2.pyi +15 -2
- streamlit/proto/Logo_pb2.pyi +7 -1
- streamlit/proto/Markdown_pb2.pyi +3 -3
- streamlit/proto/Metric_pb2.pyi +7 -7
- streamlit/proto/MetricsEvent_pb2.pyi +10 -4
- streamlit/proto/MultiSelect_pb2.pyi +7 -1
- streamlit/proto/NamedDataSet_pb2.pyi +7 -1
- streamlit/proto/Navigation_pb2.pyi +3 -3
- streamlit/proto/NewSession_pb2.pyi +40 -40
- streamlit/proto/NumberInput_pb2.pyi +3 -3
- streamlit/proto/PageConfig_pb2.pyi +7 -7
- streamlit/proto/PageInfo_pb2.pyi +7 -1
- streamlit/proto/PageLink_pb2.py +2 -2
- streamlit/proto/PageLink_pb2.pyi +11 -2
- streamlit/proto/PageNotFound_pb2.pyi +7 -1
- streamlit/proto/PageProfile_pb2.pyi +13 -7
- streamlit/proto/PagesChanged_pb2.pyi +7 -1
- streamlit/proto/ParentMessage_pb2.pyi +7 -1
- streamlit/proto/PlotlyChart_pb2.pyi +6 -6
- streamlit/proto/Progress_pb2.pyi +7 -1
- streamlit/proto/Radio_pb2.pyi +7 -1
- streamlit/proto/RootContainer_pb2.pyi +1 -1
- streamlit/proto/Selectbox_pb2.pyi +7 -1
- streamlit/proto/SessionEvent_pb2.pyi +7 -1
- streamlit/proto/SessionStatus_pb2.pyi +7 -1
- streamlit/proto/Skeleton_pb2.pyi +3 -3
- streamlit/proto/Slider_pb2.pyi +5 -5
- streamlit/proto/Snow_pb2.pyi +7 -1
- streamlit/proto/Space_pb2.pyi +7 -1
- streamlit/proto/Spinner_pb2.pyi +7 -1
- streamlit/proto/TextAlignmentConfig_pb2.py +29 -0
- streamlit/proto/TextAlignmentConfig_pb2.pyi +68 -0
- streamlit/proto/TextArea_pb2.pyi +7 -1
- streamlit/proto/TextInput_pb2.pyi +3 -3
- streamlit/proto/Text_pb2.pyi +7 -1
- streamlit/proto/TimeInput_pb2.pyi +7 -1
- streamlit/proto/Toast_pb2.pyi +7 -1
- streamlit/proto/VegaLiteChart_pb2.pyi +7 -1
- streamlit/proto/Video_pb2.pyi +6 -6
- streamlit/proto/WidgetStates_pb2.pyi +10 -4
- streamlit/proto/WidthConfig_pb2.pyi +7 -1
- streamlit/proto/openmetrics_data_model_pb2.pyi +52 -52
- streamlit/runtime/app_session.py +38 -1
- streamlit/runtime/caching/cache_data_api.py +1 -1
- streamlit/runtime/caching/cache_resource_api.py +2 -2
- streamlit/runtime/caching/cache_utils.py +1 -1
- streamlit/runtime/caching/hashing.py +1 -1
- streamlit/runtime/download_data_util.py +53 -0
- streamlit/runtime/forward_msg_queue.py +1 -0
- streamlit/runtime/media_file_manager.py +178 -2
- streamlit/runtime/metrics_util.py +87 -3
- streamlit/runtime/scriptrunner/script_runner.py +3 -1
- streamlit/runtime/state/query_params.py +80 -29
- streamlit/runtime/state/session_state.py +2 -2
- streamlit/static/index.html +1 -1
- streamlit/static/manifest.json +530 -229
- streamlit/static/static/js/{ErrorOutline.esm.YoJdlW1p.js → ErrorOutline.esm.ZJDbmVTx.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.Ddx8VEYy.js → FileDownload.esm.Dx0vI3vH.js} +1 -1
- streamlit/static/static/js/{FileHelper.90EtOmj9.js → FileHelper.B7Ero7qQ.js} +3 -3
- streamlit/static/static/js/{FormClearHelper.BB1Km6eP.js → FormClearHelper.CG2XN1_g.js} +1 -1
- streamlit/static/static/js/IFrameUtil.DefezniK.js +1 -0
- streamlit/static/static/js/InputInstructions.Cj5-1zf6.js +1 -0
- streamlit/static/static/js/Particles.BfWfv0Aw.js +1 -0
- streamlit/static/static/js/{ProgressBar.DLY8H6nE.js → ProgressBar.CGQ8OgfO.js} +2 -2
- streamlit/static/static/js/StreamlitSyntaxHighlighter.DTKLpwhl.js +20 -0
- streamlit/static/static/js/{Toolbar.D8nHCkuz.js → Toolbar.B2qFUmd9.js} +1 -1
- streamlit/static/static/js/_arrayIncludes.B19Iyn2B.js +1 -0
- streamlit/static/static/js/_baseIndexOf.BTknn6Gb.js +1 -0
- streamlit/static/static/js/{base-input.CJGiNqed.js → base-input.o9tL8MDP.js} +4 -4
- streamlit/static/static/js/{checkbox.Cpdd482O.js → checkbox.0BeV1IBL.js} +1 -1
- streamlit/static/static/js/{createSuper.CuQIogbW.js → createSuper.RBO59fEm.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.CiTkUy0t.js +1 -0
- streamlit/static/static/js/{downloader.CN0K7xlu.js → downloader.DwNZg3Mw.js} +1 -1
- streamlit/static/static/js/embed.XT9xNd3F.js +195 -0
- streamlit/static/static/js/{es6.BJcsVXQ0.js → es6.x9KsYQg-.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.XzUvQqcZ.js → iframeResizer.contentWindow.ZVXpMPi0.js} +1 -1
- streamlit/static/static/js/index.5VPOamri.js +1 -0
- streamlit/static/static/js/index.8HslT92O.js +14 -0
- streamlit/static/static/js/index.AnXMIBz3.js +7 -0
- streamlit/static/static/js/index.B0yp3bM1.js +6 -0
- streamlit/static/static/js/index.B1fRb5wF.js +1 -0
- streamlit/static/static/js/index.B527JZdO.js +3 -0
- streamlit/static/static/js/index.BHgV-yW4.js +1 -0
- streamlit/static/static/js/index.BQr-XwGV.js +1 -0
- streamlit/static/static/js/index.BTtmaLDB.js +1 -0
- streamlit/static/static/js/index.BWB_91TA.js +1 -0
- streamlit/static/static/js/index.BfEKaEmw.js +1 -0
- streamlit/static/static/js/index.BfXjTO8b.js +1 -0
- streamlit/static/static/js/index.Bjy4NRu9.js +3 -0
- streamlit/static/static/js/index.Bu5JWpT_.js +1 -0
- streamlit/static/static/js/index.BuCx76ZV.js +1 -0
- streamlit/static/static/js/index.BxjzhVUb.js +2 -0
- streamlit/static/static/js/index.By55VdPY.js +1 -0
- streamlit/static/static/js/index.CF5MxTbK.js +1 -0
- streamlit/static/static/js/index.CLmq_z9K.js +1 -0
- streamlit/static/static/js/index.CNH4rdSz.js +1 -0
- streamlit/static/static/js/{index.D3GPA5k4.js → index.CTgm_-jO.js} +9 -40
- streamlit/static/static/js/index.C_rK-Swb.js +188 -0
- streamlit/static/static/js/index.CjozwSzS.js +1 -0
- streamlit/static/static/js/{index.DOFlg3dS.js → index.CkGVt6-G.js} +1 -1
- streamlit/static/static/js/index.CuvXOyER.js +2 -0
- streamlit/static/static/js/{index.B_dWA3vd.js → index.CyUHWoCC.js} +2 -2
- streamlit/static/static/js/index.CyroQtI4.js +2 -0
- streamlit/static/static/js/index.D6HmkoDm.js +263 -0
- streamlit/static/static/js/index.DAqCNvsO.js +1 -0
- streamlit/static/static/js/index.DB_w_CZQ.js +1 -0
- streamlit/static/static/js/index.DBalctjj.js +2 -0
- streamlit/static/static/js/index.DK0RFJUG.js +11 -0
- streamlit/static/static/js/index.DMxc2XFp.js +151 -0
- streamlit/static/static/js/index.DO5utP74.js +2 -0
- streamlit/static/static/js/index.DS7lf09n.js +1 -0
- streamlit/static/static/js/index.DWexTVLY.js +1 -0
- streamlit/static/static/js/index.DXxnU5ej.js +1 -0
- streamlit/static/static/js/index.DcU3uDvB.js +2 -0
- streamlit/static/static/js/index.DlltaH7J.js +1 -0
- streamlit/static/static/js/index.DpNTZz82.js +27 -0
- streamlit/static/static/js/index.Dr9HIhQw.js +1 -0
- streamlit/static/static/js/index.DsgAU5lc.js +1 -0
- streamlit/static/static/js/{index.DPUXkcQL.js → index.KfXqjDYy.js} +1 -1
- streamlit/static/static/js/index.PaidgjCs.js +1 -0
- streamlit/static/static/js/index.RJZuWCGA.js +1 -0
- streamlit/static/static/js/{index.CxIUUfab.js → index.hbeqcRTn.js} +53 -122
- streamlit/static/static/js/index.q5hIQwAY.js +1 -0
- streamlit/static/static/js/index.rORSX6IW.js +1 -0
- streamlit/static/static/js/index.uSX757_v.js +1 -0
- streamlit/static/static/js/index.x_QRaLMd.js +1 -0
- streamlit/static/static/js/{input.D4MN_FzN.js → input.D5oh9-aB.js} +2 -2
- streamlit/static/static/js/main.q9oGOg0H.js +13 -0
- streamlit/static/static/js/{memory.DrZjtdGT.js → memory.5kCSFUJS.js} +1 -1
- streamlit/static/static/js/moment.C3j7ZXd7.js +4 -0
- streamlit/static/static/js/number-overlay-editor.Cn_LsK8N.js +9 -0
- streamlit/static/static/js/pandasStylerUtils.BqhXt51_.js +1 -0
- streamlit/static/static/js/{possibleConstructorReturn.exeeJQEP.js → possibleConstructorReturn.DD9NK1Z8.js} +1 -1
- streamlit/static/static/js/{sandbox.ClO3IuUr.js → sandbox.DACSyz29.js} +1 -1
- streamlit/static/static/js/styled-components.C3R090At.js +1 -0
- streamlit/static/static/js/threshold.Q1mXg5rX.js +1 -0
- streamlit/static/static/js/throttle.B0GR3Iyz.js +1 -0
- streamlit/static/static/js/{timepicker.DAhu-vcF.js → timepicker.BdhzPxrv.js} +1 -1
- streamlit/static/static/js/timer.C2hYhUse.js +1 -0
- streamlit/static/static/js/{toConsumableArray.DNbljYEC.js → toConsumableArray.Db2pdqM2.js} +1 -1
- streamlit/static/static/js/uniqueId.CtqIr-Yh.js +1 -0
- streamlit/static/static/js/urls.BwSlolu9.js +1 -0
- streamlit/static/static/js/{useBasicWidgetState.D6sOH6oI.js → useBasicWidgetState.Bfp6TnSw.js} +1 -1
- streamlit/static/static/js/useIntlLocale.hRV75Xgj.js +12 -0
- streamlit/static/static/js/{useTextInputAutoExpand.4u3_GcuN.js → useTextInputAutoExpand.QepX7n8Y.js} +1 -1
- streamlit/static/static/js/useUpdateUiValue.DHx8TzX6.js +1 -0
- streamlit/static/static/js/useWaveformController.WxVzpzEX.js +1 -0
- streamlit/static/static/js/value.B4vHRSi7.js +1 -0
- streamlit/static/static/js/withCalculatedWidth.DcKeRSWJ.js +1 -0
- streamlit/static/static/js/withFullScreenWrapper.CrHddARq.js +1 -0
- streamlit/string_util.py +8 -1
- streamlit/testing/v1/app_test.py +15 -0
- streamlit/testing/v1/element_tree.py +62 -0
- streamlit/web/bootstrap.py +24 -0
- streamlit/web/server/oauth_authlib_routes.py +5 -2
- streamlit/web/server/upload_file_request_handler.py +16 -0
- {streamlit-1.51.0.dist-info → streamlit-1.52.0.dist-info}/METADATA +9 -5
- {streamlit-1.51.0.dist-info → streamlit-1.52.0.dist-info}/RECORD +274 -239
- streamlit/static/static/js/InputInstructions.jhH15PqV.js +0 -1
- streamlit/static/static/js/Particles.DUsputn1.js +0 -1
- streamlit/static/static/js/data-grid-overlay-editor.2Ufgxc6y.js +0 -1
- streamlit/static/static/js/index.B1ZQh4P1.js +0 -1
- streamlit/static/static/js/index.BKstZk0M.js +0 -27
- streamlit/static/static/js/index.BMcFsUee.js +0 -1
- streamlit/static/static/js/index.BR-IdcTb.js +0 -2
- streamlit/static/static/js/index.BgnZEMVh.js +0 -1
- streamlit/static/static/js/index.BohqXifI.js +0 -1
- streamlit/static/static/js/index.Br5nxKNj.js +0 -2
- streamlit/static/static/js/index.BrIKVbNc.js +0 -3
- streamlit/static/static/js/index.BtWUPzle.js +0 -1
- streamlit/static/static/js/index.C0RLraek.js +0 -1
- streamlit/static/static/js/index.CAIjskgG.js +0 -1
- streamlit/static/static/js/index.CAj-7vWz.js +0 -949
- streamlit/static/static/js/index.CMtEit2O.js +0 -1
- streamlit/static/static/js/index.CkRlykEE.js +0 -12
- streamlit/static/static/js/index.CmN3FXfI.js +0 -1617
- streamlit/static/static/js/index.CwbFI1_-.js +0 -1
- streamlit/static/static/js/index.D2KPNy7e.js +0 -1
- streamlit/static/static/js/index.DGAh7DMq.js +0 -1
- streamlit/static/static/js/index.DKb_NvmG.js +0 -197
- streamlit/static/static/js/index.DMqgUYKq.js +0 -1
- streamlit/static/static/js/index.DX1xY89g.js +0 -1
- streamlit/static/static/js/index.DYATBCsq.js +0 -2
- streamlit/static/static/js/index.DaSmGJ76.js +0 -3
- streamlit/static/static/js/index.Dd7bMeLP.js +0 -1
- streamlit/static/static/js/index.DjmmgI5U.js +0 -1
- streamlit/static/static/js/index.Dq56CyM2.js +0 -1
- streamlit/static/static/js/index.DuiXaS5_.js +0 -7
- streamlit/static/static/js/index.DvFidMLe.js +0 -2
- streamlit/static/static/js/index.DwkhC5Pc.js +0 -1
- streamlit/static/static/js/index.Q-3sFn1v.js +0 -1
- streamlit/static/static/js/index.QJ5QO9sJ.js +0 -1
- streamlit/static/static/js/index.VwTaeety.js +0 -1
- streamlit/static/static/js/index.YOqQbeX8.js +0 -1
- streamlit/static/static/js/number-overlay-editor.DRwAw1In.js +0 -9
- streamlit/static/static/js/uniqueId.oG4Gvj1v.js +0 -1
- streamlit/static/static/js/useUpdateUiValue.F2R3eTeR.js +0 -1
- streamlit/static/static/js/withFullScreenWrapper.zothJIsI.js +0 -1
- {streamlit-1.51.0.data → streamlit-1.52.0.data}/scripts/streamlit.cmd +0 -0
- {streamlit-1.51.0.dist-info → streamlit-1.52.0.dist-info}/WHEEL +0 -0
- {streamlit-1.51.0.dist-info → streamlit-1.52.0.dist-info}/entry_points.txt +0 -0
- {streamlit-1.51.0.dist-info → streamlit-1.52.0.dist-info}/top_level.txt +0 -0
streamlit/dataframe_util.py
CHANGED
|
@@ -153,7 +153,7 @@ class DataFrameGenericAlias(Protocol[V_co]):
|
|
|
153
153
|
class PandasCompatible(Protocol):
|
|
154
154
|
"""Protocol for Pandas compatible objects that have a `to_pandas` method."""
|
|
155
155
|
|
|
156
|
-
def to_pandas(self) -> DataFrame | Series: ...
|
|
156
|
+
def to_pandas(self) -> DataFrame | Series[Any]: ...
|
|
157
157
|
|
|
158
158
|
|
|
159
159
|
class DataframeInterchangeCompatible(Protocol):
|
|
@@ -177,9 +177,9 @@ OptionSequence: TypeAlias = (
|
|
|
177
177
|
# st.line_chart`...
|
|
178
178
|
Data: TypeAlias = Union[
|
|
179
179
|
"DataFrame",
|
|
180
|
-
"Series",
|
|
180
|
+
"Series[Any]",
|
|
181
181
|
"Styler",
|
|
182
|
-
"Index",
|
|
182
|
+
"Index[Any]",
|
|
183
183
|
"pa.Table",
|
|
184
184
|
"pa.Array",
|
|
185
185
|
"np.ndarray[Any, np.dtype[Any]]",
|
|
@@ -502,7 +502,7 @@ def _fix_column_naming(data_df: DataFrame) -> DataFrame:
|
|
|
502
502
|
which is not very descriptive.
|
|
503
503
|
"""
|
|
504
504
|
|
|
505
|
-
if len(data_df.columns) == 1 and data_df.columns[0] == 0:
|
|
505
|
+
if len(data_df.columns) == 1 and cast("Any", data_df.columns[0]) == 0:
|
|
506
506
|
# Pandas automatically names the first column with 0 if it is not named.
|
|
507
507
|
# We rename it to "value" to make it more descriptive if there is only
|
|
508
508
|
# one column in the dataframe.
|
|
@@ -566,13 +566,13 @@ def convert_anything_to_pandas_df(
|
|
|
566
566
|
import pandas as pd
|
|
567
567
|
|
|
568
568
|
if isinstance(data, pd.DataFrame):
|
|
569
|
-
return data.copy() if ensure_copy else
|
|
569
|
+
return data.copy() if ensure_copy else data
|
|
570
570
|
|
|
571
571
|
if isinstance(data, (pd.Series, pd.Index, pd.api.extensions.ExtensionArray)):
|
|
572
572
|
return pd.DataFrame(data)
|
|
573
573
|
|
|
574
574
|
if is_pandas_styler(data):
|
|
575
|
-
return cast("pd.DataFrame", data.data.copy() if ensure_copy else data.data)
|
|
575
|
+
return cast("pd.DataFrame", data.data.copy() if ensure_copy else data.data) # type: ignore
|
|
576
576
|
|
|
577
577
|
if isinstance(data, np.ndarray):
|
|
578
578
|
return (
|
|
@@ -583,11 +583,11 @@ def convert_anything_to_pandas_df(
|
|
|
583
583
|
|
|
584
584
|
if is_polars_dataframe(data):
|
|
585
585
|
data = data.clone() if ensure_copy else data
|
|
586
|
-
return data.to_pandas()
|
|
586
|
+
return cast("pd.DataFrame", data.to_pandas())
|
|
587
587
|
|
|
588
588
|
if is_polars_series(data):
|
|
589
589
|
data = data.clone() if ensure_copy else data
|
|
590
|
-
return data.to_pandas().to_frame()
|
|
590
|
+
return cast("pd.DataFrame", data.to_pandas().to_frame())
|
|
591
591
|
|
|
592
592
|
if is_polars_lazyframe(data):
|
|
593
593
|
data = data.limit(max_unevaluated_rows).collect().to_pandas()
|
|
@@ -601,12 +601,12 @@ def convert_anything_to_pandas_df(
|
|
|
601
601
|
if is_xarray_dataset(data):
|
|
602
602
|
if ensure_copy:
|
|
603
603
|
data = data.copy(deep=True)
|
|
604
|
-
return data.to_dataframe()
|
|
604
|
+
return cast("pd.DataFrame", data.to_dataframe())
|
|
605
605
|
|
|
606
606
|
if is_xarray_data_array(data):
|
|
607
607
|
if ensure_copy:
|
|
608
608
|
data = data.copy(deep=True)
|
|
609
|
-
return data.to_series().to_frame()
|
|
609
|
+
return cast("pd.DataFrame", data.to_series().to_frame())
|
|
610
610
|
|
|
611
611
|
if is_dask_object(data):
|
|
612
612
|
data = data.head(max_unevaluated_rows, compute=True)
|
|
@@ -684,7 +684,7 @@ def convert_anything_to_pandas_df(
|
|
|
684
684
|
f"⚠️ Showing only {string_util.simplify_number(max_unevaluated_rows)} "
|
|
685
685
|
"rows. Call `df()` on the relation to show more."
|
|
686
686
|
)
|
|
687
|
-
return data
|
|
687
|
+
return cast("pd.DataFrame", data)
|
|
688
688
|
|
|
689
689
|
if is_dbapi_cursor(data):
|
|
690
690
|
# Based on the specification, the first item in the description is the
|
|
@@ -698,7 +698,7 @@ def convert_anything_to_pandas_df(
|
|
|
698
698
|
f"⚠️ Showing only {string_util.simplify_number(max_unevaluated_rows)} "
|
|
699
699
|
"rows. Call `fetchall()` on the Cursor to show more."
|
|
700
700
|
)
|
|
701
|
-
return data
|
|
701
|
+
return cast("DataFrame", data) # ty: ignore[redundant-cast]
|
|
702
702
|
|
|
703
703
|
if is_snowpark_row_list(data):
|
|
704
704
|
return pd.DataFrame([row.as_dict() for row in data])
|
|
@@ -727,7 +727,7 @@ def convert_anything_to_pandas_df(
|
|
|
727
727
|
f"⚠️ Showing only {string_util.simplify_number(max_unevaluated_rows)} "
|
|
728
728
|
"rows. Convert the data to a list to show more."
|
|
729
729
|
)
|
|
730
|
-
return data
|
|
730
|
+
return cast("DataFrame", data) # ty: ignore[redundant-cast]
|
|
731
731
|
|
|
732
732
|
if isinstance(data, EnumMeta):
|
|
733
733
|
# Support for enum classes
|
|
@@ -859,7 +859,7 @@ def convert_arrow_bytes_to_pandas_df(source: bytes) -> DataFrame:
|
|
|
859
859
|
import pyarrow as pa
|
|
860
860
|
|
|
861
861
|
reader = pa.RecordBatchStreamReader(source)
|
|
862
|
-
return reader.read_pandas()
|
|
862
|
+
return cast("DataFrame", reader.read_pandas())
|
|
863
863
|
|
|
864
864
|
|
|
865
865
|
def _show_data_information(msg: str) -> None:
|
|
@@ -1040,7 +1040,7 @@ def _maybe_truncate_table(
|
|
|
1040
1040
|
return table
|
|
1041
1041
|
|
|
1042
1042
|
|
|
1043
|
-
def is_colum_type_arrow_incompatible(column: Series[Any] | Index) -> bool:
|
|
1043
|
+
def is_colum_type_arrow_incompatible(column: Series[Any] | Index[Any]) -> bool:
|
|
1044
1044
|
"""Return True if the column type is known to cause issues during
|
|
1045
1045
|
Arrow conversion.
|
|
1046
1046
|
"""
|
|
@@ -1281,7 +1281,7 @@ def _unify_missing_values(df: DataFrame) -> DataFrame:
|
|
|
1281
1281
|
# then infer objects without creating a separate copy:
|
|
1282
1282
|
# For performance reasons, we could use copy=False here.
|
|
1283
1283
|
# However, this is only available in pandas >=2.
|
|
1284
|
-
return df.replace([pd.NA, pd.NaT, np.nan], None).infer_objects()
|
|
1284
|
+
return df.replace([pd.NA, pd.NaT, np.nan], None).infer_objects() # type: ignore
|
|
1285
1285
|
|
|
1286
1286
|
|
|
1287
1287
|
def _pandas_df_to_series(df: DataFrame) -> Series[Any]:
|
|
@@ -1297,7 +1297,7 @@ def _pandas_df_to_series(df: DataFrame) -> Series[Any]:
|
|
|
1297
1297
|
raise ValueError(
|
|
1298
1298
|
f"DataFrame is expected to have a single column but has {len(df.columns)}."
|
|
1299
1299
|
)
|
|
1300
|
-
return df
|
|
1300
|
+
return df.iloc[:, 0]
|
|
1301
1301
|
|
|
1302
1302
|
|
|
1303
1303
|
def convert_pandas_df_to_data_format(
|
|
@@ -1404,7 +1404,7 @@ def convert_pandas_df_to_data_format(
|
|
|
1404
1404
|
return_list = []
|
|
1405
1405
|
if len(df.columns) == 1:
|
|
1406
1406
|
# Get the first column and convert to list
|
|
1407
|
-
return_list = df
|
|
1407
|
+
return_list = df.iloc[:, 0].tolist()
|
|
1408
1408
|
elif len(df.columns) >= 1:
|
|
1409
1409
|
raise ValueError(
|
|
1410
1410
|
"DataFrame is expected to have a single column but "
|
streamlit/delta_generator.py
CHANGED
|
@@ -64,7 +64,9 @@ from streamlit.elements.layouts import LayoutsMixin
|
|
|
64
64
|
from streamlit.elements.lib.form_utils import FormData, current_form_id
|
|
65
65
|
from streamlit.elements.lib.layout_utils import (
|
|
66
66
|
get_height_config,
|
|
67
|
+
get_text_alignment_config,
|
|
67
68
|
get_width_config,
|
|
69
|
+
validate_text_alignment,
|
|
68
70
|
)
|
|
69
71
|
from streamlit.elements.map import MapMixin
|
|
70
72
|
from streamlit.elements.markdown import MarkdownMixin
|
|
@@ -495,6 +497,11 @@ class DeltaGenerator(
|
|
|
495
497
|
msg.delta.new_element.width_config.CopyFrom(
|
|
496
498
|
get_width_config(layout_config.width)
|
|
497
499
|
)
|
|
500
|
+
if layout_config.text_alignment is not None:
|
|
501
|
+
validate_text_alignment(layout_config.text_alignment)
|
|
502
|
+
msg.delta.new_element.text_alignment_config.CopyFrom(
|
|
503
|
+
get_text_alignment_config(layout_config.text_alignment)
|
|
504
|
+
)
|
|
498
505
|
|
|
499
506
|
# Only enqueue message and fill in metadata if there's a container.
|
|
500
507
|
msg_was_enqueued = False
|
|
@@ -145,28 +145,22 @@ class ContextVarWithLazyDefault(Generic[_T]):
|
|
|
145
145
|
self._default = default
|
|
146
146
|
self._context_var: ContextVar[_T] | None = None
|
|
147
147
|
|
|
148
|
-
def
|
|
149
|
-
self._context_var
|
|
148
|
+
def _ensure_context_var(self) -> ContextVar[_T]:
|
|
149
|
+
if self._context_var is None:
|
|
150
|
+
self._context_var = ContextVar(self._name, default=self._default()) # noqa: B039
|
|
151
|
+
return self._context_var
|
|
150
152
|
|
|
151
153
|
def get(self) -> _T:
|
|
152
|
-
|
|
153
|
-
self._init_context_var()
|
|
154
|
-
return self._context_var.get() # type: ignore[union-attr]
|
|
154
|
+
return self._ensure_context_var().get()
|
|
155
155
|
|
|
156
156
|
def set(self, value: _T) -> Token[_T]:
|
|
157
|
-
|
|
158
|
-
self._init_context_var()
|
|
159
|
-
return self._context_var.set(value) # type: ignore[union-attr]
|
|
157
|
+
return self._ensure_context_var().set(value)
|
|
160
158
|
|
|
161
159
|
def reset(self, token: Token[_T]) -> None:
|
|
162
|
-
|
|
163
|
-
self._init_context_var()
|
|
164
|
-
self._context_var.reset(token) # type: ignore[union-attr]
|
|
160
|
+
self._ensure_context_var().reset(token)
|
|
165
161
|
|
|
166
162
|
def __hash__(self) -> int:
|
|
167
|
-
|
|
168
|
-
self._init_context_var()
|
|
169
|
-
return self._context_var.__hash__()
|
|
163
|
+
return self._ensure_context_var().__hash__()
|
|
170
164
|
|
|
171
165
|
|
|
172
166
|
# we don't use the default factory here because `main_dg` is not initialized when this
|
streamlit/elements/alert.py
CHANGED
|
@@ -50,6 +50,7 @@ class AlertMixin:
|
|
|
50
50
|
|
|
51
51
|
.. |st.markdown| replace:: ``st.markdown``
|
|
52
52
|
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
|
53
|
+
|
|
53
54
|
icon : str, None
|
|
54
55
|
An optional emoji or icon to display next to the alert. If ``icon``
|
|
55
56
|
is ``None`` (default), no icon is displayed. If ``icon`` is a
|
|
@@ -66,6 +67,9 @@ class AlertMixin:
|
|
|
66
67
|
Thumb Up icon. Find additional icons in the `Material Symbols \
|
|
67
68
|
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
|
|
68
69
|
font library.
|
|
70
|
+
|
|
71
|
+
- ``"spinner"``: Displays a spinner as an icon.
|
|
72
|
+
|
|
69
73
|
width : "stretch" or int
|
|
70
74
|
The width of the alert element. This can be one of the following:
|
|
71
75
|
|
|
@@ -123,6 +127,7 @@ class AlertMixin:
|
|
|
123
127
|
|
|
124
128
|
.. |st.markdown| replace:: ``st.markdown``
|
|
125
129
|
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
|
130
|
+
|
|
126
131
|
icon : str, None
|
|
127
132
|
An optional emoji or icon to display next to the alert. If ``icon``
|
|
128
133
|
is ``None`` (default), no icon is displayed. If ``icon`` is a
|
|
@@ -139,6 +144,9 @@ class AlertMixin:
|
|
|
139
144
|
Thumb Up icon. Find additional icons in the `Material Symbols \
|
|
140
145
|
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
|
|
141
146
|
font library.
|
|
147
|
+
|
|
148
|
+
- ``"spinner"``: Displays a spinner as an icon.
|
|
149
|
+
|
|
142
150
|
width : "stretch" or int
|
|
143
151
|
The width of the warning element. This can be one of the following:
|
|
144
152
|
|
|
@@ -195,6 +203,7 @@ class AlertMixin:
|
|
|
195
203
|
|
|
196
204
|
.. |st.markdown| replace:: ``st.markdown``
|
|
197
205
|
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
|
206
|
+
|
|
198
207
|
icon : str, None
|
|
199
208
|
An optional emoji or icon to display next to the alert. If ``icon``
|
|
200
209
|
is ``None`` (default), no icon is displayed. If ``icon`` is a
|
|
@@ -211,6 +220,9 @@ class AlertMixin:
|
|
|
211
220
|
Thumb Up icon. Find additional icons in the `Material Symbols \
|
|
212
221
|
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
|
|
213
222
|
font library.
|
|
223
|
+
|
|
224
|
+
- ``"spinner"``: Displays a spinner as an icon.
|
|
225
|
+
|
|
214
226
|
width : "stretch" or int
|
|
215
227
|
The width of the info element. This can be one of the following:
|
|
216
228
|
|
|
@@ -268,6 +280,7 @@ class AlertMixin:
|
|
|
268
280
|
|
|
269
281
|
.. |st.markdown| replace:: ``st.markdown``
|
|
270
282
|
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
|
283
|
+
|
|
271
284
|
icon : str, None
|
|
272
285
|
An optional emoji or icon to display next to the alert. If ``icon``
|
|
273
286
|
is ``None`` (default), no icon is displayed. If ``icon`` is a
|
|
@@ -284,6 +297,9 @@ class AlertMixin:
|
|
|
284
297
|
Thumb Up icon. Find additional icons in the `Material Symbols \
|
|
285
298
|
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
|
|
286
299
|
font library.
|
|
300
|
+
|
|
301
|
+
- ``"spinner"``: Displays a spinner as an icon.
|
|
302
|
+
|
|
287
303
|
width : "stretch" or int
|
|
288
304
|
The width of the success element. This can be one of the following:
|
|
289
305
|
|
streamlit/elements/arrow.py
CHANGED
|
@@ -42,7 +42,7 @@ from streamlit.elements.lib.column_config_utils import (
|
|
|
42
42
|
)
|
|
43
43
|
from streamlit.elements.lib.form_utils import current_form_id
|
|
44
44
|
from streamlit.elements.lib.layout_utils import (
|
|
45
|
-
|
|
45
|
+
Height,
|
|
46
46
|
LayoutConfig,
|
|
47
47
|
Width,
|
|
48
48
|
validate_height,
|
|
@@ -287,7 +287,7 @@ class ArrowMixin:
|
|
|
287
287
|
self,
|
|
288
288
|
data: Data = None,
|
|
289
289
|
width: Width = "stretch",
|
|
290
|
-
height:
|
|
290
|
+
height: Height | Literal["auto"] = "auto",
|
|
291
291
|
*,
|
|
292
292
|
use_container_width: bool | None = None,
|
|
293
293
|
hide_index: bool | None = None,
|
|
@@ -297,6 +297,7 @@ class ArrowMixin:
|
|
|
297
297
|
on_select: Literal["ignore"] = "ignore",
|
|
298
298
|
selection_mode: SelectionMode | Iterable[SelectionMode] = "multi-row",
|
|
299
299
|
row_height: int | None = None,
|
|
300
|
+
placeholder: str | None = None,
|
|
300
301
|
) -> DeltaGenerator: ...
|
|
301
302
|
|
|
302
303
|
@overload
|
|
@@ -304,7 +305,7 @@ class ArrowMixin:
|
|
|
304
305
|
self,
|
|
305
306
|
data: Data = None,
|
|
306
307
|
width: Width = "stretch",
|
|
307
|
-
height:
|
|
308
|
+
height: Height | Literal["auto"] = "auto",
|
|
308
309
|
*,
|
|
309
310
|
use_container_width: bool | None = None,
|
|
310
311
|
hide_index: bool | None = None,
|
|
@@ -314,6 +315,7 @@ class ArrowMixin:
|
|
|
314
315
|
on_select: Literal["rerun"] | WidgetCallback,
|
|
315
316
|
selection_mode: SelectionMode | Iterable[SelectionMode] = "multi-row",
|
|
316
317
|
row_height: int | None = None,
|
|
318
|
+
placeholder: str | None = None,
|
|
317
319
|
) -> DataframeState: ...
|
|
318
320
|
|
|
319
321
|
@gather_metrics("dataframe")
|
|
@@ -321,7 +323,7 @@ class ArrowMixin:
|
|
|
321
323
|
self,
|
|
322
324
|
data: Data = None,
|
|
323
325
|
width: Width = "stretch",
|
|
324
|
-
height:
|
|
326
|
+
height: Height | Literal["auto"] = "auto",
|
|
325
327
|
*,
|
|
326
328
|
use_container_width: bool | None = None,
|
|
327
329
|
hide_index: bool | None = None,
|
|
@@ -331,6 +333,7 @@ class ArrowMixin:
|
|
|
331
333
|
on_select: Literal["ignore", "rerun"] | WidgetCallback = "ignore",
|
|
332
334
|
selection_mode: SelectionMode | Iterable[SelectionMode] = "multi-row",
|
|
333
335
|
row_height: int | None = None,
|
|
336
|
+
placeholder: str | None = None,
|
|
334
337
|
) -> DeltaGenerator | DataframeState:
|
|
335
338
|
"""Display a dataframe as an interactive table.
|
|
336
339
|
|
|
@@ -389,11 +392,14 @@ class ArrowMixin:
|
|
|
389
392
|
the parent container, the width of the element matches the width
|
|
390
393
|
of the parent container.
|
|
391
394
|
|
|
392
|
-
height : "auto", "stretch", or int
|
|
395
|
+
height : "auto", "content", "stretch", or int
|
|
393
396
|
The height of the dataframe element. This can be one of the following:
|
|
394
397
|
|
|
395
398
|
- ``"auto"`` (default): Streamlit sets the height to show at most
|
|
396
399
|
ten rows.
|
|
400
|
+
- ``"content"``: The height of the element matches the height of
|
|
401
|
+
its content. The height is capped at 10,000 pixels to prevent
|
|
402
|
+
performance issues with very large dataframes.
|
|
397
403
|
- ``"stretch"``: The height of the element expands to fill the
|
|
398
404
|
available vertical space in its parent container. When multiple
|
|
399
405
|
elements with stretch height are in the same container, they
|
|
@@ -510,6 +516,12 @@ class ArrowMixin:
|
|
|
510
516
|
is ``None`` (default), Streamlit will use a default row height,
|
|
511
517
|
which fits one line of text.
|
|
512
518
|
|
|
519
|
+
placeholder : str or None
|
|
520
|
+
The text that should be shown for missing values. If this is
|
|
521
|
+
``None`` (default), missing values are displayed as "None". To
|
|
522
|
+
leave a cell empty, use an empty string (``""``). Other common
|
|
523
|
+
values are ``"null"``, ``"NaN"`` and ``"-"``.
|
|
524
|
+
|
|
513
525
|
Returns
|
|
514
526
|
-------
|
|
515
527
|
element or dict
|
|
@@ -676,7 +688,7 @@ class ArrowMixin:
|
|
|
676
688
|
validate_width(width, allow_content=True)
|
|
677
689
|
validate_height(
|
|
678
690
|
height,
|
|
679
|
-
allow_content=
|
|
691
|
+
allow_content=True,
|
|
680
692
|
additional_allowed=["auto"],
|
|
681
693
|
)
|
|
682
694
|
|
|
@@ -691,6 +703,9 @@ class ArrowMixin:
|
|
|
691
703
|
if column_order:
|
|
692
704
|
proto.column_order[:] = column_order
|
|
693
705
|
|
|
706
|
+
if placeholder is not None:
|
|
707
|
+
proto.placeholder = placeholder
|
|
708
|
+
|
|
694
709
|
proto.editing_mode = ArrowProto.EditingMode.READ_ONLY
|
|
695
710
|
|
|
696
711
|
has_range_index: bool = False
|
|
@@ -767,6 +782,7 @@ class ArrowMixin:
|
|
|
767
782
|
selection_mode=selection_mode,
|
|
768
783
|
is_selection_activated=is_selection_activated,
|
|
769
784
|
row_height=row_height,
|
|
785
|
+
placeholder=placeholder,
|
|
770
786
|
)
|
|
771
787
|
|
|
772
788
|
serde = DataframeSelectionSerde()
|
|
@@ -895,6 +911,12 @@ class ArrowMixin:
|
|
|
895
911
|
def add_rows(self, data: Data = None, **kwargs: Any) -> DeltaGenerator | None:
|
|
896
912
|
"""Concatenate a dataframe to the bottom of the current one.
|
|
897
913
|
|
|
914
|
+
.. important::
|
|
915
|
+
``add_rows`` is deprecated and might be removed in a future version.
|
|
916
|
+
If you have a specific use-case that requires the ``add_rows``
|
|
917
|
+
functionality, please tell us via this
|
|
918
|
+
[issue on Github](https://github.com/streamlit/streamlit/issues/13063).
|
|
919
|
+
|
|
898
920
|
Parameters
|
|
899
921
|
----------
|
|
900
922
|
data : pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, Iterable, dict, or None
|
|
@@ -947,6 +969,14 @@ class ArrowMixin:
|
|
|
947
969
|
>>> my_chart.add_rows(some_fancy_name=df2) # <-- name used as keyword
|
|
948
970
|
|
|
949
971
|
""" # noqa: E501
|
|
972
|
+
show_deprecation_warning(
|
|
973
|
+
"`add_rows` is deprecated and might be removed in a future version."
|
|
974
|
+
" If you have a specific use-case that requires the `add_rows` "
|
|
975
|
+
"functionality, please tell us via this "
|
|
976
|
+
"[issue on Github](https://github.com/streamlit/streamlit/issues/13063).",
|
|
977
|
+
show_in_browser=False,
|
|
978
|
+
)
|
|
979
|
+
|
|
950
980
|
return _arrow_add_rows(self.dg, data, **kwargs)
|
|
951
981
|
|
|
952
982
|
@property
|
|
@@ -16,48 +16,33 @@
|
|
|
16
16
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
-
import
|
|
20
|
-
from typing import TYPE_CHECKING, Final, cast
|
|
19
|
+
from typing import TYPE_CHECKING, cast
|
|
21
20
|
|
|
22
21
|
from streamlit.deprecation_util import (
|
|
23
22
|
show_deprecation_warning,
|
|
24
23
|
)
|
|
25
|
-
from streamlit.errors import StreamlitAPIException
|
|
26
|
-
from streamlit.proto.BokehChart_pb2 import BokehChart as BokehChartProto
|
|
27
24
|
from streamlit.runtime.metrics_util import gather_metrics
|
|
28
|
-
from streamlit.util import calc_md5
|
|
29
25
|
|
|
30
26
|
if TYPE_CHECKING:
|
|
31
|
-
from bokeh.plotting.figure import Figure
|
|
32
|
-
|
|
33
27
|
from streamlit.delta_generator import DeltaGenerator
|
|
34
28
|
|
|
35
|
-
ST_BOKEH_VERSION: Final = "2.4.3"
|
|
36
|
-
|
|
37
29
|
|
|
38
30
|
class BokehMixin:
|
|
39
31
|
@gather_metrics("bokeh_chart")
|
|
40
32
|
def bokeh_chart(
|
|
41
33
|
self,
|
|
42
|
-
figure:
|
|
43
|
-
use_container_width: bool = True,
|
|
34
|
+
figure: object, # noqa: ARG002
|
|
35
|
+
use_container_width: bool = True, # noqa: ARG002
|
|
44
36
|
) -> DeltaGenerator:
|
|
45
37
|
"""Display an interactive Bokeh chart.
|
|
46
38
|
|
|
47
|
-
Bokeh is a charting library for Python.
|
|
48
|
-
closely follow the ones for Bokeh's ``show`` function. You can find
|
|
39
|
+
Bokeh is a charting library for Python. You can find
|
|
49
40
|
more about Bokeh at https://bokeh.pydata.org.
|
|
50
41
|
|
|
51
|
-
To show Bokeh charts in Streamlit, call ``st.bokeh_chart``
|
|
52
|
-
wherever you would call Bokeh's ``show``.
|
|
53
|
-
|
|
54
42
|
.. Important::
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
For more current updates, use the |streamlit-bokeh|_ custom
|
|
60
|
-
component instead.
|
|
43
|
+
This command has been deprecated and removed. Please use our custom
|
|
44
|
+
component, |streamlit-bokeh|_, instead. Calling st.bokeh_chart will
|
|
45
|
+
do nothing.
|
|
61
46
|
|
|
62
47
|
.. |streamlit-bokeh| replace:: ``streamlit-bokeh``
|
|
63
48
|
.. _streamlit-bokeh: https://github.com/streamlit/streamlit-bokeh
|
|
@@ -74,70 +59,17 @@ class BokehMixin:
|
|
|
74
59
|
container. If ``use_container_width`` is ``False``, Streamlit sets the
|
|
75
60
|
width of the chart to fit its contents according to the plotting library,
|
|
76
61
|
up to the width of the parent container.
|
|
77
|
-
|
|
78
|
-
Example
|
|
79
|
-
-------
|
|
80
|
-
>>> import streamlit as st
|
|
81
|
-
>>> from bokeh.plotting import figure
|
|
82
|
-
>>>
|
|
83
|
-
>>> x = [1, 2, 3, 4, 5]
|
|
84
|
-
>>> y = [6, 7, 2, 4, 5]
|
|
85
|
-
>>>
|
|
86
|
-
>>> p = figure(title="simple line example", x_axis_label="x", y_axis_label="y")
|
|
87
|
-
>>> p.line(x, y, legend_label="Trend", line_width=2)
|
|
88
|
-
>>>
|
|
89
|
-
>>> st.bokeh_chart(p)
|
|
90
|
-
|
|
91
|
-
.. output::
|
|
92
|
-
https://doc-bokeh-chart.streamlit.app/
|
|
93
|
-
height: 700px
|
|
94
|
-
|
|
95
62
|
"""
|
|
96
|
-
import bokeh
|
|
97
|
-
|
|
98
|
-
if bokeh.__version__ != ST_BOKEH_VERSION:
|
|
99
|
-
raise StreamlitAPIException(
|
|
100
|
-
f"Streamlit only supports Bokeh version {ST_BOKEH_VERSION}, "
|
|
101
|
-
f"but you have version {bokeh.__version__} installed. Please "
|
|
102
|
-
f"run `pip install --force-reinstall --no-deps bokeh=="
|
|
103
|
-
f"{ST_BOKEH_VERSION}` to install the correct version.\n\n\n"
|
|
104
|
-
f"To use the latest version of Bokeh, install our custom component, "
|
|
105
|
-
f"[streamlit-bokeh](https://github.com/streamlit/streamlit-bokeh)."
|
|
106
|
-
)
|
|
107
63
|
|
|
108
64
|
show_deprecation_warning(
|
|
109
|
-
"st.bokeh_chart
|
|
65
|
+
"st.bokeh_chart has been deprecated and removed. "
|
|
110
66
|
"Please use our custom component, "
|
|
111
67
|
"[streamlit-bokeh](https://github.com/streamlit/streamlit-bokeh), "
|
|
112
|
-
"instead."
|
|
68
|
+
"instead. Calling st.bokeh_chart will do nothing."
|
|
113
69
|
)
|
|
114
|
-
|
|
115
|
-
delta_path = self.dg._get_delta_path_str()
|
|
116
|
-
|
|
117
|
-
element_id = calc_md5(delta_path.encode())
|
|
118
|
-
bokeh_chart_proto = BokehChartProto()
|
|
119
|
-
marshall(bokeh_chart_proto, figure, use_container_width, element_id)
|
|
120
|
-
return self.dg._enqueue("bokeh_chart", bokeh_chart_proto)
|
|
70
|
+
return self.dg
|
|
121
71
|
|
|
122
72
|
@property
|
|
123
73
|
def dg(self) -> DeltaGenerator:
|
|
124
74
|
"""Get our DeltaGenerator."""
|
|
125
75
|
return cast("DeltaGenerator", self)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
def marshall(
|
|
129
|
-
proto: BokehChartProto,
|
|
130
|
-
figure: Figure,
|
|
131
|
-
use_container_width: bool,
|
|
132
|
-
element_id: str,
|
|
133
|
-
) -> None:
|
|
134
|
-
"""Construct a Bokeh chart object.
|
|
135
|
-
|
|
136
|
-
See DeltaGenerator.bokeh_chart for docs.
|
|
137
|
-
"""
|
|
138
|
-
from bokeh.embed import json_item
|
|
139
|
-
|
|
140
|
-
data = json_item(figure)
|
|
141
|
-
proto.figure = json.dumps(data)
|
|
142
|
-
proto.use_container_width = use_container_width
|
|
143
|
-
proto.element_id = element_id
|
streamlit/elements/code.py
CHANGED
|
@@ -109,7 +109,7 @@ class CodeMixin:
|
|
|
109
109
|
... print("Hello, Streamlit!")'''
|
|
110
110
|
>>> st.code(code, language="python")
|
|
111
111
|
|
|
112
|
-
.. output
|
|
112
|
+
.. output::
|
|
113
113
|
https://doc-code.streamlit.app/
|
|
114
114
|
height: 220px
|
|
115
115
|
|
|
@@ -129,7 +129,7 @@ class CodeMixin:
|
|
|
129
129
|
... '''
|
|
130
130
|
>>> st.code(code, language=None)
|
|
131
131
|
|
|
132
|
-
.. output
|
|
132
|
+
.. output::
|
|
133
133
|
https://doc-code-ascii.streamlit.app/
|
|
134
134
|
height: 380px
|
|
135
135
|
"""
|
streamlit/elements/exception.py
CHANGED
streamlit/elements/form.py
CHANGED
|
@@ -250,6 +250,7 @@ class FormMixin:
|
|
|
250
250
|
disabled: bool = False,
|
|
251
251
|
use_container_width: bool | None = None,
|
|
252
252
|
width: Width = "content",
|
|
253
|
+
shortcut: str | None = None,
|
|
253
254
|
) -> bool:
|
|
254
255
|
r"""Display a form submit button.
|
|
255
256
|
|
|
@@ -332,6 +333,8 @@ class FormMixin:
|
|
|
332
333
|
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
|
|
333
334
|
font library.
|
|
334
335
|
|
|
336
|
+
- ``"spinner"``: Displays a spinner as an icon.
|
|
337
|
+
|
|
335
338
|
disabled : bool
|
|
336
339
|
Whether to disable the button. If this is ``False`` (default), the
|
|
337
340
|
user can interact with the button. If this is ``True``, the button
|
|
@@ -369,6 +372,27 @@ class FormMixin:
|
|
|
369
372
|
the parent container, the width of the button matches the width
|
|
370
373
|
of the parent container.
|
|
371
374
|
|
|
375
|
+
shortcut : str or None
|
|
376
|
+
An optional keyboard shortcut that triggers the button. This can be
|
|
377
|
+
one of the following strings:
|
|
378
|
+
|
|
379
|
+
- A single alphanumeric key like ``"K"`` or ``"4"``.
|
|
380
|
+
- A function key like ``"F11"``.
|
|
381
|
+
- A special key like ``"Enter"``, ``"Esc"``, or ``"Tab"``.
|
|
382
|
+
- Any of the above combined with modifiers. For example, you can use
|
|
383
|
+
``"Ctrl+K"`` or ``"Cmd+Shift+O"``.
|
|
384
|
+
|
|
385
|
+
.. important::
|
|
386
|
+
The keys ``"C"`` and ``"R"`` are reserved and can't be used,
|
|
387
|
+
even with modifiers. Punctuation keys like ``"."`` and ``","``
|
|
388
|
+
aren't currently supported.
|
|
389
|
+
|
|
390
|
+
For a list of supported keys and modifiers, see the documentation
|
|
391
|
+
for |st.button|_.
|
|
392
|
+
|
|
393
|
+
.. |st.button| replace:: ``st.button``
|
|
394
|
+
.. _st.button: https://docs.streamlit.io/develop/api-reference/widgets/st.button
|
|
395
|
+
|
|
372
396
|
Returns
|
|
373
397
|
-------
|
|
374
398
|
bool
|
|
@@ -398,6 +422,7 @@ class FormMixin:
|
|
|
398
422
|
ctx=ctx,
|
|
399
423
|
width=width,
|
|
400
424
|
key=key,
|
|
425
|
+
shortcut=shortcut,
|
|
401
426
|
)
|
|
402
427
|
|
|
403
428
|
def _form_submit_button(
|
|
@@ -414,6 +439,7 @@ class FormMixin:
|
|
|
414
439
|
disabled: bool = False,
|
|
415
440
|
ctx: ScriptRunContext | None = None,
|
|
416
441
|
width: Width = "content",
|
|
442
|
+
shortcut: str | None = None,
|
|
417
443
|
) -> bool:
|
|
418
444
|
form_id = current_form_id(self.dg)
|
|
419
445
|
submit_button_key = to_key(key) or f"FormSubmitter:{form_id}-{label}"
|
|
@@ -430,6 +456,7 @@ class FormMixin:
|
|
|
430
456
|
disabled=disabled,
|
|
431
457
|
ctx=ctx,
|
|
432
458
|
width=width,
|
|
459
|
+
shortcut=shortcut,
|
|
433
460
|
)
|
|
434
461
|
|
|
435
462
|
@property
|