File size: 2,701 Bytes
8717b14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Full App Code

import streamlit as st
import pandas as pd

# Define function for dramatic header
def dramatic_header(text, emoji):
    st.markdown(f"## {emoji} {text} {emoji}")

# Streamlit App Function
def glasses_art_app():
    st.title("Glasses Art Workshop πŸ•ΆοΈ")

    # Dramatic Situation 1: The Creation Challenge
    dramatic_header("The Creation Challenge", "πŸ–ΌοΈ")
    st.markdown("**Artisans**, welcome to the ultimate glasses design competition!")

    glass_types = ["Round", "Square", "Cat Eye", "Aviator"]
    colors = ["Red", "Blue", "Green", "Black", "White"]
    materials = ["Plastic", "Metal", "Wood", "Composite"]

    chosen_glass = st.selectbox("Choose your glass type:", glass_types)
    chosen_color = st.color_picker("Pick a color for your glasses:", "#000000")
    chosen_material = st.selectbox("Choose the material:", materials)

    st.markdown(f"πŸ•ΆοΈ You have chosen **{chosen_glass}**, color **{chosen_color}**, and material **{chosen_material}**!")

    if "designs" not in st.session_state:
        st.session_state.designs = []

    design = {"glass_type": chosen_glass, "color": chosen_color, "material": chosen_material}
    if st.button("Submit Design"):
        st.session_state.designs.append(design)
        st.success("Design submitted!")

    # Dramatic Situation 2: The Evaluation
    dramatic_header("The Evaluation", "πŸ”„")
    st.markdown("**Enthusiasts**, it's time to review the latest designs!")

    if st.session_state.designs:
        designs_df = pd.DataFrame(st.session_state.designs)
        st.dataframe(designs_df)

        ratings = {}
        for i, design in designs_df.iterrows():
            rating = st.slider(f"Rate design {i+1}: {design['glass_type']} ({design['color']}, {design['material']})", 1, 5, 3)
            ratings[i] = rating

        if st.button("Submit Ratings"):
            st.session_state.ratings = ratings
            st.success("Ratings submitted!")

    # Dramatic Situation 3: The Exhibition
    dramatic_header("The Exhibition", "πŸŽ‰")
    st.markdown("Check out the top-rated designs in our virtual gallery!")

    if st.session_state.get("ratings"):
        rated_designs = [{"design": st.session_state.designs[i], "rating": rating} for i, rating in st.session_state.ratings.items()]
        top_rated_designs = sorted(rated_designs, key=lambda x: x["rating"], reverse=True)

        st.markdown("### πŸ† Top Designs πŸ†")
        for item in top_rated_designs:
            design = item["design"]
            rating = item["rating"]
            st.markdown(f"**{design['glass_type']}** ({design['color']}, {design['material']}) – Rating: {rating}/5")

# Call the app function
glasses_art_app()