streamlit-nightly 1.33.1.dev20240422__py2.py3-none-any.whl → 1.33.1.dev20240424__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 (40) hide show
  1. streamlit/elements/heading.py +9 -6
  2. streamlit/elements/layouts.py +13 -9
  3. streamlit/elements/markdown.py +6 -4
  4. streamlit/elements/media.py +71 -1
  5. streamlit/elements/metric.py +3 -2
  6. streamlit/elements/progress.py +3 -2
  7. streamlit/elements/toast.py +3 -2
  8. streamlit/elements/widgets/button.py +12 -8
  9. streamlit/elements/widgets/camera_input.py +3 -2
  10. streamlit/elements/widgets/checkbox.py +6 -4
  11. streamlit/elements/widgets/color_picker.py +3 -2
  12. streamlit/elements/widgets/file_uploader.py +3 -2
  13. streamlit/elements/widgets/multiselect.py +3 -2
  14. streamlit/elements/widgets/number_input.py +3 -2
  15. streamlit/elements/widgets/radio.py +3 -2
  16. streamlit/elements/widgets/select_slider.py +3 -2
  17. streamlit/elements/widgets/selectbox.py +3 -2
  18. streamlit/elements/widgets/slider.py +3 -2
  19. streamlit/elements/widgets/text_widgets.py +6 -4
  20. streamlit/elements/widgets/time_widgets.py +6 -4
  21. streamlit/elements/write.py +11 -3
  22. streamlit/proto/Audio_pb2.py +3 -3
  23. streamlit/proto/Audio_pb2.pyi +7 -1
  24. streamlit/proto/Video_pb2.py +4 -4
  25. streamlit/proto/Video_pb2.pyi +10 -1
  26. streamlit/static/asset-manifest.json +4 -4
  27. streamlit/static/index.html +1 -1
  28. streamlit/static/static/js/178.7bea8c5d.chunk.js +1 -0
  29. streamlit/static/static/js/9330.2b4c99e0.chunk.js +1 -0
  30. streamlit/static/static/js/main.3d71c26f.js +2 -0
  31. {streamlit_nightly-1.33.1.dev20240422.dist-info → streamlit_nightly-1.33.1.dev20240424.dist-info}/METADATA +1 -1
  32. {streamlit_nightly-1.33.1.dev20240422.dist-info → streamlit_nightly-1.33.1.dev20240424.dist-info}/RECORD +37 -37
  33. streamlit/static/static/js/178.b5384fd0.chunk.js +0 -1
  34. streamlit/static/static/js/9330.d29313d4.chunk.js +0 -1
  35. streamlit/static/static/js/main.8fc4565f.js +0 -2
  36. /streamlit/static/static/js/{main.8fc4565f.js.LICENSE.txt → main.3d71c26f.js.LICENSE.txt} +0 -0
  37. {streamlit_nightly-1.33.1.dev20240422.data → streamlit_nightly-1.33.1.dev20240424.data}/scripts/streamlit.cmd +0 -0
  38. {streamlit_nightly-1.33.1.dev20240422.dist-info → streamlit_nightly-1.33.1.dev20240424.dist-info}/WHEEL +0 -0
  39. {streamlit_nightly-1.33.1.dev20240422.dist-info → streamlit_nightly-1.33.1.dev20240424.dist-info}/entry_points.txt +0 -0
  40. {streamlit_nightly-1.33.1.dev20240422.dist-info → streamlit_nightly-1.33.1.dev20240424.dist-info}/top_level.txt +0 -0
@@ -67,8 +67,9 @@ class HeadingMixin:
67
67
  must be on their own lines). Supported LaTeX functions are listed
68
68
  at https://katex.org/docs/supported.html.
69
69
 
70
- * Colored text, using the syntax ``:color[text to be colored]``,
71
- where ``color`` needs to be replaced with any of the following
70
+ * Colored text and background colors for text, using the syntax
71
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
72
+ respectively — where ``color`` needs to be replaced with any of the following
72
73
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
73
74
 
74
75
  anchor : str or False
@@ -137,8 +138,9 @@ class HeadingMixin:
137
138
  must be on their own lines). Supported LaTeX functions are listed
138
139
  at https://katex.org/docs/supported.html.
139
140
 
