Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Full App Code
|
2 |
+
|
3 |
+
import streamlit as st
|
4 |
+
import pandas as pd
|
5 |
+
|
6 |
+
# Define function for dramatic header
|
7 |
+
def dramatic_header(text, emoji):
|
8 |
+
st.markdown(f"## {emoji} {text} {emoji}")
|
9 |
+
|
10 |
+
# Streamlit App Function
|
11 |
+
def glasses_art_app():
|
12 |
+
st.title("Glasses Art Workshop πΆοΈ")
|
13 |
+
|
14 |
+
# Dramatic Situation 1: The Creation Challenge
|
15 |
+
dramatic_header("The Creation Challenge", "πΌοΈ")
|
16 |
+
st.markdown("**Artisans**, welcome to the ultimate glasses design competition!")
|
17 |
+
|
18 |
+
glass_types = ["Round", "Square", "Cat Eye", "Aviator"]
|
19 |
+
colors = ["Red", "Blue", "Green", "Black", "White"]
|
20 |
+
materials = ["Plastic", "Metal", "Wood", "Composite"]
|
21 |
+
|
22 |
+
chosen_glass = st.selectbox("Choose your glass type:", glass_types)
|
23 |
+
chosen_color = st.color_picker("Pick a color for your glasses:", "#000000")
|
24 |
+
chosen_material = st.selectbox("Choose the material:", materials)
|
25 |
+
|
26 |
+
st.markdown(f"πΆοΈ You have chosen **{chosen_glass}**, color **{chosen_color}**, and material **{chosen_material}**!")
|
27 |
+
|
28 |
+
if "designs" not in st.session_state:
|
29 |
+
st.session_state.designs = []
|
30 |
+
|
31 |
+
design = {"glass_type": chosen_glass, "color": chosen_color, "material": chosen_material}
|
32 |
+
if st.button("Submit Design"):
|
33 |
+
st.session_state.designs.append(design)
|
34 |
+
st.success("Design submitted!")
|
35 |
+
|
36 |
+
# Dramatic Situation 2: The Evaluation
|
37 |
+
dramatic_header("The Evaluation", "π")
|
38 |
+
st.markdown("**Enthusiasts**, it's time to review the latest designs!")
|
39 |
+
|
40 |
+
if st.session_state.designs:
|
41 |
+
designs_df = pd.DataFrame(st.session_state.designs)
|
42 |
+
st.dataframe(designs_df)
|
43 |
+
|
44 |
+
ratings = {}
|
45 |
+
for i, design in designs_df.iterrows():
|
46 |
+
rating = st.slider(f"Rate design {i+1}: {design['glass_type']} ({design['color']}, {design['material']})", 1, 5, 3)
|
47 |
+
ratings[i] = rating
|
48 |
+
|
49 |
+
if st.button("Submit Ratings"):
|
50 |
+
st.session_state.ratings = ratings
|
51 |
+
st.success("Ratings submitted!")
|
52 |
+
|
53 |
+
# Dramatic Situation 3: The Exhibition
|
54 |
+
dramatic_header("The Exhibition", "π")
|
55 |
+
st.markdown("Check out the top-rated designs in our virtual gallery!")
|
56 |
+
|
57 |
+
if st.session_state.get("ratings"):
|
58 |
+
rated_designs = [{"design": st.session_state.designs[i], "rating": rating} for i, rating in st.session_state.ratings.items()]
|
59 |
+
top_rated_designs = sorted(rated_designs, key=lambda x: x["rating"], reverse=True)
|
60 |
+
|
61 |
+
st.markdown("### π Top Designs π")
|
62 |
+
for item in top_rated_designs:
|
63 |
+
design = item["design"]
|
64 |
+
rating = item["rating"]
|
65 |
+
st.markdown(f"**{design['glass_type']}** ({design['color']}, {design['material']}) β Rating: {rating}/5")
|
66 |
+
|
67 |
+
# Call the app function
|
68 |
+
glasses_art_app()
|