Skip to content

Commit 3fd039f

Browse files
Prerelease 1.43.0 - Embedded apps (#1237)
* switch to nightly * File uploader for chat input * Json column example * Download button examples * Paragraph padding in admonitions
1 parent 0d16bb0 commit 3fd039f

File tree

7 files changed

+88
-6
lines changed

7 files changed

+88
-6
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import streamlit as st
2+
3+
prompt = st.chat_input(
4+
"Say something and/or attach an image",
5+
accept_file=True,
6+
file_type=["jpg", "jpeg", "png"],
7+
)
8+
if prompt and prompt.text:
9+
st.markdown(prompt.text)
10+
if prompt and prompt["files"]:
11+
st.image(prompt["files"][0])
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pandas as pd
2+
import streamlit as st
3+
4+
data_df = pd.DataFrame(
5+
{
6+
"json": [
7+
{"foo": "bar", "bar": "baz"},
8+
{"foo": "baz", "bar": "qux"},
9+
{"foo": "qux", "bar": "foo"},
10+
None,
11+
],
12+
}
13+
)
14+
15+
st.dataframe(
16+
data_df,
17+
column_config={
18+
"json": st.column_config.JsonColumn(
19+
"JSON Data",
20+
help="JSON strings or objects",
21+
width="large",
22+
),
23+
},
24+
hide_index=True,
25+
)

python/api-examples-source/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ pydeck
1111
Faker
1212
openai
1313
vega_datasets
14-
streamlit>=1.42.0
14+
streamlit-nightly
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import streamlit as st
2+
import pandas as pd
3+
import numpy as np
4+
5+
6+
@st.cache_data
7+
def get_data():
8+
df = pd.DataFrame(
9+
np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
10+
)
11+
return df
12+
13+
14+
@st.cache_data
15+
def convert_for_download(df):
16+
return df.to_csv().encode("utf-8")
17+
18+
19+
df = get_data()
20+
csv = convert_for_download(df)
21+
22+
st.download_button(
23+
label="Download CSV",
24+
data=csv,
25+
file_name="data.csv",
26+
mime="text/csv",
27+
icon=":material/download:",
28+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import streamlit as st
2+
3+
with open("python/api-examples-source/flower.png", "rb") as file:
4+
st.download_button(
5+
label="Download image",
6+
data=file,
7+
file_name="flower.png",
8+
mime="image/png",
9+
)
10+
st.write(type(file))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import streamlit as st
2+
import time
3+
4+
message = st.text_area("Message", value="Lorem ipsum.\nStreamlit is cool.")
5+
time.sleep(.5) # Simulate some other code running
6+
7+
st.download_button(
8+
label="Download text",
9+
data=message,
10+
file_name="message.txt",
11+
mime="text/txt",
12+
on_click="ignore",
13+
)

styles/admonition.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ div.admonition {
77
@apply text-lg font-bold;
88
}
99

10-
// Text
11-
p {
12-
@apply mb-0;
13-
}
14-
1510
// Note
1611
&.note {
1712
@apply bg-lightBlue-10 dark:bg-lightBlue-100/30;

0 commit comments

Comments
 (0)