140
- * Colored text, using the syntax ``:color[text to be colored]``,
141
- where ``color`` needs to be replaced with any of the following
141
+ * Colored text and background colors for text, using the syntax
142
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
143
+ respectively — where ``color`` needs to be replaced with any of the following
142
144
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
143
145
 
144
146
  anchor : str or False
@@ -209,8 +211,9 @@ class HeadingMixin:
209
211
  must be on their own lines). Supported LaTeX functions are listed
210
212
  at https://katex.org/docs/supported.html.
211
213
 
212
- * Colored text, using the syntax ``:color[text to be colored]``,
213
- where ``color`` needs to be replaced with any of the following
214
+ * Colored text and background colors for text, using the syntax
215
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
216
+ respectively — where ``color`` needs to be replaced with any of the following
214
217
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
215
218
 
216
219
  anchor : str or False
@@ -303,8 +303,9 @@ class LayoutsMixin:
303
303
  must be on their own lines). Supported LaTeX functions are listed
304
304
  at https://katex.org/docs/supported.html.
305
305
 
306
- * Colored text, using the syntax ``:color[text to be colored]``,
307
- where ``color`` needs to be replaced with any of the following
306
+ * Colored text and background colors for text, using the syntax
307
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
308
+ respectively — where ``color`` needs to be replaced with any of the following
308
309
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
309
310
 
310
311
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -413,8 +414,9 @@ class LayoutsMixin:
413
414
  must be on their own lines). Supported LaTeX functions are listed
414
415
  at https://katex.org/docs/supported.html.
415
416
 
416
- * Colored text, using the syntax ``:color[text to be colored]``,
417
- where ``color`` needs to be replaced with any of the following
417
+ * Colored text and background colors for text, using the syntax
418
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
419
+ respectively — where ``color`` needs to be replaced with any of the following
418
420
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
419
421
 
420
422
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -519,9 +521,10 @@ class LayoutsMixin:
519
521
  must be on their own lines). Supported LaTeX functions are listed
520
522
  at https://katex.org/docs/supported.html.
521
523
 
522
- * Colored text, using the syntax ``:color[text to be colored]``,
523
- where ``color`` needs to be replaced with any of the following
524
- supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
524
+ * Colored text and background colors for text, using the syntax
525
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
526
+ respectively where ``color`` needs to be replaced with any of the following
527
+ supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
525
528
 
526
529
  Unsupported elements are unwrapped so only their children (text contents) render.
527
530
  Display unsupported elements as literal characters by
@@ -631,8 +634,9 @@ class LayoutsMixin:
631
634
  must be on their own lines). Supported LaTeX functions are listed
632
635
  at https://katex.org/docs/supported.html.
633
636
 
634
- * Colored text, using the syntax ``:color[text to be colored]``,
635
- where ``color`` needs to be replaced with any of the following
637
+ * Colored text and background colors for text, using the syntax
638
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
639
+ respectively — where ``color`` needs to be replaced with any of the following
636
640
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
637
641
 
638
642
  Unsupported elements are unwrapped so only their children (text contents)
@@ -56,8 +56,9 @@ class MarkdownMixin:
56
56
  must be on their own lines). Supported LaTeX functions are listed
57
57
  at https://katex.org/docs/supported.html.
58
58
 
59
- * Colored text, using the syntax ``:color[text to be colored]``,
60
- where ``color`` needs to be replaced with any of the following
59
+ * Colored text and background colors for text, using the syntax
60
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
61
+ respectively — where ``color`` needs to be replaced with any of the following
61
62
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
62
63
 
63
64
  unsafe_allow_html : bool
@@ -174,8 +175,9 @@ class MarkdownMixin:
174
175
  must be on their own lines). Supported LaTeX functions are listed
175
176
  at https://katex.org/docs/supported.html.
176
177
 
177
- * Colored text, using the syntax ``:color[text to be colored]``,
178
- where ``color`` needs to be replaced with any of the following
178
+ * Colored text and background colors for text, using the syntax
179
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
180
+ respectively — where ``color`` needs to be replaced with any of the following
179
181
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
180
182
 
181
183
  unsafe_allow_html : bool
@@ -30,6 +30,8 @@ from streamlit.proto.Audio_pb2 import Audio as AudioProto
30
30
  from streamlit.proto.Video_pb2 import Video as VideoProto
