Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,77 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
# Define the HTML and CSS for the cloud-shaped button and text field
|
4 |
+
cloud_button_html = """
|
5 |
+
<style>
|
6 |
+
.cloud-button {
|
7 |
+
background-color: #FFCC99;
|
8 |
+
border: none;
|
9 |
+
color: white;
|
10 |
+
padding: 10px 20px;
|
11 |
+
text-align: center;
|
12 |
+
text-decoration: none;
|
13 |
+
display: inline-block;
|
14 |
+
font-size: 16px;
|
15 |
+
margin: 4px 2px;
|
16 |
+
transition-duration: 0.4s;
|
17 |
+
cursor: pointer;
|
18 |
+
border-radius: 16px;
|
19 |
+
box-shadow: 0 6px 6px 0 rgba(0, 0, 0, 0.24), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
|
20 |
+
position: relative;
|
21 |
+
}
|
22 |
+
|
23 |
+
.cloud-button:after {
|
24 |
+
content: "";
|
25 |
+
position: absolute;
|
26 |
+
top: 100%;
|
27 |
+
left: 50%;
|
28 |
+
border-width: 0 15px 10px 15px;
|
29 |
+
border-style: solid;
|
30 |
+
border-color: #FFCC99 transparent transparent transparent;
|
31 |
+
margin-left: -15px;
|
32 |
+
margin-top: -2px;
|
33 |
+
}
|
34 |
+
|
35 |
+
.text-field {
|
36 |
+
border: none;
|
37 |
+
background: transparent;
|
38 |
+
color: #333;
|
39 |
+
width: 100%;
|
40 |
+
text-align: center;
|
41 |
+
}
|
42 |
+
</style>
|
43 |
+
<div style="text-align: center; margin-top: 20px;">
|
44 |
+
<button class="cloud-button" onclick="handleClick()">
|
45 |
+
<input type="text" value="this is a text field" class="text-field" readonly />
|
46 |
+
</button>
|
47 |
+
</div>
|
48 |
+
<script>
|
49 |
+
function handleClick() {
|
50 |
+
const outputDiv = document.getElementById('output');
|
51 |
+
if(outputDiv) {
|
52 |
+
outputDiv.innerText = 'success';
|
53 |
+
}
|
54 |
+
}
|
55 |
+
</script>
|
56 |
+
"""
|
57 |
+
|
58 |
+
# Render the cloud button with Streamlit
|
59 |
+
st.markdown(cloud_button_html, unsafe_allow_html=True)
|
60 |
+
|
61 |
+
# Placeholder for the output text
|
62 |
+
output = st.empty()
|
63 |
+
|
64 |
+
# Update the output text when the button is clicked
|
65 |
+
if "button_clicked" not in st.session_state:
|
66 |
+
st.session_state["button_clicked"] = False
|
67 |
+
|
68 |
+
if st.session_state["button_clicked"]:
|
69 |
+
output.text("success")
|
70 |
+
|
71 |
+
# Button click handler
|
72 |
+
with st.form(key="my_form"):
|
73 |
+
submit_button = st.button("Click me!")
|
74 |
+
if submit_button:
|
75 |
+
st.session_state["button_clicked"] = True
|
76 |
|
77 |
|