|
| 1 | +These Streamlit snippets demonstrate various functionalities: |
| 2 | + |
| 3 | +**Replace any single element:** |
| 4 | + |
| 5 | + element = st.empty() |
| 6 | +creates an empty placeholder element. |
| 7 | + |
| 8 | + element.line_chart(...) |
| 9 | +replaces the empty element with a line chart. |
| 10 | + |
| 11 | + element.text_input(...) |
| 12 | +replaces the previous element with a text input field. |
| 13 | + |
| 14 | +**Insert out of order:** |
| 15 | + |
| 16 | + elements = st.container() |
| 17 | + creates a container for elements. |
| 18 | + |
| 19 | + elements.line_chart(...) |
| 20 | +inserts a line chart into the container. |
| 21 | + |
| 22 | + st.write("Hello") |
| 23 | +writes "Hello" outside of the container. |
| 24 | + |
| 25 | + elements.text_input(...) |
| 26 | +appears above "Hello" within the container. |
| 27 | + |
| 28 | +**Other Streamlit functions:** |
| 29 | + |
| 30 | + st.help(pandas.DataFrame) |
| 31 | +displays help information for the Pandas DataFrame. |
| 32 | + |
| 33 | + st.get_option(key) |
| 34 | +retrieves the value of a Streamlit option. |
| 35 | + |
| 36 | + st.set_option(key, value) |
| 37 | +sets the value of a Streamlit option. |
| 38 | + |
| 39 | + st.set_page_config(layout='wide') |
| 40 | +sets page configuration options like layout. |
| 41 | + |
| 42 | + st.experimental_show(objects) |
| 43 | +displays experimental Streamlit objects. |
| 44 | + |
| 45 | + st.experimental_get_query_params() |
| 46 | +retrieves query parameters from the URL. |
| 47 | + |
| 48 | + st.experimental_set_query_params(**params) |
| 49 | +sets query parameters in the URL. |
0 commit comments