31
31
  from streamlit.runtime import caching
32
32
  from streamlit.runtime.metrics_util import gather_metrics
33
+ from streamlit.runtime.scriptrunner import get_script_run_ctx
34
+ from streamlit.runtime.state.common import compute_widget_id
33
35
  from streamlit.time_util import time_to_seconds
34
36
 
35
37
  if TYPE_CHECKING:
@@ -69,6 +71,7 @@ class MediaMixin:
69
71
  sample_rate: int | None = None,
70
72
  end_time: MediaTime | None = None,
71
73
  loop: bool = False,
74
+ autoplay: bool = False,
72
75
  ) -> DeltaGenerator:
73
76
  """Display an audio player.
74
77
 
@@ -118,6 +121,11 @@ class MediaMixin:
118
121
  e.g. ``timedelta(seconds=70)``.
119
122
  loop: bool
120
123
  Whether the audio should loop playback.
124
+ autoplay: bool
125
+ Whether the audio should start playing automatically.
126
+ Browsers will not autoplay audio files if the user has not interacted with
127
+ the page yet, for example by clicking on the page while it loads.
128
+ Defaults to False.
121
129
 
122
130
  Examples
123
131
  --------
@@ -183,6 +191,7 @@ class MediaMixin:
183
191
  sample_rate,
184
192
  end_time,
185
193
  loop,
194
+ autoplay,
186
195
  )
187
196
  return self.dg._enqueue("audio", audio_proto)
188
197
 
@@ -196,6 +205,8 @@ class MediaMixin:
196
205
  subtitles: SubtitleData = None,
197
206
  end_time: MediaTime | None = None,
198
207
  loop: bool = False,
208
+ autoplay: bool = False,
209
+ muted: bool = False,
199
210
  ) -> DeltaGenerator:
200
211
  """Display a video player.
201
212
 
@@ -263,6 +274,15 @@ class MediaMixin:
263
274
  e.g. ``timedelta(seconds=70)``.
264
275
  loop: bool
265
276
  Whether the video should loop playback.
277
+ autoplay: bool
278
+ Whether the video should start playing automatically.
279
+ Browsers will not autoplay video files if the user has not interacted with
280
+ the page yet, for example by clicking on the page while it loads.
281
+ To enable autoplay without user interaction, you can set muted=True.
282
+ Defaults to False.
283
+ muted: bool
284
+ Whether the video should play with the audio silenced. This can be used to
285
+ enable autoplay without user interaction. Defaults to False.
266
286
 
267
287
  Example
268
288
  -------
@@ -314,7 +334,6 @@ class MediaMixin:
314
334
  for more information.
315
335
 
316
336
  """
317
-
318
337
  start_time, end_time = _parse_start_time_end_time(start_time, end_time)
319
338
 
320
339
  video_proto = VideoProto()
@@ -328,6 +347,8 @@ class MediaMixin:
328
347
  subtitles,
329
348
  end_time,
330
349
  loop,
350
+ autoplay,
351
+ muted,
331
352
  )
332
353
  return self.dg._enqueue("video", video_proto)
333
354
 
@@ -434,6 +455,8 @@ def marshall_video(
434
455
  subtitles: SubtitleData = None,
435
456
  end_time: int | None = None,
436
457
  loop: bool = False,
458
+ autoplay: bool = False,
459
+ muted: bool = False,
437
460
  ) -> None:
438
461
  """Marshalls a video proto, using url processors as needed.
439
462
 
