streamlit-nightly 1.39.1.dev20241031__py2.py3-none-any.whl → 1.39.1.dev20241102__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. streamlit/commands/execution_control.py +7 -2
  2. streamlit/commands/logo.py +3 -3
  3. streamlit/commands/navigation.py +48 -3
  4. streamlit/commands/page_config.py +8 -3
  5. streamlit/elements/html.py +6 -4
  6. streamlit/elements/image.py +28 -443
  7. streamlit/elements/layouts.py +12 -7
  8. streamlit/elements/lib/image_utils.py +440 -0
  9. streamlit/elements/markdown.py +6 -0
  10. streamlit/elements/media.py +22 -9
  11. streamlit/elements/metric.py +8 -5
  12. streamlit/elements/progress.py +2 -1
  13. streamlit/elements/pyplot.py +3 -5
  14. streamlit/elements/text.py +1 -1
  15. streamlit/elements/widgets/audio_input.py +12 -11
  16. streamlit/elements/widgets/button.py +28 -19
  17. streamlit/elements/widgets/button_group.py +146 -121
  18. streamlit/elements/widgets/camera_input.py +13 -11
  19. streamlit/elements/widgets/chat.py +2 -2
  20. streamlit/elements/widgets/checkbox.py +30 -24
  21. streamlit/elements/widgets/color_picker.py +15 -13
  22. streamlit/elements/widgets/file_uploader.py +12 -12
  23. streamlit/elements/widgets/multiselect.py +33 -31
  24. streamlit/elements/widgets/number_input.py +15 -12
  25. streamlit/elements/widgets/radio.py +15 -12
  26. streamlit/elements/widgets/select_slider.py +15 -12
  27. streamlit/elements/widgets/selectbox.py +19 -14
  28. streamlit/elements/widgets/slider.py +15 -12
  29. streamlit/elements/widgets/text_widgets.py +33 -27
  30. streamlit/elements/widgets/time_widgets.py +33 -25
  31. streamlit/hello/{Animation_Demo.py → animation_demo.py} +9 -10
  32. streamlit/hello/{Dataframe_Demo.py → dataframe_demo.py} +9 -15
  33. streamlit/hello/{Hello.py → hello.py} +7 -12
  34. streamlit/hello/{Mapping_Demo.py → mapping_demo.py} +10 -13
  35. streamlit/hello/{Plotting_Demo.py → plotting_demo.py} +9 -10
  36. streamlit/hello/streamlit_app.py +24 -6
  37. streamlit/proto/Image_pb2.pyi +1 -1
  38. streamlit/static/asset-manifest.json +3 -3
  39. streamlit/static/index.html +1 -1
  40. streamlit/static/static/js/3224.925d380f.chunk.js +1 -0
  41. streamlit/static/static/js/{main.754d974e.js → main.61a89bda.js} +2 -2
  42. {streamlit_nightly-1.39.1.dev20241031.dist-info → streamlit_nightly-1.39.1.dev20241102.dist-info}/METADATA +1 -1
  43. {streamlit_nightly-1.39.1.dev20241031.dist-info → streamlit_nightly-1.39.1.dev20241102.dist-info}/RECORD +48 -47
  44. streamlit/static/static/js/3224.919d670d.chunk.js +0 -1
  45. /streamlit/static/static/js/{main.754d974e.js.LICENSE.txt → main.61a89bda.js.LICENSE.txt} +0 -0
  46. {streamlit_nightly-1.39.1.dev20241031.data → streamlit_nightly-1.39.1.dev20241102.data}/scripts/streamlit.cmd +0 -0
  47. {streamlit_nightly-1.39.1.dev20241031.dist-info → streamlit_nightly-1.39.1.dev20241102.dist-info}/WHEEL +0 -0
  48. {streamlit_nightly-1.39.1.dev20241031.dist-info → streamlit_nightly-1.39.1.dev20241102.dist-info}/entry_points.txt +0 -0
  49. {streamlit_nightly-1.39.1.dev20241031.dist-info → streamlit_nightly-1.39.1.dev20241102.dist-info}/top_level.txt +0 -0
@@ -16,6 +16,7 @@ from __future__ import annotations
16
16
 
17
17
  import os
18
18
  from itertools import dropwhile
19
+ from pathlib import Path
19
20
  from typing import Literal, NoReturn
20
21
 
21
22
  import streamlit as st
