From bbf73ca76b4ef47a7c3e6ffc96b9104afd1f3039 Mon Sep 17 00:00:00 2001 From: Debbie Matthews Date: Wed, 6 Sep 2023 16:26:03 -0700 Subject: [PATCH 1/8] Update to streamlit-nightly for api examples --- python/api-examples-source/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/api-examples-source/requirements.txt b/python/api-examples-source/requirements.txt index b8e1121bc..d53f70e3c 100644 --- a/python/api-examples-source/requirements.txt +++ b/python/api-examples-source/requirements.txt @@ -10,4 +10,4 @@ altair==4.2.0 pydeck==0.8.0 Faker==19.1.0 openai==0.27.8 -streamlit==1.26.0 +streamlit-nightly From c126078e559ec2103179d4637cf10fc330ff3870 Mon Sep 17 00:00:00 2001 From: Debbie Matthews Date: Wed, 6 Sep 2023 16:26:23 -0700 Subject: [PATCH 2/8] st.scatter embedded app source --- .../charts.scatter_chart.py | 15 ++++++++++++ .../charts.scatter_chart1.py | 23 +++++++++++++++++++ .../charts.scatter_chart2.py | 22 ++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 python/api-examples-source/charts.scatter_chart.py create mode 100644 python/api-examples-source/charts.scatter_chart1.py create mode 100644 python/api-examples-source/charts.scatter_chart2.py diff --git a/python/api-examples-source/charts.scatter_chart.py b/python/api-examples-source/charts.scatter_chart.py new file mode 100644 index 000000000..62af0e548 --- /dev/null +++ b/python/api-examples-source/charts.scatter_chart.py @@ -0,0 +1,15 @@ +import streamlit as st +import pandas as pd +import numpy as np + + +@st.cache_data +def load_data(): + df = pd.DataFrame( + np.random.randn(20, 3), + columns=['a', 'b', 'c']) + return df + +chart_data = load_data() + +st.scatter_chart(chart_data) diff --git a/python/api-examples-source/charts.scatter_chart1.py b/python/api-examples-source/charts.scatter_chart1.py new file mode 100644 index 000000000..d78a0cd42 --- /dev/null +++ b/python/api-examples-source/charts.scatter_chart1.py @@ -0,0 +1,23 @@ +import streamlit as st +import pandas as pd +import numpy as np + + +@st.cache_data +def load_data(): + df = pd.DataFrame( + np.random.randn(20, 3), + columns=['col1', 'col2', 'col3']) + df['col4'] = np.random.choice(['A','B','C'], 20) + return df + + +chart_data = load_data() + +st.scatter_chart( + chart_data, + x='col1', + y='col2', + color='col4', + size='col3', +) diff --git a/python/api-examples-source/charts.scatter_chart2.py b/python/api-examples-source/charts.scatter_chart2.py new file mode 100644 index 000000000..d3d56c0c0 --- /dev/null +++ b/python/api-examples-source/charts.scatter_chart2.py @@ -0,0 +1,22 @@ +import streamlit as st +import pandas as pd +import numpy as np + + +@st.cache_data +def load_data(): + df = pd.DataFrame( + np.random.randn(20, 4), + columns=['col1', 'col2', 'col3', 'col4']) + return df + + +chart_data = load_data() + +st.scatter_chart( + chart_data, + x='col1', + y=['col2', 'col3'], + size='col4', + color=['#FF0000', '#0000FF'], # Optional +) From 066132fe41086cfcb7c218ef85f6ac28b762cfcd Mon Sep 17 00:00:00 2001 From: Debbie Matthews Date: Thu, 7 Sep 2023 18:23:50 -0700 Subject: [PATCH 3/8] Add st.progress example source code --- python/api-examples-source/status.progress.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 python/api-examples-source/status.progress.py diff --git a/python/api-examples-source/status.progress.py b/python/api-examples-source/status.progress.py new file mode 100644 index 000000000..e68bb71b0 --- /dev/null +++ b/python/api-examples-source/status.progress.py @@ -0,0 +1,13 @@ +import streamlit as st +import time + +progress_text = "Operation in progress. Please wait." +my_bar = st.progress(0, text=progress_text) + +for percent_complete in range(100): + time.sleep(0.01) + my_bar.progress(percent_complete + 1, text=progress_text) +time.sleep(1) +my_bar.empty() + +st.button("Rerun") From c015d72d7326e710a23cfbf1c86b659bcd9085ee Mon Sep 17 00:00:00 2001 From: Debbie Matthews Date: Thu, 14 Sep 2023 20:43:00 -0700 Subject: [PATCH 4/8] Simple charts PEP 8 spacing --- python/api-examples-source/charts.area_chart.py | 2 +- python/api-examples-source/charts.area_chart1.py | 12 ++++++------ python/api-examples-source/charts.area_chart2.py | 8 ++++---- python/api-examples-source/charts.bar_chart.py | 4 ++-- python/api-examples-source/charts.bar_chart1.py | 12 ++++++------ python/api-examples-source/charts.bar_chart2.py | 12 ++++++------ python/api-examples-source/charts.line_chart.py | 2 +- python/api-examples-source/charts.line_chart1.py | 12 ++++++------ python/api-examples-source/charts.line_chart2.py | 8 ++++---- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/python/api-examples-source/charts.area_chart.py b/python/api-examples-source/charts.area_chart.py index 0eed64286..b527697af 100644 --- a/python/api-examples-source/charts.area_chart.py +++ b/python/api-examples-source/charts.area_chart.py @@ -7,7 +7,7 @@ def load_data(): df = pd.DataFrame( np.random.randn(20, 3), - columns = ['a', 'b', 'c']) + columns=['a', 'b', 'c']) return df diff --git a/python/api-examples-source/charts.area_chart1.py b/python/api-examples-source/charts.area_chart1.py index c33c9730e..934de21c5 100644 --- a/python/api-examples-source/charts.area_chart1.py +++ b/python/api-examples-source/charts.area_chart1.py @@ -6,9 +6,9 @@ @st.cache_data def load_data(): df = pd.DataFrame({ - 'col1' : np.random.randn(20), - 'col2' : np.random.randn(20), - 'col3' : np.random.choice(['A','B','C'], 20) + 'col1': np.random.randn(20), + 'col2': np.random.randn(20), + 'col3': np.random.choice(['A','B','C'], 20) }) return df @@ -17,7 +17,7 @@ def load_data(): st.area_chart( chart_data, - x = 'col1', - y = 'col2', - color = 'col3' + x='col1', + y='col2', + color='col3' ) diff --git a/python/api-examples-source/charts.area_chart2.py b/python/api-examples-source/charts.area_chart2.py index 507deb396..3327eb515 100644 --- a/python/api-examples-source/charts.area_chart2.py +++ b/python/api-examples-source/charts.area_chart2.py @@ -7,7 +7,7 @@ def load_data(): df = pd.DataFrame( np.random.randn(20, 3), - columns = ['col1', 'col2', 'col3']) + columns=['col1', 'col2', 'col3']) return df @@ -15,7 +15,7 @@ def load_data(): st.area_chart( chart_data, - x = 'col1', - y = ['col2', 'col3'], - color = ['#FF0000', '#0000FF'] # Optional + x='col1', + y=['col2', 'col3'], + color=['#FF0000', '#0000FF'] # Optional ) diff --git a/python/api-examples-source/charts.bar_chart.py b/python/api-examples-source/charts.bar_chart.py index 07dfd2592..bc0cc5e98 100644 --- a/python/api-examples-source/charts.bar_chart.py +++ b/python/api-examples-source/charts.bar_chart.py @@ -6,8 +6,8 @@ @st.cache_data def load_data(): df = pd.DataFrame( - np.random.randn(50, 3), - columns = ["a", "b", "c"]) + np.random.randn(20, 3), + columns=["a", "b", "c"]) return df diff --git a/python/api-examples-source/charts.bar_chart1.py b/python/api-examples-source/charts.bar_chart1.py index 0807cfe41..40e3ab5ea 100644 --- a/python/api-examples-source/charts.bar_chart1.py +++ b/python/api-examples-source/charts.bar_chart1.py @@ -6,9 +6,9 @@ @st.cache_data def load_data(): df = pd.DataFrame({ - 'col1' : list(range(20))*3, - 'col2' : np.random.randn(60), - 'col3' : ['A']*20 + ['B']*20 + ['C']*20 + 'col1': list(range(20))*3, + 'col2': np.random.randn(60), + 'col3': ['A']*20 + ['B']*20 + ['C']*20 }) return df @@ -17,7 +17,7 @@ def load_data(): st.bar_chart( chart_data, - x = 'col1', - y = 'col2', - color = 'col3' + x='col1', + y='col2', + color='col3' ) diff --git a/python/api-examples-source/charts.bar_chart2.py b/python/api-examples-source/charts.bar_chart2.py index c56585305..2e359676b 100644 --- a/python/api-examples-source/charts.bar_chart2.py +++ b/python/api-examples-source/charts.bar_chart2.py @@ -6,9 +6,9 @@ @st.cache_data def load_data(): df = pd.DataFrame({ - 'col1' : list(range(20)), - 'col2' : np.random.randn(20), - 'col3' : np.random.randn(20) + 'col1': list(range(20)), + 'col2': np.random.randn(20), + 'col3': np.random.randn(20) }) return df @@ -17,7 +17,7 @@ def load_data(): st.bar_chart( chart_data, - x = 'col1', - y = ['col2', 'col3'], - color = ['#FF0000', '#0000FF'] # Optional + x='col1', + y=['col2', 'col3'], + color=['#FF0000', '#0000FF'] # Optional ) diff --git a/python/api-examples-source/charts.line_chart.py b/python/api-examples-source/charts.line_chart.py index 07dfd8c76..8144e85a2 100644 --- a/python/api-examples-source/charts.line_chart.py +++ b/python/api-examples-source/charts.line_chart.py @@ -7,7 +7,7 @@ def load_data(): df = pd.DataFrame( np.random.randn(20, 3), - columns = ['a', 'b', 'c']) + columns=['a', 'b', 'c']) return df diff --git a/python/api-examples-source/charts.line_chart1.py b/python/api-examples-source/charts.line_chart1.py index 073a5f3b3..b879ea287 100644 --- a/python/api-examples-source/charts.line_chart1.py +++ b/python/api-examples-source/charts.line_chart1.py @@ -6,9 +6,9 @@ @st.cache_data def load_data(): df = pd.DataFrame({ - 'col1' : np.random.randn(20), - 'col2' : np.random.randn(20), - 'col3' : np.random.choice(['A','B','C'], 20) + 'col1': np.random.randn(20), + 'col2': np.random.randn(20), + 'col3': np.random.choice(['A','B','C'], 20) }) return df @@ -17,7 +17,7 @@ def load_data(): st.line_chart( chart_data, - x = 'col1', - y = 'col2', - color = 'col3' + x='col1', + y='col2', + color='col3' ) diff --git a/python/api-examples-source/charts.line_chart2.py b/python/api-examples-source/charts.line_chart2.py index 09f7ac51d..d12a4ccb9 100644 --- a/python/api-examples-source/charts.line_chart2.py +++ b/python/api-examples-source/charts.line_chart2.py @@ -7,7 +7,7 @@ def load_data(): df = pd.DataFrame( np.random.randn(20, 3), - columns = ['col1', 'col2', 'col3']) + columns=['col1', 'col2', 'col3']) return df @@ -15,7 +15,7 @@ def load_data(): st.line_chart( chart_data, - x = 'col1', - y = ['col2', 'col3'], - color = ['#FF0000', '#0000FF'] # Optional + x='col1', + y=['col2', 'col3'], + color=['#FF0000', '#0000FF'] # Optional ) From 6abf1e012a7d2176286f5b4ce1db5dd9c683f769 Mon Sep 17 00:00:00 2001 From: Debbie Matthews Date: Thu, 14 Sep 2023 23:42:23 -0700 Subject: [PATCH 5/8] st.link_button example --- python/api-examples-source/widget.link_button.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 python/api-examples-source/widget.link_button.py diff --git a/python/api-examples-source/widget.link_button.py b/python/api-examples-source/widget.link_button.py new file mode 100644 index 000000000..e5f9ac101 --- /dev/null +++ b/python/api-examples-source/widget.link_button.py @@ -0,0 +1,3 @@ +import streamlit as st + +st.link_button('Go to gallery', 'https://streamlit.io/gallery') From b2e026dce400dae90511c11d52bc0b1777b0adc4 Mon Sep 17 00:00:00 2001 From: Debbie Matthews Date: Fri, 15 Sep 2023 00:20:30 -0700 Subject: [PATCH 6/8] Setting none as initial value examples --- python/api-examples-source/text.text_area.py | 10 ++++++++++ python/api-examples-source/widget.date_input_empty.py | 5 +++++ .../api-examples-source/widget.number_input_empty.py | 4 ++++ python/api-examples-source/widget.selectbox_empty.py | 10 ++++++++++ python/api-examples-source/widget.time_input_empty.py | 5 +++++ 5 files changed, 34 insertions(+) create mode 100644 python/api-examples-source/text.text_area.py create mode 100644 python/api-examples-source/widget.date_input_empty.py create mode 100644 python/api-examples-source/widget.number_input_empty.py create mode 100644 python/api-examples-source/widget.selectbox_empty.py create mode 100644 python/api-examples-source/widget.time_input_empty.py diff --git a/python/api-examples-source/text.text_area.py b/python/api-examples-source/text.text_area.py new file mode 100644 index 000000000..f35f70347 --- /dev/null +++ b/python/api-examples-source/text.text_area.py @@ -0,0 +1,10 @@ +import streamlit as st + +txt = st.text_area('Text to analyze', 'It was the best of times, it was '\ + 'the worst of times, it was the age of wisdom, it was the age of '\ + 'foolishness, it was the epoch of belief, it was the epoch of '\ + 'incredulity, it was the season of Light, it was the season of Darkness, '\ + 'it was the spring of hope, it was the winter of despair, (...)' + ) + +st.write(f'You wrote {len(txt)} characters.') diff --git a/python/api-examples-source/widget.date_input_empty.py b/python/api-examples-source/widget.date_input_empty.py new file mode 100644 index 000000000..d1f42d910 --- /dev/null +++ b/python/api-examples-source/widget.date_input_empty.py @@ -0,0 +1,5 @@ +import datetime +import streamlit as st + +d = st.date_input("When's your birthday", value=None) +st.write('Your birthday is:', d) diff --git a/python/api-examples-source/widget.number_input_empty.py b/python/api-examples-source/widget.number_input_empty.py new file mode 100644 index 000000000..540ee780f --- /dev/null +++ b/python/api-examples-source/widget.number_input_empty.py @@ -0,0 +1,4 @@ +import streamlit as st + +number = st.number_input('Insert a number', value=None) +st.write('The current number is ', number) diff --git a/python/api-examples-source/widget.selectbox_empty.py b/python/api-examples-source/widget.selectbox_empty.py new file mode 100644 index 000000000..8cdc85cc9 --- /dev/null +++ b/python/api-examples-source/widget.selectbox_empty.py @@ -0,0 +1,10 @@ +import streamlit as st + +option = st.selectbox( + "How would you like to be contacted?", + ("Email", "Home phone", "Mobile phone"), + index=None, + placeholder="Select contact method...", +) + +st.write('You selected:', option) diff --git a/python/api-examples-source/widget.time_input_empty.py b/python/api-examples-source/widget.time_input_empty.py new file mode 100644 index 000000000..a8d40bdde --- /dev/null +++ b/python/api-examples-source/widget.time_input_empty.py @@ -0,0 +1,5 @@ +import datetime +import streamlit as st + +t = st.time_input('Set an alarm for', value=None) +st.write('Alarm is set for', t) From 9a89863e13edf34115df755e8b949707024de1d9 Mon Sep 17 00:00:00 2001 From: snehankekre Date: Fri, 15 Sep 2023 14:47:33 +0530 Subject: [PATCH 7/8] Format embedded apps with black --- .../api-examples-source/charts.area_chart.py | 4 +- .../api-examples-source/charts.area_chart1.py | 19 +++---- .../api-examples-source/charts.area_chart2.py | 9 +-- .../api-examples-source/charts.bar_chart.py | 4 +- .../api-examples-source/charts.bar_chart1.py | 19 +++---- .../api-examples-source/charts.bar_chart2.py | 17 +++--- .../api-examples-source/charts.line_chart.py | 4 +- .../api-examples-source/charts.line_chart1.py | 19 +++---- .../api-examples-source/charts.line_chart2.py | 9 +-- .../charts.scatter_chart.py | 5 +- .../charts.scatter_chart1.py | 14 ++--- .../charts.scatter_chart2.py | 12 ++-- .../data.column_config.empty.py | 16 +++--- .../api-examples-source/data.column_config.py | 1 + .../forms.form_container.py | 12 ++-- .../api-examples-source/forms.form_default.py | 10 ++-- .../forms.form_overview.py | 56 ++++++++++--------- .../forms.form_process1.py | 14 ++--- .../forms.form_process2.py | 20 ++++--- .../forms.form_process3.py | 18 +++--- python/api-examples-source/status.status.py | 2 +- python/api-examples-source/status.status1.py | 2 +- python/api-examples-source/status.toast1.py | 12 ++-- python/api-examples-source/status.toast2.py | 10 ++-- python/api-examples-source/text.caption.py | 2 +- python/api-examples-source/text.header.py | 4 +- python/api-examples-source/text.markdown.py | 16 ++++-- python/api-examples-source/text.markdown1.py | 12 ++-- python/api-examples-source/text.subheader.py | 4 +- python/api-examples-source/text.text_area.py | 16 +++--- python/api-examples-source/text.title.py | 4 +- python/api-examples-source/widget.button.py | 8 +-- .../widget.color_picker.py | 4 +- .../widget.date_input_empty.py | 2 +- .../api-examples-source/widget.link_button.py | 2 +- .../api-examples-source/widget.multiselect.py | 9 +-- .../widget.number_input.py | 4 +- .../widget.number_input_empty.py | 4 +- python/api-examples-source/widget.radio.py | 3 +- .../widget.select_slider.py | 16 +++--- .../widget.selectbox_empty.py | 10 ++-- .../widget.time_input_empty.py | 4 +- python/api-examples-source/widget.toggle.py | 4 +- 43 files changed, 217 insertions(+), 219 deletions(-) diff --git a/python/api-examples-source/charts.area_chart.py b/python/api-examples-source/charts.area_chart.py index b527697af..ed4558fb7 100644 --- a/python/api-examples-source/charts.area_chart.py +++ b/python/api-examples-source/charts.area_chart.py @@ -5,9 +5,7 @@ @st.cache_data def load_data(): - df = pd.DataFrame( - np.random.randn(20, 3), - columns=['a', 'b', 'c']) + df = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"]) return df diff --git a/python/api-examples-source/charts.area_chart1.py b/python/api-examples-source/charts.area_chart1.py index 934de21c5..995b9fdd3 100644 --- a/python/api-examples-source/charts.area_chart1.py +++ b/python/api-examples-source/charts.area_chart1.py @@ -5,19 +5,16 @@ @st.cache_data def load_data(): - df = pd.DataFrame({ - 'col1': np.random.randn(20), - 'col2': np.random.randn(20), - 'col3': np.random.choice(['A','B','C'], 20) - }) + df = pd.DataFrame( + { + "col1": np.random.randn(20), + "col2": np.random.randn(20), + "col3": np.random.choice(["A", "B", "C"], 20), + } + ) return df chart_data = load_data() -st.area_chart( - chart_data, - x='col1', - y='col2', - color='col3' -) +st.area_chart(chart_data, x="col1", y="col2", color="col3") diff --git a/python/api-examples-source/charts.area_chart2.py b/python/api-examples-source/charts.area_chart2.py index 3327eb515..1e0876c5e 100644 --- a/python/api-examples-source/charts.area_chart2.py +++ b/python/api-examples-source/charts.area_chart2.py @@ -5,17 +5,12 @@ @st.cache_data def load_data(): - df = pd.DataFrame( - np.random.randn(20, 3), - columns=['col1', 'col2', 'col3']) + df = pd.DataFrame(np.random.randn(20, 3), columns=["col1", "col2", "col3"]) return df chart_data = load_data() st.area_chart( - chart_data, - x='col1', - y=['col2', 'col3'], - color=['#FF0000', '#0000FF'] # Optional + chart_data, x="col1", y=["col2", "col3"], color=["#FF0000", "#0000FF"] # Optional ) diff --git a/python/api-examples-source/charts.bar_chart.py b/python/api-examples-source/charts.bar_chart.py index bc0cc5e98..73788b7d7 100644 --- a/python/api-examples-source/charts.bar_chart.py +++ b/python/api-examples-source/charts.bar_chart.py @@ -5,9 +5,7 @@ @st.cache_data def load_data(): - df = pd.DataFrame( - np.random.randn(20, 3), - columns=["a", "b", "c"]) + df = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"]) return df diff --git a/python/api-examples-source/charts.bar_chart1.py b/python/api-examples-source/charts.bar_chart1.py index 40e3ab5ea..791605579 100644 --- a/python/api-examples-source/charts.bar_chart1.py +++ b/python/api-examples-source/charts.bar_chart1.py @@ -5,19 +5,16 @@ @st.cache_data def load_data(): - df = pd.DataFrame({ - 'col1': list(range(20))*3, - 'col2': np.random.randn(60), - 'col3': ['A']*20 + ['B']*20 + ['C']*20 - }) + df = pd.DataFrame( + { + "col1": list(range(20)) * 3, + "col2": np.random.randn(60), + "col3": ["A"] * 20 + ["B"] * 20 + ["C"] * 20, + } + ) return df chart_data = load_data() -st.bar_chart( - chart_data, - x='col1', - y='col2', - color='col3' -) +st.bar_chart(chart_data, x="col1", y="col2", color="col3") diff --git a/python/api-examples-source/charts.bar_chart2.py b/python/api-examples-source/charts.bar_chart2.py index 2e359676b..5ddd5477a 100644 --- a/python/api-examples-source/charts.bar_chart2.py +++ b/python/api-examples-source/charts.bar_chart2.py @@ -5,19 +5,18 @@ @st.cache_data def load_data(): - df = pd.DataFrame({ - 'col1': list(range(20)), - 'col2': np.random.randn(20), - 'col3': np.random.randn(20) - }) + df = pd.DataFrame( + { + "col1": list(range(20)), + "col2": np.random.randn(20), + "col3": np.random.randn(20), + } + ) return df chart_data = load_data() st.bar_chart( - chart_data, - x='col1', - y=['col2', 'col3'], - color=['#FF0000', '#0000FF'] # Optional + chart_data, x="col1", y=["col2", "col3"], color=["#FF0000", "#0000FF"] # Optional ) diff --git a/python/api-examples-source/charts.line_chart.py b/python/api-examples-source/charts.line_chart.py index 8144e85a2..387b77374 100644 --- a/python/api-examples-source/charts.line_chart.py +++ b/python/api-examples-source/charts.line_chart.py @@ -5,9 +5,7 @@ @st.cache_data def load_data(): - df = pd.DataFrame( - np.random.randn(20, 3), - columns=['a', 'b', 'c']) + df = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"]) return df diff --git a/python/api-examples-source/charts.line_chart1.py b/python/api-examples-source/charts.line_chart1.py index b879ea287..6b6b443f8 100644 --- a/python/api-examples-source/charts.line_chart1.py +++ b/python/api-examples-source/charts.line_chart1.py @@ -5,19 +5,16 @@ @st.cache_data def load_data(): - df = pd.DataFrame({ - 'col1': np.random.randn(20), - 'col2': np.random.randn(20), - 'col3': np.random.choice(['A','B','C'], 20) - }) + df = pd.DataFrame( + { + "col1": np.random.randn(20), + "col2": np.random.randn(20), + "col3": np.random.choice(["A", "B", "C"], 20), + } + ) return df chart_data = load_data() -st.line_chart( - chart_data, - x='col1', - y='col2', - color='col3' -) +st.line_chart(chart_data, x="col1", y="col2", color="col3") diff --git a/python/api-examples-source/charts.line_chart2.py b/python/api-examples-source/charts.line_chart2.py index d12a4ccb9..fa71ec498 100644 --- a/python/api-examples-source/charts.line_chart2.py +++ b/python/api-examples-source/charts.line_chart2.py @@ -5,17 +5,12 @@ @st.cache_data def load_data(): - df = pd.DataFrame( - np.random.randn(20, 3), - columns=['col1', 'col2', 'col3']) + df = pd.DataFrame(np.random.randn(20, 3), columns=["col1", "col2", "col3"]) return df chart_data = load_data() st.line_chart( - chart_data, - x='col1', - y=['col2', 'col3'], - color=['#FF0000', '#0000FF'] # Optional + chart_data, x="col1", y=["col2", "col3"], color=["#FF0000", "#0000FF"] # Optional ) diff --git a/python/api-examples-source/charts.scatter_chart.py b/python/api-examples-source/charts.scatter_chart.py index 62af0e548..884231e8b 100644 --- a/python/api-examples-source/charts.scatter_chart.py +++ b/python/api-examples-source/charts.scatter_chart.py @@ -5,11 +5,10 @@ @st.cache_data def load_data(): - df = pd.DataFrame( - np.random.randn(20, 3), - columns=['a', 'b', 'c']) + df = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"]) return df + chart_data = load_data() st.scatter_chart(chart_data) diff --git a/python/api-examples-source/charts.scatter_chart1.py b/python/api-examples-source/charts.scatter_chart1.py index d78a0cd42..d7bc03a5d 100644 --- a/python/api-examples-source/charts.scatter_chart1.py +++ b/python/api-examples-source/charts.scatter_chart1.py @@ -5,10 +5,8 @@ @st.cache_data def load_data(): - df = pd.DataFrame( - np.random.randn(20, 3), - columns=['col1', 'col2', 'col3']) - df['col4'] = np.random.choice(['A','B','C'], 20) + df = pd.DataFrame(np.random.randn(20, 3), columns=["col1", "col2", "col3"]) + df["col4"] = np.random.choice(["A", "B", "C"], 20) return df @@ -16,8 +14,8 @@ def load_data(): st.scatter_chart( chart_data, - x='col1', - y='col2', - color='col4', - size='col3', + x="col1", + y="col2", + color="col4", + size="col3", ) diff --git a/python/api-examples-source/charts.scatter_chart2.py b/python/api-examples-source/charts.scatter_chart2.py index d3d56c0c0..ac96f880c 100644 --- a/python/api-examples-source/charts.scatter_chart2.py +++ b/python/api-examples-source/charts.scatter_chart2.py @@ -5,9 +5,7 @@ @st.cache_data def load_data(): - df = pd.DataFrame( - np.random.randn(20, 4), - columns=['col1', 'col2', 'col3', 'col4']) + df = pd.DataFrame(np.random.randn(20, 4), columns=["col1", "col2", "col3", "col4"]) return df @@ -15,8 +13,8 @@ def load_data(): st.scatter_chart( chart_data, - x='col1', - y=['col2', 'col3'], - size='col4', - color=['#FF0000', '#0000FF'], # Optional + x="col1", + y=["col2", "col3"], + size="col4", + color=["#FF0000", "#0000FF"], # Optional ) diff --git a/python/api-examples-source/data.column_config.empty.py b/python/api-examples-source/data.column_config.empty.py index acd0ce363..d0288198f 100644 --- a/python/api-examples-source/data.column_config.empty.py +++ b/python/api-examples-source/data.column_config.empty.py @@ -1,15 +1,17 @@ import streamlit as st import pandas as pd -df = pd.DataFrame(columns=['name','age','color']) -colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'] +df = pd.DataFrame(columns=["name", "age", "color"]) +colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"] config = { - 'name' : st.column_config.TextColumn('Full Name (required)', width='large', required=True), - 'age' : st.column_config.NumberColumn('Age (years)', min_value=0, max_value=122), - 'color' : st.column_config.SelectboxColumn('Favorite Color', options=colors) + "name": st.column_config.TextColumn( + "Full Name (required)", width="large", required=True + ), + "age": st.column_config.NumberColumn("Age (years)", min_value=0, max_value=122), + "color": st.column_config.SelectboxColumn("Favorite Color", options=colors), } -result = st.data_editor(df, column_config = config, num_rows='dynamic') +result = st.data_editor(df, column_config=config, num_rows="dynamic") -if st.button('Get results'): +if st.button("Get results"): st.write(result) diff --git a/python/api-examples-source/data.column_config.py b/python/api-examples-source/data.column_config.py index 251b04f24..2bf3ce255 100644 --- a/python/api-examples-source/data.column_config.py +++ b/python/api-examples-source/data.column_config.py @@ -7,6 +7,7 @@ st.set_page_config("Profiles", "👤") + @st.cache_data def get_profile_dataset(number_of_items: int = 100, seed: int = 0) -> pd.DataFrame: new_data = [] diff --git a/python/api-examples-source/forms.form_container.py b/python/api-examples-source/forms.form_container.py index 2a672398c..04e0a0e12 100644 --- a/python/api-examples-source/forms.form_container.py +++ b/python/api-examples-source/forms.form_container.py @@ -1,16 +1,16 @@ import streamlit as st -animal = st.form('my_animal') +animal = st.form("my_animal") # This is writing directly to the main body. Since the form container is # defined above, this will appear below everything written in the form. -sound = st.selectbox('Sounds like', ['meow','woof','squeak','tweet']) +sound = st.selectbox("Sounds like", ["meow", "woof", "squeak", "tweet"]) # These methods called on the form container, so they appear inside the form. -submit = animal.form_submit_button(f'Say it with {sound}!') -sentence = animal.text_input('Your sentence:', 'Where\'s the tuna?') -say_it = sentence.rstrip('.,!?') + f', {sound}!' +submit = animal.form_submit_button(f"Say it with {sound}!") +sentence = animal.text_input("Your sentence:", "Where's the tuna?") +say_it = sentence.rstrip(".,!?") + f", {sound}!" if submit: animal.subheader(say_it) else: - animal.subheader(' ') + animal.subheader(" ") diff --git a/python/api-examples-source/forms.form_default.py b/python/api-examples-source/forms.form_default.py index 1852126df..a6d1090d2 100644 --- a/python/api-examples-source/forms.form_default.py +++ b/python/api-examples-source/forms.form_default.py @@ -1,10 +1,12 @@ import streamlit as st with st.form("my_form"): - st.write("Inside the form") - my_number = st.slider('Pick a number', 1, 10) - my_color = st.selectbox('Pick a color', ['red','orange','green','blue','violet']) - st.form_submit_button('Submit my picks') + st.write("Inside the form") + my_number = st.slider("Pick a number", 1, 10) + my_color = st.selectbox( + "Pick a color", ["red", "orange", "green", "blue", "violet"] + ) + st.form_submit_button("Submit my picks") # This is outside the form st.write(my_number) diff --git a/python/api-examples-source/forms.form_overview.py b/python/api-examples-source/forms.form_overview.py index db5dac3d4..b8f3d76b7 100644 --- a/python/api-examples-source/forms.form_overview.py +++ b/python/api-examples-source/forms.form_overview.py @@ -2,42 +2,48 @@ import pandas as pd import numpy as np + def get_data(): - df = pd.DataFrame({ - "lat": np.random.randn(200) / 50 + 37.76, - "lon": np.random.randn(200) / 50 + -122.4, - "team": ['A','B']*100 - }) + df = pd.DataFrame( + { + "lat": np.random.randn(200) / 50 + 37.76, + "lon": np.random.randn(200) / 50 + -122.4, + "team": ["A", "B"] * 100, + } + ) return df -if st.button('Generate new points'): + +if st.button("Generate new points"): st.session_state.df = get_data() -if 'df' not in st.session_state: +if "df" not in st.session_state: st.session_state.df = get_data() df = st.session_state.df with st.form("my_form"): - header = st.columns([1,2,2]) - header[0].subheader('Color') - header[1].subheader('Opacity') - header[2].subheader('Size') + header = st.columns([1, 2, 2]) + header[0].subheader("Color") + header[1].subheader("Opacity") + header[2].subheader("Size") - row1 = st.columns([1,2,2]) - colorA = row1[0].color_picker('Team A', '#0000FF') - opacityA = row1[1].slider('A opacity', 20, 100, 50, label_visibility='hidden') - sizeA = row1[2].slider('A size', 50, 200, 100, step=10, label_visibility='hidden') + row1 = st.columns([1, 2, 2]) + colorA = row1[0].color_picker("Team A", "#0000FF") + opacityA = row1[1].slider("A opacity", 20, 100, 50, label_visibility="hidden") + sizeA = row1[2].slider("A size", 50, 200, 100, step=10, label_visibility="hidden") - row2 = st.columns([1,2,2]) - colorB = row2[0].color_picker('Team B', '#FF0000') - opacityB = row2[1].slider('B opacity', 20, 100, 50, label_visibility='hidden') - sizeB = row2[2].slider('B size', 50, 200, 100, step=10, label_visibility='hidden') + row2 = st.columns([1, 2, 2]) + colorB = row2[0].color_picker("Team B", "#FF0000") + opacityB = row2[1].slider("B opacity", 20, 100, 50, label_visibility="hidden") + sizeB = row2[2].slider("B size", 50, 200, 100, step=10, label_visibility="hidden") - st.form_submit_button('Update map') + st.form_submit_button("Update map") -alphaA = int(opacityA*255/100) -alphaB = int(opacityB*255/100) +alphaA = int(opacityA * 255 / 100) +alphaB = int(opacityB * 255 / 100) -df['color'] = np.where(df.team=='A',colorA+f'{alphaA:02x}',colorB+f'{alphaB:02x}') -df['size'] = np.where(df.team=='A',sizeA, sizeB) +df["color"] = np.where( + df.team == "A", colorA + f"{alphaA:02x}", colorB + f"{alphaB:02x}" +) +df["size"] = np.where(df.team == "A", sizeA, sizeB) -st.map(df, size='size', color='color') +st.map(df, size="size", color="color") diff --git a/python/api-examples-source/forms.form_process1.py b/python/api-examples-source/forms.form_process1.py index fe61f6bac..aff4db010 100644 --- a/python/api-examples-source/forms.form_process1.py +++ b/python/api-examples-source/forms.form_process1.py @@ -1,12 +1,12 @@ import streamlit as st -col1,col2 = st.columns([1,2]) -col1.title('Sum:') +col1, col2 = st.columns([1, 2]) +col1.title("Sum:") -with st.form('addition'): - a = st.number_input('a') - b = st.number_input('b') - submit = st.form_submit_button('add') +with st.form("addition"): + a = st.number_input("a") + b = st.number_input("b") + submit = st.form_submit_button("add") if submit: - col2.title(f'{a+b:.2f}') + col2.title(f"{a+b:.2f}") diff --git a/python/api-examples-source/forms.form_process2.py b/python/api-examples-source/forms.form_process2.py index 4a3554996..39f05a0fa 100644 --- a/python/api-examples-source/forms.form_process2.py +++ b/python/api-examples-source/forms.form_process2.py @@ -1,18 +1,20 @@ import streamlit as st -if 'sum' not in st.session_state: - st.session_state.sum = '' +if "sum" not in st.session_state: + st.session_state.sum = "" + def sum(): result = st.session_state.a + st.session_state.b st.session_state.sum = result -col1,col2 = st.columns(2) -col1.title('Sum:') + +col1, col2 = st.columns(2) +col1.title("Sum:") if isinstance(st.session_state.sum, float): - col2.title(f'{st.session_state.sum:.2f}') + col2.title(f"{st.session_state.sum:.2f}") -with st.form('addition'): - st.number_input('a', key = 'a') - st.number_input('b', key = 'b') - st.form_submit_button('add', on_click=sum) +with st.form("addition"): + st.number_input("a", key="a") + st.number_input("b", key="b") + st.form_submit_button("add", on_click=sum) diff --git a/python/api-examples-source/forms.form_process3.py b/python/api-examples-source/forms.form_process3.py index 4cea83f3c..cb3a1d3c6 100644 --- a/python/api-examples-source/forms.form_process3.py +++ b/python/api-examples-source/forms.form_process3.py @@ -1,17 +1,17 @@ import streamlit as st -if 'sum' not in st.session_state: - st.session_state.sum = '' +if "sum" not in st.session_state: + st.session_state.sum = "" -col1,col2 = st.columns(2) -col1.title('Sum:') +col1, col2 = st.columns(2) +col1.title("Sum:") if isinstance(st.session_state.sum, float): - col2.title(f'{st.session_state.sum:.2f}') + col2.title(f"{st.session_state.sum:.2f}") -with st.form('addition'): - a = st.number_input('a') - b = st.number_input('b') - submit = st.form_submit_button('add') +with st.form("addition"): + a = st.number_input("a") + b = st.number_input("b") + submit = st.form_submit_button("add") # The value of st.session_state.sum is updated at the end of the script rerun, # so the displayed value at the top in col2 does not show the new sum. Trigger diff --git a/python/api-examples-source/status.status.py b/python/api-examples-source/status.status.py index a83c422a1..0163b69ae 100644 --- a/python/api-examples-source/status.status.py +++ b/python/api-examples-source/status.status.py @@ -9,4 +9,4 @@ st.write("Downloading data...") time.sleep(1) -st.button('Rerun') +st.button("Rerun") diff --git a/python/api-examples-source/status.status1.py b/python/api-examples-source/status.status1.py index ff7164089..9a7de12b6 100644 --- a/python/api-examples-source/status.status1.py +++ b/python/api-examples-source/status.status1.py @@ -10,4 +10,4 @@ time.sleep(1) status.update(label="Download complete!", state="complete", expanded=False) -st.button('Rerun') +st.button("Rerun") diff --git a/python/api-examples-source/status.toast1.py b/python/api-examples-source/status.toast1.py index eaa2db844..4f90f83a8 100644 --- a/python/api-examples-source/status.toast1.py +++ b/python/api-examples-source/status.toast1.py @@ -1,9 +1,9 @@ import streamlit as st import time -if st.button('Three cheers'): - st.toast('Hip!') - time.sleep(.5) - st.toast('Hip!') - time.sleep(.5) - st.toast('Hooray!', icon='🎉') +if st.button("Three cheers"): + st.toast("Hip!") + time.sleep(0.5) + st.toast("Hip!") + time.sleep(0.5) + st.toast("Hooray!", icon="🎉") diff --git a/python/api-examples-source/status.toast2.py b/python/api-examples-source/status.toast2.py index 98da6b5cd..b3d4676aa 100644 --- a/python/api-examples-source/status.toast2.py +++ b/python/api-examples-source/status.toast2.py @@ -1,12 +1,14 @@ import streamlit as st import time + def cook_breakfast(): - msg = st.toast('Gathering ingredients...') + msg = st.toast("Gathering ingredients...") time.sleep(1) - msg.toast('Cooking...') + msg.toast("Cooking...") time.sleep(1) - msg.toast('Ready!', icon = "🥞") + msg.toast("Ready!", icon="🥞") + -if st.button('Cook breakfast'): +if st.button("Cook breakfast"): cook_breakfast() diff --git a/python/api-examples-source/text.caption.py b/python/api-examples-source/text.caption.py index af3d55ef7..391ac96fa 100644 --- a/python/api-examples-source/text.caption.py +++ b/python/api-examples-source/text.caption.py @@ -1,3 +1,3 @@ import streamlit as st -st.caption('This is a caption') +st.caption("This is a caption") diff --git a/python/api-examples-source/text.header.py b/python/api-examples-source/text.header.py index 9b65a92fd..09bf64835 100644 --- a/python/api-examples-source/text.header.py +++ b/python/api-examples-source/text.header.py @@ -1,4 +1,4 @@ import streamlit as st -st.header('This is a header with a divider', divider='rainbow') -st.header('_Streamlit_ is :blue[cool] :sunglasses:') +st.header("This is a header with a divider", divider="rainbow") +st.header("_Streamlit_ is :blue[cool] :sunglasses:") diff --git a/python/api-examples-source/text.markdown.py b/python/api-examples-source/text.markdown.py index 1c8dfd45e..491fd8286 100644 --- a/python/api-examples-source/text.markdown.py +++ b/python/api-examples-source/text.markdown.py @@ -1,15 +1,19 @@ import streamlit as st st.markdown("*Streamlit* is **really** ***cool***.") -st.markdown(""" +st.markdown( + """ :red[Streamlit] :orange[can] :green[write] :blue[text] :violet[in] - :gray[pretty] :rainbow[colors].""") -st.markdown("Here's a bouquet —\ - :tulip::cherry_blossom::rose::hibiscus::sunflower::blossom:") + :gray[pretty] :rainbow[colors].""" +) +st.markdown( + "Here's a bouquet —\ + :tulip::cherry_blossom::rose::hibiscus::sunflower::blossom:" +) -multi = '''If you end a line with two spaces, +multi = """If you end a line with two spaces, a soft return is used for the next line. Two (or more) newline characters in a row will result in a hard return. -''' +""" st.markdown(multi) diff --git a/python/api-examples-source/text.markdown1.py b/python/api-examples-source/text.markdown1.py index cce5a43fa..2603d7588 100644 --- a/python/api-examples-source/text.markdown1.py +++ b/python/api-examples-source/text.markdown1.py @@ -1,12 +1,16 @@ import streamlit as st -md = st.text_area('Type in your markdown string (without outer quotes)', - "Happy Streamlit-ing! :balloon:") +md = st.text_area( + "Type in your markdown string (without outer quotes)", + "Happy Streamlit-ing! :balloon:", +) -st.code(f""" +st.code( + f""" import streamlit as st st.markdown('''{md}''') -""") +""" +) st.markdown(md) diff --git a/python/api-examples-source/text.subheader.py b/python/api-examples-source/text.subheader.py index 8c86dc882..623af2210 100644 --- a/python/api-examples-source/text.subheader.py +++ b/python/api-examples-source/text.subheader.py @@ -1,4 +1,4 @@ import streamlit as st -st.subheader('This is a subheader with a divider', divider='rainbow') -st.subheader('_Streamlit_ is :blue[cool] :sunglasses:') +st.subheader("This is a subheader with a divider", divider="rainbow") +st.subheader("_Streamlit_ is :blue[cool] :sunglasses:") diff --git a/python/api-examples-source/text.text_area.py b/python/api-examples-source/text.text_area.py index f35f70347..114b11ff4 100644 --- a/python/api-examples-source/text.text_area.py +++ b/python/api-examples-source/text.text_area.py @@ -1,10 +1,12 @@ import streamlit as st -txt = st.text_area('Text to analyze', 'It was the best of times, it was '\ - 'the worst of times, it was the age of wisdom, it was the age of '\ - 'foolishness, it was the epoch of belief, it was the epoch of '\ - 'incredulity, it was the season of Light, it was the season of Darkness, '\ - 'it was the spring of hope, it was the winter of despair, (...)' - ) +txt = st.text_area( + "Text to analyze", + "It was the best of times, it was " + "the worst of times, it was the age of wisdom, it was the age of " + "foolishness, it was the epoch of belief, it was the epoch of " + "incredulity, it was the season of Light, it was the season of Darkness, " + "it was the spring of hope, it was the winter of despair, (...)", +) -st.write(f'You wrote {len(txt)} characters.') +st.write(f"You wrote {len(txt)} characters.") diff --git a/python/api-examples-source/text.title.py b/python/api-examples-source/text.title.py index 73772765f..8ada0609c 100644 --- a/python/api-examples-source/text.title.py +++ b/python/api-examples-source/text.title.py @@ -1,4 +1,4 @@ import streamlit as st -st.title('This is a title') -st.title('_Streamlit_ is :blue[cool] :sunglasses:') +st.title("This is a title") +st.title("_Streamlit_ is :blue[cool] :sunglasses:") diff --git a/python/api-examples-source/widget.button.py b/python/api-examples-source/widget.button.py index 85540b67d..f1c9fd4a0 100644 --- a/python/api-examples-source/widget.button.py +++ b/python/api-examples-source/widget.button.py @@ -1,7 +1,7 @@ import streamlit as st -st.button('Reset', type='primary') -if st.button('Say hello'): - st.write('Why hello there') +st.button("Reset", type="primary") +if st.button("Say hello"): + st.write("Why hello there") else: - st.write('Goodbye') + st.write("Goodbye") diff --git a/python/api-examples-source/widget.color_picker.py b/python/api-examples-source/widget.color_picker.py index f2180c305..b1d26b3bb 100644 --- a/python/api-examples-source/widget.color_picker.py +++ b/python/api-examples-source/widget.color_picker.py @@ -1,4 +1,4 @@ import streamlit as st -color = st.color_picker('Pick A Color', '#00f900') -st.write('The current color is', color) +color = st.color_picker("Pick A Color", "#00f900") +st.write("The current color is", color) diff --git a/python/api-examples-source/widget.date_input_empty.py b/python/api-examples-source/widget.date_input_empty.py index d1f42d910..627d0b17f 100644 --- a/python/api-examples-source/widget.date_input_empty.py +++ b/python/api-examples-source/widget.date_input_empty.py @@ -2,4 +2,4 @@ import streamlit as st d = st.date_input("When's your birthday", value=None) -st.write('Your birthday is:', d) +st.write("Your birthday is:", d) diff --git a/python/api-examples-source/widget.link_button.py b/python/api-examples-source/widget.link_button.py index e5f9ac101..a5864d508 100644 --- a/python/api-examples-source/widget.link_button.py +++ b/python/api-examples-source/widget.link_button.py @@ -1,3 +1,3 @@ import streamlit as st -st.link_button('Go to gallery', 'https://streamlit.io/gallery') +st.link_button("Go to gallery", "https://streamlit.io/gallery") diff --git a/python/api-examples-source/widget.multiselect.py b/python/api-examples-source/widget.multiselect.py index be5632cdb..2832006b9 100644 --- a/python/api-examples-source/widget.multiselect.py +++ b/python/api-examples-source/widget.multiselect.py @@ -1,8 +1,9 @@ import streamlit as st options = st.multiselect( - 'What are your favorite colors', - ['Green', 'Yellow', 'Red', 'Blue'], - ['Yellow', 'Red']) + "What are your favorite colors", + ["Green", "Yellow", "Red", "Blue"], + ["Yellow", "Red"], +) -st.write('You selected:', options) +st.write("You selected:", options) diff --git a/python/api-examples-source/widget.number_input.py b/python/api-examples-source/widget.number_input.py index ff4da406b..7e7444789 100644 --- a/python/api-examples-source/widget.number_input.py +++ b/python/api-examples-source/widget.number_input.py @@ -1,4 +1,4 @@ import streamlit as st -number = st.number_input('Insert a number') -st.write('The current number is ', number) +number = st.number_input("Insert a number") +st.write("The current number is ", number) diff --git a/python/api-examples-source/widget.number_input_empty.py b/python/api-examples-source/widget.number_input_empty.py index 540ee780f..d43d8961a 100644 --- a/python/api-examples-source/widget.number_input_empty.py +++ b/python/api-examples-source/widget.number_input_empty.py @@ -1,4 +1,4 @@ import streamlit as st -number = st.number_input('Insert a number', value=None) -st.write('The current number is ', number) +number = st.number_input("Insert a number", value=None) +st.write("The current number is ", number) diff --git a/python/api-examples-source/widget.radio.py b/python/api-examples-source/widget.radio.py index 11d9405da..6afd93cd5 100644 --- a/python/api-examples-source/widget.radio.py +++ b/python/api-examples-source/widget.radio.py @@ -3,7 +3,8 @@ genre = st.radio( "What's your favorite movie genre", [":rainbow[Comedy]", "***Drama***", "Documentary :movie_camera:"], - captions = ["Laugh out loud.", "Get the popcorn.", "Never stop learning."]) + captions=["Laugh out loud.", "Get the popcorn.", "Never stop learning."], +) if genre == ":rainbow[Comedy]": st.write("You selected comedy.") diff --git a/python/api-examples-source/widget.select_slider.py b/python/api-examples-source/widget.select_slider.py index 61c31a35a..dc704c527 100644 --- a/python/api-examples-source/widget.select_slider.py +++ b/python/api-examples-source/widget.select_slider.py @@ -1,14 +1,16 @@ import streamlit as st color = st.select_slider( - 'Select a color of the rainbow', - options=['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']) + "Select a color of the rainbow", + options=["red", "orange", "yellow", "green", "blue", "indigo", "violet"], +) -st.write('My favorite color is', color) +st.write("My favorite color is", color) start_color, end_color = st.select_slider( - 'Select a range of color wavelength', - options=['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'], - value=('red', 'blue')) + "Select a range of color wavelength", + options=["red", "orange", "yellow", "green", "blue", "indigo", "violet"], + value=("red", "blue"), +) -st.write('You selected wavelengths between', start_color, 'and', end_color) +st.write("You selected wavelengths between", start_color, "and", end_color) diff --git a/python/api-examples-source/widget.selectbox_empty.py b/python/api-examples-source/widget.selectbox_empty.py index 8cdc85cc9..e4bd8ab34 100644 --- a/python/api-examples-source/widget.selectbox_empty.py +++ b/python/api-examples-source/widget.selectbox_empty.py @@ -1,10 +1,10 @@ import streamlit as st option = st.selectbox( - "How would you like to be contacted?", - ("Email", "Home phone", "Mobile phone"), - index=None, - placeholder="Select contact method...", + "How would you like to be contacted?", + ("Email", "Home phone", "Mobile phone"), + index=None, + placeholder="Select contact method...", ) -st.write('You selected:', option) +st.write("You selected:", option) diff --git a/python/api-examples-source/widget.time_input_empty.py b/python/api-examples-source/widget.time_input_empty.py index a8d40bdde..58cda421a 100644 --- a/python/api-examples-source/widget.time_input_empty.py +++ b/python/api-examples-source/widget.time_input_empty.py @@ -1,5 +1,5 @@ import datetime import streamlit as st -t = st.time_input('Set an alarm for', value=None) -st.write('Alarm is set for', t) +t = st.time_input("Set an alarm for", value=None) +st.write("Alarm is set for", t) diff --git a/python/api-examples-source/widget.toggle.py b/python/api-examples-source/widget.toggle.py index 7ee2a4e45..79fd8df9d 100644 --- a/python/api-examples-source/widget.toggle.py +++ b/python/api-examples-source/widget.toggle.py @@ -1,6 +1,6 @@ import streamlit as st -on = st.toggle('Activate feature') +on = st.toggle("Activate feature") if on: - st.write('Feature activated!') + st.write("Feature activated!") From 4a3f6832c90360ef2ab3837cb59e048b5d91df53 Mon Sep 17 00:00:00 2001 From: Debbie Matthews Date: Fri, 15 Sep 2023 06:39:05 -0700 Subject: [PATCH 8/8] Line wrapping in text.text_area.py --- python/api-examples-source/text.text_area.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/api-examples-source/text.text_area.py b/python/api-examples-source/text.text_area.py index 114b11ff4..550b824ae 100644 --- a/python/api-examples-source/text.text_area.py +++ b/python/api-examples-source/text.text_area.py @@ -2,11 +2,11 @@ txt = st.text_area( "Text to analyze", - "It was the best of times, it was " - "the worst of times, it was the age of wisdom, it was the age of " - "foolishness, it was the epoch of belief, it was the epoch of " - "incredulity, it was the season of Light, it was the season of Darkness, " - "it was the spring of hope, it was the winter of despair, (...)", + "It was the best of times, it was the worst of times, it was the age of " + "wisdom, it was the age of foolishness, it was the epoch of belief, it " + "was the epoch of incredulity, it was the season of Light, it was the " + "season of Darkness, it was the spring of hope, it was the winter of " + "despair, (...)", ) st.write(f"You wrote {len(txt)} characters.")