@@ -467,12 +490,22 @@ def marshall_video(
467
490
  The time at which this element should stop playing
468
491
  loop: bool
469
492
  Whether the video should loop playback.
493
+ autoplay: bool
494
+ Whether the video should start playing automatically.
495
+ Browsers will not autoplay video files if the user has not interacted with
496
+ the page yet, for example by clicking on the page while it loads.
497
+ To enable autoplay without user interaction, you can set muted=True.
498
+ Defaults to False.
499
+ muted: bool
500
+ Whether the video should play with the audio silenced. This can be used to
501
+ enable autoplay without user interaction. Defaults to False.
470
502
  """
471
503
 
472
504
  if start_time < 0 or (end_time is not None and end_time <= start_time):
473
505
  raise StreamlitAPIException("Invalid start_time and end_time combination.")
474
506
 
475
507
  proto.start_time = start_time
508
+ proto.muted = muted
476
509
 
477
510
  if end_time is not None:
478
511
  proto.end_time = end_time
@@ -531,6 +564,23 @@ def marshall_video(
531
564
  f"Failed to process the provided subtitle: {label}"
532
565
  ) from original_err
533
566
 
567
+ if autoplay:
568
+ ctx = get_script_run_ctx()
569
+ proto.autoplay = autoplay
570
+ id = compute_widget_id(
571
+ "video",
572
+ url=proto.url,
573
+ mimetype=mimetype,
574
+ start_time=start_time,
575
+ end_time=end_time,
576
+ loop=loop,
577
+ autoplay=autoplay,
578
+ muted=muted,
579
+ page=ctx.page_script_hash if ctx else None,
580
+ )
581
+
582
+ proto.id = id
583
+
534
584
 
535
585
  def _parse_start_time_end_time(
536
586
  start_time: MediaTime, end_time: MediaTime | None
@@ -647,6 +697,7 @@ def marshall_audio(
647
697
  sample_rate: int | None = None,
648
698
  end_time: int | None = None,
649
699
  loop: bool = False,
700
+ autoplay: bool = False,
650
701
  ) -> None:
651
702
  """Marshalls an audio proto, using data and url processors as needed.
652
703
 
@@ -670,6 +721,9 @@ def marshall_audio(
670
721
  The time at which this element should stop playing
671
722
  loop: bool
672
723
  Whether the audio should loop playback.
724
+ autoplay : bool
725
+ Whether the audio should start playing automatically.
726
+ Browsers will not autoplay audio files if the user has not interacted with the page yet.
673
727
  """
674
728
 
675
729
  proto.start_time = start_time
@@ -685,3 +739,19 @@ def marshall_audio(
685
739
  else:
686
740
  data = _maybe_convert_to_wav_bytes(data, sample_rate)
687
741
  _marshall_av_media(coordinates, proto, data, mimetype)
742
+
743
+ if autoplay:
744
+ ctx = get_script_run_ctx()
745
+ proto.autoplay = autoplay
746
+ id = compute_widget_id(
747
+ "audio",
748
+ url=proto.url,
749
+ mimetype=mimetype,
750
+ start_time=start_time,
751
+ sample_rate=sample_rate,
752
+ end_time=end_time,
753
+ loop=loop,
754
+ autoplay=autoplay,
755
+ page=ctx.page_script_hash if ctx else None,
756
+ )
757
+ proto.id = id
@@ -79,8 +79,9 @@ class MetricMixin:
79
79
  must be on their own lines). Supported LaTeX functions are listed
80
80
  at https://katex.org/docs/supported.html.
81
81
 
82
- * Colored text, using the syntax ``:color[text to be colored]``,
83
- where ``color`` needs to be replaced with any of the following
82
+ * Colored text and background colors for text, using the syntax
83
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
84
+ respectively — where ``color`` needs to be replaced with any of the following
84
85
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
85
86
 
86
87
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -117,8 +117,9 @@ class ProgressMixin:
117
117
  must be on their own lines). Supported LaTeX functions are listed
118
118
  at https://katex.org/docs/supported.html.
119
119
 
120
- * Colored text, using the syntax ``:color[text to be colored]``,
121
- where ``color`` needs to be replaced with any of the following
120
+ * Colored text and background colors for text, using the syntax
121
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
122
+ respectively — where ``color`` needs to be replaced with any of the following
122
123
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
123
124
 
124
125
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -67,8 +67,9 @@ class ToastMixin:
67
67
  must be on their own lines). Supported LaTeX functions are listed
68
68
  at https://katex.org/docs/supported.html.
69
69
 
70
- * Colored text, using the syntax ``:color[text to be colored]``,
71
- where ``color`` needs to be replaced with any of the following
70
+ * Colored text and background colors for text, using the syntax
71
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
72
+ respectively — where ``color`` needs to be replaced with any of the following
72
73
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
73
74
  icon : str or None
74
75
  An optional argument that specifies an emoji to use as
@@ -97,8 +97,9 @@ class ButtonMixin:
97
97
  must be on their own lines). Supported LaTeX functions are listed
98
98
  at https://katex.org/docs/supported.html.
99
99
 
100
- * Colored text, using the syntax ``:color[text to be colored]``,
101
- where ``color`` needs to be replaced with any of the following
100
+ * Colored text and background colors for text, using the syntax
101
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
102
+ respectively — where ``color`` needs to be replaced with any of the following
102
103
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
103
104
 
104
105
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -216,8 +217,9 @@ class ButtonMixin:
216
217
  must be on their own lines). Supported LaTeX functions are listed
217
218
  at https://katex.org/docs/supported.html.
218
219
 
219
- * Colored text, using the syntax ``:color[text to be colored]``,
220
- where ``color`` needs to be replaced with any of the following
220
+ * Colored text and background colors for text, using the syntax
221
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
222
+ respectively — where ``color`` needs to be replaced with any of the following
221
223
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
222
224
 
223
225
  Unsupported elements are unwrapped so only their children (text contents)
@@ -376,8 +378,9 @@ class ButtonMixin:
376
378
  must be on their own lines). Supported LaTeX functions are listed
377
379
  at https://katex.org/docs/supported.html.
378
380
 
379
- * Colored text, using the syntax ``:color[text to be colored]``,
380
- where ``color`` needs to be replaced with any of the following
381
+ * Colored text and background colors for text, using the syntax
382
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
383
+ respectively — where ``color`` needs to be replaced with any of the following
381
384
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
382
385
 
383
386
  Unsupported elements are unwrapped so only their children (text contents)
@@ -468,8 +471,9 @@ class ButtonMixin:
468
471
  must be on their own lines). Supported LaTeX functions are listed
469
472
  at https://katex.org/docs/supported.html.
470
473
 
471
- * Colored text, using the syntax ``:color[text to be colored]``,
472
- where ``color`` needs to be replaced with any of the following
474
+ * Colored text and background colors for text, using the syntax
475
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
476
+ respectively — where ``color`` needs to be replaced with any of the following
473
477
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
474
478
 
475
479
  Unsupported elements are unwrapped so only their children (text contents)
@@ -112,8 +112,9 @@ class CameraInputMixin:
112
112
  must be on their own lines). Supported LaTeX functions are listed
113
113
  at https://katex.org/docs/supported.html.
114
114
 
115
- * Colored text, using the syntax ``:color[text to be colored]``,
116
- where ``color`` needs to be replaced with any of the following
115
+ * Colored text and background colors for text, using the syntax
116
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
117
+ respectively — where ``color`` needs to be replaced with any of the following
117
118
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
118
119
 
119
120
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -86,8 +86,9 @@ class CheckboxMixin:
86
86
  must be on their own lines). Supported LaTeX functions are listed
87
87
  at https://katex.org/docs/supported.html.
88
88
 
89
- * Colored text, using the syntax ``:color[text to be colored]``,
90
- where ``color`` needs to be replaced with any of the following
89
+ * Colored text and background colors for text, using the syntax
90
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
91
+ respectively — where ``color`` needs to be replaced with any of the following
91
92
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
92
93
 
93
94
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -189,8 +190,9 @@ class CheckboxMixin:
189
190
  must be on their own lines). Supported LaTeX functions are listed
190
191
  at https://katex.org/docs/supported.html.
191
192
 
192
- * Colored text, using the syntax ``:color[text to be colored]``,
193
- where ``color`` needs to be replaced with any of the following
193
+ * Colored text and background colors for text, using the syntax
194
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
195
+ respectively — where ``color`` needs to be replaced with any of the following
194
196
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
195
197
 
196
198
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -86,8 +86,9 @@ class ColorPickerMixin:
86
86
  must be on their own lines). Supported LaTeX functions are listed
87
87
  at https://katex.org/docs/supported.html.
88
88
 
89
- * Colored text, using the syntax ``:color[text to be colored]``,
90
- where ``color`` needs to be replaced with any of the following
89
+ * Colored text and background colors for text, using the syntax
90
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
91
+ respectively — where ``color`` needs to be replaced with any of the following
91
92
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
92
93
 
93
94
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -264,8 +264,9 @@ class FileUploaderMixin:
264
264
  must be on their own lines). Supported LaTeX functions are listed
265
265
  at https://katex.org/docs/supported.html.
266
266
 
267
- * Colored text, using the syntax ``:color[text to be colored]``,
268
- where ``color`` needs to be replaced with any of the following
267
+ * Colored text and background colors for text, using the syntax
268
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
269
+ respectively — where ``color`` needs to be replaced with any of the following
269
270
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
270
271
 
271
272
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -179,8 +179,9 @@ class MultiSelectMixin:
179
179
  must be on their own lines). Supported LaTeX functions are listed
180
180
  at https://katex.org/docs/supported.html.
181
181
 
182
- * Colored text, using the syntax ``:color[text to be colored]``,
183
- where ``color`` needs to be replaced with any of the following
182
+ * Colored text and background colors for text, using the syntax
183
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
184
+ respectively — where ``color`` needs to be replaced with any of the following
184
185
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
185
186
 
186
187
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -156,8 +156,9 @@ class NumberInputMixin:
156
156
  must be on their own lines). Supported LaTeX functions are listed
157
157
  at https://katex.org/docs/supported.html.
158
158
 
159
- * Colored text, using the syntax ``:color[text to be colored]``,
160
- where ``color`` needs to be replaced with any of the following
159
+ * Colored text and background colors for text, using the syntax
160
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
161
+ respectively — where ``color`` needs to be replaced with any of the following
161
162
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
162
163
 
163
164
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -119,8 +119,9 @@ class RadioMixin:
119
119
  must be on their own lines). Supported LaTeX functions are listed
120
120
  at https://katex.org/docs/supported.html.
121
121
 
122
- * Colored text, using the syntax ``:color[text to be colored]``,
123
- where ``color`` needs to be replaced with any of the following
122
+ * Colored text and background colors for text, using the syntax
123
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
124
+ respectively — where ``color`` needs to be replaced with any of the following
124
125
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
125
126
 
126
127
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -147,8 +147,9 @@ class SelectSliderMixin:
147
147
  must be on their own lines). Supported LaTeX functions are listed
148
148
  at https://katex.org/docs/supported.html.
149
149
 
150
- * Colored text, using the syntax ``:color[text to be colored]``,
151
- where ``color`` needs to be replaced with any of the following
150
+ * Colored text and background colors for text, using the syntax
151
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
152
+ respectively — where ``color`` needs to be replaced with any of the following
152
153
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
153
154
 
154
155
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -111,8 +111,9 @@ class SelectboxMixin:
111
111
  must be on their own lines). Supported LaTeX functions are listed
112
112
  at https://katex.org/docs/supported.html.
113
113
 
114
- * Colored text, using the syntax ``:color[text to be colored]``,
115
- where ``color`` needs to be replaced with any of the following
114
+ * Colored text and background colors for text, using the syntax
115
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
116
+ respectively — where ``color`` needs to be replaced with any of the following
116
117
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
117
118
 
118
119
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -221,8 +221,9 @@ class SliderMixin:
221
221
  must be on their own lines). Supported LaTeX functions are listed
222
222
  at https://katex.org/docs/supported.html.
223
223
 
224
- * Colored text, using the syntax ``:color[text to be colored]``,
225
- where ``color`` needs to be replaced with any of the following
224
+ * Colored text and background colors for text, using the syntax
225
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
226
+ respectively — where ``color`` needs to be replaced with any of the following
226
227
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
227
228
 
228
229
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -150,8 +150,9 @@ class TextWidgetsMixin:
150
150
  must be on their own lines). Supported LaTeX functions are listed
151
151
  at https://katex.org/docs/supported.html.
152
152
 
153
- * Colored text, using the syntax ``:color[text to be colored]``,
154
- where ``color`` needs to be replaced with any of the following
153
+ * Colored text and background colors for text, using the syntax
154
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
155
+ respectively — where ``color`` needs to be replaced with any of the following
155
156
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
156
157
 
157
158
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -415,8 +416,9 @@ class TextWidgetsMixin:
415
416
  must be on their own lines). Supported LaTeX functions are listed
416
417
  at https://katex.org/docs/supported.html.
417
418
 
418
- * Colored text, using the syntax ``:color[text to be colored]``,
419
- where ``color`` needs to be replaced with any of the following
419
+ * Colored text and background colors for text, using the syntax
420
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
421
+ respectively — where ``color`` needs to be replaced with any of the following
420
422
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
421
423
 
422
424
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -321,8 +321,9 @@ class TimeWidgetsMixin:
321
321
  must be on their own lines). Supported LaTeX functions are listed
322
322
  at https://katex.org/docs/supported.html.
323
323
 
324
- * Colored text, using the syntax ``:color[text to be colored]``,
325
- where ``color`` needs to be replaced with any of the following
324
+ * Colored text and background colors for text, using the syntax
325
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
326
+ respectively — where ``color`` needs to be replaced with any of the following
326
327
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
327
328
 
328
329
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -545,8 +546,9 @@ class TimeWidgetsMixin:
545
546
  must be on their own lines). Supported LaTeX functions are listed
546
547
  at https://katex.org/docs/supported.html.
547
548
 
548
- * Colored text, using the syntax ``:color[text to be colored]``,
549
- where ``color`` needs to be replaced with any of the following
549
+ * Colored text and background colors for text, using the syntax
550
+ ``:color[text to be colored]`` and ``:color-background[text to be colored]``,
551
+ respectively — where ``color`` needs to be replaced with any of the following
550
552
  supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
551
553
 
552
554
  Unsupported elements are unwrapped so only their children (text contents) render.
@@ -197,6 +197,10 @@ class WriteMixin:
197
197
  ) from err
198
198
 
199
199
  if isinstance(chunk, str):
200
+ if not chunk:
201
+ # Empty strings can be ignored
202
+ continue
203
+
200
204
  first_text = False
201
205
  if not stream_container:
202
206
  stream_container = self.dg.empty()
@@ -216,10 +220,14 @@ class WriteMixin:
216
220
 
217
221
  flush_stream_response()
218
222
 
219
- # If the output only contains a single string, return it as a string
220
- if len(written_content) == 1 and isinstance(written_content[0], str):
223
+ if not written_content:
224
+ # If nothing was streamed, return an empty string.
225
+ return ""
226
+ elif len(written_content) == 1 and isinstance(written_content[0], str):
227
+ # If the output only contains a single string, return it as a string
221
228
  return written_content[0]
222
- # Otherwise return it as a list
229
+
230
+ # Otherwise return it as a list of write-compatible objects
223
231
  return written_content
224
232
 
225
233
  @gather_metrics("write")
@@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default()
13
13
 
14
14
 
15
15
 
16
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bstreamlit/proto/Audio.proto\"h\n\x05\x41udio\x12\x0b\n\x03url\x18\x05 \x01(\t\x12\x12\n\nstart_time\x18\x03 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x06 \x01(\x05\x12\x0c\n\x04loop\x18\x07 \x01(\x08J\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03J\x04\x08\x04\x10\x05R\x04\x64\x61taR\x06\x66ormatB*\n\x1c\x63om.snowflake.apps.streamlitB\nAudioProtob\x06proto3')
16
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bstreamlit/proto/Audio.proto\"\x86\x01\n\x05\x41udio\x12\x0b\n\x03url\x18\x05 \x01(\t\x12\x12\n\nstart_time\x18\x03 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x06 \x01(\x05\x12\x0c\n\x04loop\x18\x07 \x01(\x08\x12\x10\n\x08\x61utoplay\x18\x08 \x01(\x08\x12\n\n\x02id\x18\t \x01(\tJ\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03J\x04\x08\x04\x10\x05R\x04\x64\x61taR\x06\x66ormatB*\n\x1c\x63om.snowflake.apps.streamlitB\nAudioProtob\x06proto3')
17
17
 
18
18
  _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
19
19
  _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'streamlit.proto.Audio_pb2', globals())
@@ -21,6 +21,6 @@ if _descriptor._USE_C_DESCRIPTORS == False:
21
21
 
22
22
  DESCRIPTOR._options = None
23
23
  DESCRIPTOR._serialized_options = b'\n\034com.snowflake.apps.streamlitB\nAudioProto'
24
- _AUDIO._serialized_start=31
25
- _AUDIO._serialized_end=135
24
+ _AUDIO._serialized_start=32
25
+ _AUDIO._serialized_end=166
26
26
  # @@protoc_insertion_point(module_scope)