@@ -146,7 +147,7 @@ def rerun( # type: ignore[misc]
146
147
 
147
148
 
148
149
  @gather_metrics("switch_page")
149
- def switch_page(page: str | StreamlitPage) -> NoReturn: # type: ignore[misc]
150
+ def switch_page(page: str | Path | StreamlitPage) -> NoReturn: # type: ignore[misc]
150
151
  """Programmatically switch the current page in a multipage app.
151
152
 
152
153
  When ``st.switch_page`` is called, the current page execution stops and
@@ -157,7 +158,7 @@ def switch_page(page: str | StreamlitPage) -> NoReturn: # type: ignore[misc]
157
158
 
158
159
  Parameters
159
160
  ----------
160
- page: str or st.Page
161
+ page: str, Path, or st.Page
161
162
  The file path (relative to the main script) or an st.Page indicating
162
163
  the page to switch to.
163
164
 
@@ -197,6 +198,10 @@ def switch_page(page: str | StreamlitPage) -> NoReturn: # type: ignore[misc]
197
198
  if isinstance(page, StreamlitPage):
198
199
  page_script_hash = page._script_hash
199
200
  else:
201
+ # Convert Path to string if necessary
202
+ if isinstance(page, Path):
203
+ page = str(page)
204
+
200
205
  main_script_directory = get_main_script_directory(ctx.main_script_path)
201
206
  requested_page = os.path.realpath(
202
207
  normalize_path_join(main_script_directory, page)
@@ -19,7 +19,7 @@ from __future__ import annotations
19
19
  from typing import Literal
20
20
 
21
21
  from streamlit import url_util
22
- from streamlit.elements.image import AtomicImage, WidthBehaviour, image_to_url
22
+ from streamlit.elements.lib.image_utils import AtomicImage, WidthBehavior, image_to_url
23
23
  from streamlit.errors import StreamlitAPIException
24
24
  from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
25
25
  from streamlit.runtime.metrics_util import gather_metrics
@@ -132,7 +132,7 @@ def logo(
132
132
  try:
133
133
  image_url = image_to_url(
134
134
  image,
135
- width=WidthBehaviour.AUTO,
135
+ width=WidthBehavior.AUTO,
136
136
  clamp=False,
137
137
  channels="RGB",
138
138
  output_format="auto",
@@ -155,7 +155,7 @@ def logo(
155
155
  try:
156
156
  icon_image_url = image_to_url(
157
157
  icon_image,
158
- width=WidthBehaviour.AUTO,
158
+ width=WidthBehavior.AUTO,
159
159
  clamp=False,
160
160
  channels="RGB",
161
161
  output_format="auto",
@@ -126,15 +126,47 @@ def navigation(
126
126
  you pass to ``streamlit run``. Your entrypoint file manages your app's
127
127
  navigation and serves as a router between pages.
128
128
 
129
+ **Example 1: Use a callable or Python file as a page**
130
+
129
131
  You can declare pages from callables or file paths.
130
132
 
133
+ ``page_1.py`` (in the same directory as your entrypoint file):
134
+
135
+ >>> import streamlit as st
136
+ >>>
137
+ >>> st.title("Page 1")
138
+
139
+ Your entrypoint file:
140
+
131
141
  >>> import streamlit as st
132
- >>> from page_functions import page1
133
142
  >>>
134
- >>> pg = st.navigation([st.Page(page1), st.Page("page2.py")])
143
+ >>> def page_2():
144
+ ... st.title("Page 2")
145
+ >>>
146
+ >>> pg = st.navigation([st.Page("page_1.py"), st.Page(page_2)])
135
147
  >>> pg.run()
136
148
 
137
- Use a dictionary to create sections within your navigation menu.
149
+ .. output::
150
+ https://doc-navigation-example-1.streamlit.app/
151
+ height: 200px
152
+
153
+ **Example 2: Group pages into sections**
154
+
155
+ You can use a dictionary to create sections within your navigation menu. In
156
+ the following example, each page is similar to Page 1 in Example 1, and all
157
+ pages are in the same directory. However, you can use Python files from
158
+ anywhere in your repository. For more information, see |st.Page|_.
159
+
160
+ Directory structure:
161
+
162
+ >>> your_repository/
163
+ >>> ├── create_account.py
164
+ >>> ├── learn.py
165
+ >>> ├── manage_account.py
166
+ >>> ├── streamlit_app.py
167
+ >>> └── trial.py
168
+
169
+ ``streamlit_app.py``:
138
170
 
139
171
  >>> import streamlit as st
140
172
  >>>
@@ -152,6 +184,12 @@ def navigation(
152
184
  >>> pg = st.navigation(pages)
153
185
  >>> pg.run()
154
186
 
187
+ .. output::
188
+ https://doc-navigation-example-2.streamlit.app/
189
+ height: 300px
190
+
191
+ **Example 3: Stateful widgets across multiple pages**
192
+
155
193
  Call widget functions in your entrypoint file when you want a widget to be
156
194
  stateful across pages. Assign keys to your common widgets and access their
157
195
  values through Session State within your pages.
@@ -171,6 +209,13 @@ def navigation(
171
209
  >>> pg = st.navigation([st.Page(page1), st.Page(page2)])
172
210
  >>> pg.run()
173
211
 
212
+ .. output::
213
+ https://doc-navigation-multipage-widgets.streamlit.app/
214
+ height: 350px
215
+
216
+ .. |st.Page| replace:: ``st.Page``
217
+ .. _st.Page: https://docs.streamlit.io/develop/api-reference/navigation/st.page
218
+
174
219
  """
175
220
  nav_sections = {"": pages} if isinstance(pages, list) else pages
176
221
  page_list = pages_from_nav_sections(nav_sections)
@@ -15,12 +15,13 @@
15
15
  from __future__ import annotations
16
16
 
17
17
  import random
18
+ from pathlib import Path
18
19
  from textwrap import dedent
19
20
  from typing import TYPE_CHECKING, Any, Final, Literal, Mapping, Union, cast
20
21
 
21
22
  from typing_extensions import TypeAlias
22
23
 
23
- from streamlit.elements import image
24
+ from streamlit.elements.lib.image_utils import AtomicImage, image_to_url
24
25
  from streamlit.errors import (
25
26
  StreamlitInvalidMenuItemKeyError,
26
27
  StreamlitInvalidPageLayoutError,
@@ -41,7 +42,7 @@ GET_HELP_KEY: Final = "get help"
41
42
  REPORT_A_BUG_KEY: Final = "report a bug"
42
43
  ABOUT_KEY: Final = "about"
43
44
 
44
- PageIcon: TypeAlias = Union[image.AtomicImage, str]
45
+ PageIcon: TypeAlias = Union[AtomicImage, str]
45
46
  Layout: TypeAlias = Literal["centered", "wide"]
46
47
  InitialSideBarState: TypeAlias = Literal["auto", "expanded", "collapsed"]
47
48
  _GetHelp: TypeAlias = Literal["Get help", "Get Help", "get help"]
@@ -105,9 +106,13 @@ def _get_favicon_string(page_icon: PageIcon) -> str:
105
106
  if isinstance(page_icon, str) and page_icon.startswith(":material"):
106
107
  return validate_material_icon(page_icon)
107
108
 
109
+ # Convert Path to string if necessary
110
+ if isinstance(page_icon, Path):
111
+ page_icon = str(page_icon)
112
+
108
113
  # Fall back to image_to_url.
109
114
  try:
110
- return image.image_to_url(
115
+ return image_to_url(
111
116
  page_icon,
112
117
  width=-1, # Always use full width for favicons
113
118
  clamp=False,
@@ -15,6 +15,7 @@
15
15
  from __future__ import annotations
16
16
 
17
17
  import os
18
+ from pathlib import Path
18
19
  from typing import TYPE_CHECKING, cast
19
20
 
20
21
  from streamlit.proto.Html_pb2 import Html as HtmlProto
@@ -29,7 +30,7 @@ class HtmlMixin:
29
30
  @gather_metrics("html")
30
31
  def html(
31
32
  self,
32
- body: str,
33
+ body: str | Path,
33
34
  ) -> DeltaGenerator:
34
35
  """Insert HTML into your app.
35
36
 
@@ -45,7 +46,7 @@ class HtmlMixin:
45
46
 
46
47
  Parameters
47
48
  ----------
48
- body : str
49
+ body : str, Path
49
50
  The HTML code to insert, or path to an HTML code file which is
50
51
  loaded and inserted.
51
52
 
@@ -67,8 +68,9 @@ class HtmlMixin:
67
68
 
68
69
  """
69
70
  html_proto = HtmlProto()
70
- # Check if the body is a file path
71
- if os.path.isfile(body):
71
+
72
+ # Check if the body is a file path. If it's a Path object, open it directly.
73
+ if os.path.isfile(body) or isinstance(body, Path):
72
74
  with open(body, encoding="utf-8") as f:
73
75
  html_proto.body = f.read()
74
76
  else: