Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,86 +1,105 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import streamlit as st
|
| 3 |
|
| 4 |
st.set_page_config(page_title="Temperature Converter", page_icon=":thermometer:", layout="wide")
|
| 5 |
|
| 6 |
-
# Custom CSS for
|
| 7 |
st.markdown(
|
| 8 |
"""
|
| 9 |
<style>
|
| 10 |
body {
|
| 11 |
-
font-family: '
|
| 12 |
-
background
|
|
|
|
| 13 |
}
|
| 14 |
.converter-container {
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
box-shadow:
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
margin: 20px auto; /* Added margin top/bottom */
|
| 22 |
}
|
| 23 |
.input-group {
|
| 24 |
-
margin-bottom:
|
| 25 |
}
|
| 26 |
.input-group label {
|
| 27 |
-
font-weight: bold
|
| 28 |
-
margin-bottom:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
.stButton>button {
|
| 31 |
-
background-color: #
|
| 32 |
color: white;
|
| 33 |
-
padding:
|
| 34 |
border: none;
|
| 35 |
-
border-radius:
|
| 36 |
cursor: pointer;
|
| 37 |
width: 100%;
|
|
|
|
|
|
|
|
|
|
| 38 |
}
|
| 39 |
.stButton>button:hover {
|
| 40 |
-
background-color: #
|
|
|
|
| 41 |
}
|
| 42 |
.result-area {
|
| 43 |
-
margin-top:
|
| 44 |
-
padding:
|
| 45 |
-
border: 1px solid #
|
| 46 |
-
border-radius:
|
| 47 |
-
background-color: #
|
| 48 |
-
font-size: 1.
|
| 49 |
-
font-weight:
|
| 50 |
-
text-align: center;
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
.quote {
|
| 53 |
font-style: italic;
|
| 54 |
-
color: #
|
| 55 |
-
margin-top:
|
| 56 |
text-align: center;
|
|
|
|
| 57 |
}
|
| 58 |
.image-container {
|
| 59 |
-
text-align: center;
|
| 60 |
-
margin-bottom:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
}
|
| 62 |
</style>
|
| 63 |
""",
|
| 64 |
unsafe_allow_html=True,
|
| 65 |
)
|
| 66 |
|
| 67 |
-
st.title("Temperature Converter")
|
| 68 |
|
| 69 |
-
with st.container() as converter_container:
|
| 70 |
|
| 71 |
-
|
| 72 |
-
st.markdown("<div class='image-container'><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Thermometer_showing_38_degree_Celsius.svg/1200px-Thermometer_showing_38_degree_Celsius.svg.png' alt='Thermometer' width='200'></div>", unsafe_allow_html=True)
|
| 73 |
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
col1, col2 = st.columns([1, 1])
|
| 76 |
|
| 77 |
with col1:
|
| 78 |
-
st.
|
| 79 |
temperature = st.number_input("Temperature", value=0.0)
|
| 80 |
unit_from = st.selectbox("From", ["Celsius", "Fahrenheit", "Kelvin"])
|
| 81 |
|
| 82 |
with col2:
|
| 83 |
-
st.
|
| 84 |
unit_to = st.selectbox("To", ["Celsius", "Fahrenheit", "Kelvin"])
|
| 85 |
|
| 86 |
if st.button("Convert"):
|
|
@@ -102,7 +121,6 @@ with st.container() as converter_container:
|
|
| 102 |
|
| 103 |
st.markdown(f"<div class='result-area'>Result: {result:.2f} {unit_to}</div>", unsafe_allow_html=True)
|
| 104 |
|
| 105 |
-
|
| 106 |
# Quote
|
| 107 |
st.markdown("<p class='quote'>\"The only way to do great work is to love what you do.\" - Steve Jobs</p>", unsafe_allow_html=True)
|
| 108 |
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
st.set_page_config(page_title="Temperature Converter", page_icon=":thermometer:", layout="wide")
|
| 4 |
|
| 5 |
+
# Custom CSS for a more polished look
|
| 6 |
st.markdown(
|
| 7 |
"""
|
| 8 |
<style>
|
| 9 |
body {
|
| 10 |
+
font-family: 'Roboto', sans-serif; /* Modern font */
|
| 11 |
+
background: linear-gradient(to bottom right, #e0eafc, #cfdef3); /* Gradient background */
|
| 12 |
+
color: #333; /* Darker text color */
|
| 13 |
}
|
| 14 |
.converter-container {
|
| 15 |
+
background-color: rgba(255, 255, 255, 0.9); /* Semi-transparent white background */
|
| 16 |
+
border-radius: 15px;
|
| 17 |
+
padding: 40px;
|
| 18 |
+
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); /* More prominent shadow */
|
| 19 |
+
max-width: 800px; /* Increased width */
|
| 20 |
+
margin: 30px auto;
|
|
|
|
| 21 |
}
|
| 22 |
.input-group {
|
| 23 |
+
margin-bottom: 25px;
|
| 24 |
}
|
| 25 |
.input-group label {
|
| 26 |
+
font-weight: 600; /* Semi-bold labels */
|
| 27 |
+
margin-bottom: 10px;
|
| 28 |
+
color: #555;
|
| 29 |
+
}
|
| 30 |
+
.stSelectbox, .stNumberInput {
|
| 31 |
+
border: 1px solid #ced4da; /* Light border for inputs */
|
| 32 |
+
border-radius: 5px;
|
| 33 |
+
padding: 10px;
|
| 34 |
}
|
| 35 |
.stButton>button {
|
| 36 |
+
background-color: #2196f3; /* Modern blue button */
|
| 37 |
color: white;
|
| 38 |
+
padding: 14px 25px;
|
| 39 |
border: none;
|
| 40 |
+
border-radius: 8px;
|
| 41 |
cursor: pointer;
|
| 42 |
width: 100%;
|
| 43 |
+
font-size: 16px; /* Larger font size */
|
| 44 |
+
transition: background-color 0.3s ease; /* Smooth transition */
|
| 45 |
+
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.15); /* Button shadow */
|
| 46 |
}
|
| 47 |
.stButton>button:hover {
|
| 48 |
+
background-color: #1976d2; /* Darker blue on hover */
|
| 49 |
+
box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2); /* Increased shadow on hover */
|
| 50 |
}
|
| 51 |
.result-area {
|
| 52 |
+
margin-top: 30px;
|
| 53 |
+
padding: 20px;
|
| 54 |
+
border: 1px solid #d0d0d0; /* Subtler border */
|
| 55 |
+
border-radius: 8px;
|
| 56 |
+
background-color: #f5f5f5;
|
| 57 |
+
font-size: 1.3em;
|
| 58 |
+
font-weight: 500;
|
| 59 |
+
text-align: center;
|
| 60 |
+
color: #444;
|
| 61 |
+
box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.05); /* Inner shadow */
|
| 62 |
}
|
| 63 |
.quote {
|
| 64 |
font-style: italic;
|
| 65 |
+
color: #666;
|
| 66 |
+
margin-top: 30px;
|
| 67 |
text-align: center;
|
| 68 |
+
font-size: 1.1em;
|
| 69 |
}
|
| 70 |
.image-container {
|
| 71 |
+
text-align: center;
|
| 72 |
+
margin-bottom: 30px;
|
| 73 |
+
}
|
| 74 |
+
.section-heading {
|
| 75 |
+
font-size: 1.6em;
|
| 76 |
+
font-weight: bold;
|
| 77 |
+
margin-bottom: 15px;
|
| 78 |
+
color: #2c3e50; /* Darker heading color */
|
| 79 |
+
text-align: center; /* Center the headings */
|
| 80 |
}
|
| 81 |
</style>
|
| 82 |
""",
|
| 83 |
unsafe_allow_html=True,
|
| 84 |
)
|
| 85 |
|
|
|
|
| 86 |
|
|
|
|
| 87 |
|
| 88 |
+
st.title("Temperature Converter")
|
|
|
|
| 89 |
|
| 90 |
+
with st.container() as converter_container:
|
| 91 |
+
# Image
|
| 92 |
+
st.markdown("<div class='image-container'><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Thermometer_showing_38_degree_Celsius.svg/1200px-Thermometer_showing_38_degree_Celsius.svg.png' alt='Thermometer' width='250'></div>", unsafe_allow_html=True)
|
| 93 |
|
| 94 |
col1, col2 = st.columns([1, 1])
|
| 95 |
|
| 96 |
with col1:
|
| 97 |
+
st.markdown("<h2 class='section-heading'>Input</h2>", unsafe_allow_html=True) # Section heading
|
| 98 |
temperature = st.number_input("Temperature", value=0.0)
|
| 99 |
unit_from = st.selectbox("From", ["Celsius", "Fahrenheit", "Kelvin"])
|
| 100 |
|
| 101 |
with col2:
|
| 102 |
+
st.markdown("<h2 class='section-heading'>Output</h2>", unsafe_allow_html=True) # Section heading
|
| 103 |
unit_to = st.selectbox("To", ["Celsius", "Fahrenheit", "Kelvin"])
|
| 104 |
|
| 105 |
if st.button("Convert"):
|
|
|
|
| 121 |
|
| 122 |
st.markdown(f"<div class='result-area'>Result: {result:.2f} {unit_to}</div>", unsafe_allow_html=True)
|
| 123 |
|
|
|
|
| 124 |
# Quote
|
| 125 |
st.markdown("<p class='quote'>\"The only way to do great work is to love what you do.\" - Steve Jobs</p>", unsafe_allow_html=True)
|
| 126 |
|