|
1 | 1 | These Streamlit snippets demonstrate various visual elements and notifications:
|
2 | 2 |
|
3 |
| -1. **Show a spinner during a process:** |
4 |
| - - `with st.spinner(text='In progress'):` displays a spinner with the text "In progress". |
5 |
| - - Inside the context manager, a process (here, `time.sleep(3)`) is simulated. |
6 |
| - - After the process, `st.success('Done')` displays a success message. |
7 |
| - |
8 |
| -2. **Show and update progress bar:** |
9 |
| - - `bar = st.progress(50)` creates a progress bar initialized to 50%. |
10 |
| - - After a delay (`time.sleep(3)`), `bar.progress(100)` updates the progress bar to 100%. |
11 |
| - |
12 |
| -3. **Other visual elements and notifications:** |
13 |
| - - `st.balloons()`: Displays flying balloons animation. |
14 |
| - - `st.snow()`: Displays falling snow animation. |
15 |
| - - `st.toast('Mr Stay-Puft')`: Shows a toast notification with the message "Mr Stay-Puft". |
16 |
| - - `st.error('Error message')`, `st.warning('Warning message')`, `st.info('Info message')`, `st.success('Success message')`: Displays different types of messages. |
17 |
| - - `st.exception(e)`: Displays an exception message `e` with a traceback. |
| 3 | +**Show a spinner during a process:** |
| 4 | + |
| 5 | + `with st.spinner(text='In progress') |
| 6 | +displays a spinner with the text "In progress". |
| 7 | + |
| 8 | + Inside the context manager, a process (here, `time.sleep(3)`) is simulated. |
| 9 | + After the process, `st.success('Done')` displays a success message. |
| 10 | + |
| 11 | +**Show and update progress bar:** |
| 12 | + |
| 13 | + bar = st.progress(50) |
| 14 | +creates a progress bar initialized to 50%. |
| 15 | + |
| 16 | + After a delay (`time.sleep(3)`), `bar.progress(100)` updates the progress bar to 100%. |
| 17 | + |
| 18 | +**Other visual elements and notifications:** |
| 19 | + |
| 20 | + st.balloons() |
| 21 | + Displays flying balloons animation. |
| 22 | + |
| 23 | + st.snow() |
| 24 | +Displays falling snow animation. |
| 25 | + |
| 26 | + st.toast('Mr Stay-Puft')` |
| 27 | + Shows a toast notification with the message "Mr Stay-Puft". |
| 28 | + |
| 29 | + st.error('Error message') |
| 30 | +st.warning('Warning message')`, `st.info('Info message')`, `st.success('Success message')`: Displays different types of messages. |
| 31 | + |
| 32 | + st.exception(e) |
| 33 | +Displays an exception message `e` with a traceback. |
18 | 34 |
|
19 | 35 | These snippets showcase Streamlit's ability to provide visual feedback, notifications, and animations to enhance user experience.
|
0 commit comments