-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prerelease 1.40.0: Embedded examples (#1179)
* Bump to nightly * Audio input GA * Button groups * Navigation examples
- Loading branch information
1 parent
918606d
commit 7246208
Showing
16 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import streamlit as st | ||
|
||
st.title("Page 1") |
1 change: 1 addition & 0 deletions
1
python/api-examples-source/navigation.example_1/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
streamlit-nightly |
7 changes: 7 additions & 0 deletions
7
python/api-examples-source/navigation.example_1/streamlit_app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import streamlit as st | ||
|
||
def Page_2(): | ||
st.title("Page 2") | ||
|
||
pg = st.navigation([st.Page("Page_1.py"), st.Page(Page_2)]) | ||
pg.run() |
3 changes: 3 additions & 0 deletions
3
python/api-examples-source/navigation.example_2/create_account.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import streamlit as st | ||
|
||
st.title("Create your account") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import streamlit as st | ||
|
||
st.title("Learn about us") |
3 changes: 3 additions & 0 deletions
3
python/api-examples-source/navigation.example_2/manage_account.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import streamlit as st | ||
|
||
st.title("Manage your account") |
1 change: 1 addition & 0 deletions
1
python/api-examples-source/navigation.example_2/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
streamlit-nightly |
15 changes: 15 additions & 0 deletions
15
python/api-examples-source/navigation.example_2/streamlit_app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import streamlit as st | ||
|
||
pages = { | ||
"Your account": [ | ||
st.Page("create_account.py", title="Create your account"), | ||
st.Page("manage_account.py", title="Manage your account"), | ||
], | ||
"Resources": [ | ||
st.Page("learn.py", title="Learn about us"), | ||
st.Page("trial.py", title="Try it out"), | ||
], | ||
} | ||
|
||
pg = st.navigation(pages) | ||
pg.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import streamlit as st | ||
|
||
st.title("Try it out") |
14 changes: 14 additions & 0 deletions
14
python/api-examples-source/navigation.multipage_widgets.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import streamlit as st | ||
|
||
def page1(): | ||
st.write(st.session_state.foo) | ||
|
||
def page2(): | ||
st.write(st.session_state.bar) | ||
|
||
# Widgets shared by all the pages | ||
st.sidebar.selectbox("Foo", ["A", "B", "C"], key="foo") | ||
st.sidebar.checkbox("Bar", key="bar") | ||
|
||
pg = st.navigation([st.Page(page1), st.Page(page2)]) | ||
pg.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ pydeck | |
Faker | ||
openai | ||
vega_datasets | ||
streamlit>=1.39.0 | ||
streamlit-nightly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import streamlit as st | ||
|
||
audio_value = st.experimental_audio_input("Record a voice message") | ||
audio_value = st.audio_input("Record a voice message") | ||
|
||
if audio_value: | ||
st.audio(audio_value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import streamlit as st | ||
|
||
options = ["North", "East", "South", "West"] | ||
selection = st.pills( | ||
"Directions", | ||
options, | ||
selection_mode="multi" | ||
) | ||
st.markdown(f"Your selected options: {selection}.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import streamlit as st | ||
|
||
option_map = { | ||
0: ":material/add:", | ||
1: ":material/zoom_in:", | ||
2: ":material/zoom_out:", | ||
3: ":material/zoom_out_map:", | ||
} | ||
selection = st.pills( | ||
"Tool", | ||
options=option_map.keys(), | ||
format_func=lambda option: option_map[option], | ||
selection_mode="single", | ||
) | ||
st.write( | ||
"Your selected option: " | ||
f"{None if selection is None else option_map[selection]}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import streamlit as st | ||
|
||
options = ["North", "East", "South", "West"] | ||
selection = st.segmented_control( | ||
"Directions", | ||
options, | ||
selection_mode="multi" | ||
) | ||
st.markdown(f"Your selected options: {selection}.") |
18 changes: 18 additions & 0 deletions
18
python/api-examples-source/widget.segmented_control_single.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import streamlit as st | ||
|
||
option_map = { | ||
0: ":material/add:", | ||
1: ":material/zoom_in:", | ||
2: ":material/zoom_out:", | ||
3: ":material/zoom_out_map:", | ||
} | ||
selection = st.segmented_control( | ||
"Tool", | ||
options=option_map.keys(), | ||
format_func=lambda option: option_map[option], | ||
selection_mode="single", | ||
) | ||
st.write( | ||
"Your selected option: " | ||
f"{None if selection is None else option_map[selection]}" | ||
) |