streamlit-nightly 1.36.1.dev20240702__py2.py3-none-any.whl → 1.36.1.dev20240703__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/commands/navigation.py +1 -1
- streamlit/components/v1/component_arrow.py +16 -11
- streamlit/components/v1/custom_component.py +2 -1
- streamlit/dataframe_util.py +835 -0
- streamlit/delta_generator.py +5 -3
- streamlit/elements/arrow.py +17 -13
- streamlit/elements/lib/built_in_chart_utils.py +78 -12
- streamlit/elements/lib/column_config_utils.py +1 -1
- streamlit/elements/lib/pandas_styler_utils.py +2 -2
- streamlit/elements/lib/policies.py +20 -2
- streamlit/elements/lib/utils.py +100 -10
- streamlit/elements/map.py +2 -2
- streamlit/elements/metric.py +5 -2
- streamlit/elements/plotly_chart.py +1 -1
- streamlit/elements/vega_charts.py +6 -5
- streamlit/elements/widgets/button.py +1 -1
- streamlit/elements/widgets/camera_input.py +7 -2
- streamlit/elements/widgets/chat.py +1 -1
- streamlit/elements/widgets/checkbox.py +7 -2
- streamlit/elements/widgets/color_picker.py +7 -2
- streamlit/elements/widgets/data_editor.py +10 -9
- streamlit/elements/widgets/file_uploader.py +7 -2
- streamlit/elements/widgets/multiselect.py +6 -7
- streamlit/elements/widgets/number_input.py +7 -2
- streamlit/elements/widgets/radio.py +6 -7
- streamlit/elements/widgets/select_slider.py +6 -7
- streamlit/elements/widgets/selectbox.py +6 -7
- streamlit/elements/widgets/slider.py +7 -2
- streamlit/elements/widgets/text_widgets.py +8 -5
- streamlit/elements/widgets/time_widgets.py +7 -2
- streamlit/elements/write.py +5 -5
- streamlit/runtime/caching/cache_utils.py +1 -1
- streamlit/runtime/state/common.py +51 -2
- streamlit/runtime/state/session_state.py +2 -1
- streamlit/runtime/state/session_state_proxy.py +1 -1
- streamlit/runtime/state/widgets.py +1 -1
- streamlit/static/asset-manifest.json +2 -2
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{main.e2ab315a.js → main.28e3c6e9.js} +2 -2
- streamlit/testing/v1/element_tree.py +3 -3
- streamlit/type_util.py +0 -1069
- {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/RECORD +48 -47
- /streamlit/static/static/js/{main.e2ab315a.js.LICENSE.txt → main.28e3c6e9.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.36.1.dev20240702.data → streamlit_nightly-1.36.1.dev20240703.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.36.1.dev20240702.dist-info → streamlit_nightly-1.36.1.dev20240703.dist-info}/top_level.txt +0 -0
streamlit/commands/navigation.py
CHANGED
@@ -155,7 +155,7 @@ def navigation(
|
|
155
155
|
>>> st.sidebar.selectbox("Foo", ["A", "B", "C"], key="foo")
|
156
156
|
>>> st.sidebar.checkbox("Bar", key="bar")
|
157
157
|
>>>
|
158
|
-
>>> pg = st.navigation(st.Page(page1), st.Page(page2))
|
158
|
+
>>> pg = st.navigation([st.Page(page1), st.Page(page2)])
|
159
159
|
>>> pg.run()
|
160
160
|
|
161
161
|
"""
|
@@ -20,7 +20,7 @@ from __future__ import annotations
|
|
20
20
|
|
21
21
|
from typing import TYPE_CHECKING, Any
|
22
22
|
|
23
|
-
from streamlit import type_util
|
23
|
+
from streamlit import dataframe_util, type_util
|
24
24
|
from streamlit.elements.lib import pandas_styler_utils
|
25
25
|
|
26
26
|
if TYPE_CHECKING:
|
@@ -29,6 +29,11 @@ if TYPE_CHECKING:
|
|
29
29
|
from streamlit.proto.Components_pb2 import ArrowTable as ArrowTableProto
|
30
30
|
|
31
31
|
|
32
|
+
def _maybe_tuple_to_list(item: Any) -> Any:
|
33
|
+
"""Convert a tuple to a list. Leave as is if it's not a tuple."""
|
34
|
+
return list(item) if isinstance(item, tuple) else item
|
35
|
+
|
36
|
+
|
32
37
|
def marshall(
|
33
38
|
proto: ArrowTableProto, data: Any, default_uuid: str | None = None
|
34
39
|
) -> None:
|
@@ -43,10 +48,10 @@ def marshall(
|
|
43
48
|
Something that is or can be converted to a dataframe.
|
44
49
|
|
45
50
|
"""
|
46
|
-
if
|
51
|
+
if dataframe_util.is_pandas_styler(data):
|
47
52
|
pandas_styler_utils.marshall_styler(proto, data, default_uuid) # type: ignore
|
48
53
|
|
49
|
-
df =
|
54
|
+
df = dataframe_util.convert_anything_to_pandas_df(data)
|
50
55
|
_marshall_index(proto, df.index)
|
51
56
|
_marshall_columns(proto, df.columns)
|
52
57
|
_marshall_data(proto, df)
|
@@ -67,9 +72,9 @@ def _marshall_index(proto: ArrowTableProto, index: Index) -> None:
|
|
67
72
|
"""
|
68
73
|
import pandas as pd
|
69
74
|
|
70
|
-
index = map(
|
75
|
+
index = map(_maybe_tuple_to_list, index.values)
|
71
76
|
index_df = pd.DataFrame(index)
|
72
|
-
proto.index =
|
77
|
+
proto.index = dataframe_util.data_frame_to_bytes(index_df)
|
73
78
|
|
74
79
|
|
75
80
|
def _marshall_columns(proto: ArrowTableProto, columns: Series) -> None:
|
@@ -87,9 +92,9 @@ def _marshall_columns(proto: ArrowTableProto, columns: Series) -> None:
|
|
87
92
|
"""
|
88
93
|
import pandas as pd
|
89
94
|
|
90
|
-
columns = map(
|
95
|
+
columns = map(_maybe_tuple_to_list, columns.values)
|
91
96
|
columns_df = pd.DataFrame(columns)
|
92
|
-
proto.columns =
|
97
|
+
proto.columns = dataframe_util.data_frame_to_bytes(columns_df)
|
93
98
|
|
94
99
|
|
95
100
|
def _marshall_data(proto: ArrowTableProto, df: DataFrame) -> None:
|
@@ -104,7 +109,7 @@ def _marshall_data(proto: ArrowTableProto, df: DataFrame) -> None:
|
|
104
109
|
A dataframe to marshall.
|
105
110
|
|
106
111
|
"""
|
107
|
-
proto.data =
|
112
|
+
proto.data = dataframe_util.data_frame_to_bytes(df)
|
108
113
|
|
109
114
|
|
110
115
|
def arrow_proto_to_dataframe(proto: ArrowTableProto) -> DataFrame:
|
@@ -125,9 +130,9 @@ def arrow_proto_to_dataframe(proto: ArrowTableProto) -> DataFrame:
|
|
125
130
|
|
126
131
|
import pandas as pd
|
127
132
|
|
128
|
-
data =
|
129
|
-
index =
|
130
|
-
columns =
|
133
|
+
data = dataframe_util.bytes_to_data_frame(proto.data)
|
134
|
+
index = dataframe_util.bytes_to_data_frame(proto.index)
|
135
|
+
columns = dataframe_util.bytes_to_data_frame(proto.columns)
|
131
136
|
|
132
137
|
return pd.DataFrame(
|
133
138
|
data.values, index=index.values.T.tolist(), columns=columns.values.T.tolist()
|
@@ -18,6 +18,7 @@ import json
|
|
18
18
|
from typing import TYPE_CHECKING, Any
|
19
19
|
|
20
20
|
from streamlit.components.types.base_custom_component import BaseCustomComponent
|
21
|
+
from streamlit.dataframe_util import is_dataframe_like
|
21
22
|
from streamlit.delta_generator import main_dg
|
22
23
|
from streamlit.elements.form import current_form_id
|
23
24
|
from streamlit.elements.lib.policies import check_cache_replay_rules
|
@@ -29,7 +30,7 @@ from streamlit.runtime.metrics_util import gather_metrics
|
|
29
30
|
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
30
31
|
from streamlit.runtime.state import NoValue, register_widget
|
31
32
|
from streamlit.runtime.state.common import compute_widget_id
|
32
|
-
from streamlit.type_util import is_bytes_like,
|
33
|
+
from streamlit.type_util import is_bytes_like, to_bytes
|
33
34
|
|
34
35
|
if TYPE_CHECKING:
|
35
36
|
from streamlit.delta_generator import DeltaGenerator
|