Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,9 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import calendar
|
| 3 |
-
|
| 4 |
-
# Define images for each month (seasonal backgrounds)
|
| 5 |
-
month_images = {
|
| 6 |
-
1: "https://example.com/january.jpg", # Winter for January
|
| 7 |
-
2: "https://example.com/february.jpg", # Winter for February
|
| 8 |
-
3: "https://example.com/march.jpg", # Spring for March
|
| 9 |
-
4: "https://example.com/april.jpg", # Spring for April
|
| 10 |
-
5: "https://example.com/may.jpg", # Spring for May
|
| 11 |
-
6: "https://example.com/june.jpg", # Summer for June
|
| 12 |
-
7: "https://example.com/july.jpg", # Summer for July
|
| 13 |
-
8: "https://example.com/august.jpg", # Summer for August
|
| 14 |
-
9: "https://example.com/september.jpg", # Fall for September
|
| 15 |
-
10: "https://example.com/october.jpg", # Fall for October
|
| 16 |
-
11: "https://example.com/november.jpg", # Fall for November
|
| 17 |
-
12: "https://example.com/december.jpg", # Winter for December
|
| 18 |
-
}
|
| 19 |
|
| 20 |
# Function to display the full calendar for a specific month and year
|
| 21 |
-
def display_full_calendar(year, month):
|
| 22 |
# Display the month and year
|
| 23 |
st.write(f"### {calendar.month_name[month]} {year}")
|
| 24 |
|
|
@@ -29,41 +14,50 @@ def display_full_calendar(year, month):
|
|
| 29 |
days_of_week = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
|
| 30 |
|
| 31 |
# Set the background image for the month
|
| 32 |
-
bg_image_url = month_images.get(month,
|
| 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 |
# Create the table
|
| 69 |
table_html = "<div class='calendar'><table>"
|
|
@@ -96,14 +90,28 @@ def display_full_calendar(year, month):
|
|
| 96 |
# Streamlit app title
|
| 97 |
st.title('2025 Calendar Viewer')
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
# Get user input for the month (default to 2025)
|
| 100 |
year = 2025
|
| 101 |
month = st.slider('Select month:', 1, 12, 1)
|
| 102 |
|
| 103 |
# Display the calendar for the selected month of the year 2025
|
| 104 |
-
display_full_calendar(year, month)
|
| 105 |
|
| 106 |
# Optionally, display all months in 2025
|
| 107 |
if st.checkbox('Show all months for 2025'):
|
| 108 |
for month in range(1, 13):
|
| 109 |
-
display_full_calendar(year, month)
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import calendar
|
| 3 |
+
from PIL import Image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# Function to display the full calendar for a specific month and year
|
| 6 |
+
def display_full_calendar(year, month, month_images):
|
| 7 |
# Display the month and year
|
| 8 |
st.write(f"### {calendar.month_name[month]} {year}")
|
| 9 |
|
|
|
|
| 14 |
days_of_week = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
|
| 15 |
|
| 16 |
# Set the background image for the month
|
| 17 |
+
bg_image_url = month_images.get(month, None)
|
| 18 |
+
if bg_image_url:
|
| 19 |
+
st.markdown(
|
| 20 |
+
f"""
|
| 21 |
+
<style>
|
| 22 |
+
.calendar {{
|
| 23 |
+
background-image: url('{bg_image_url}');
|
| 24 |
+
background-size: cover;
|
| 25 |
+
background-position: center;
|
| 26 |
+
padding: 20px;
|
| 27 |
+
border-radius: 10px;
|
| 28 |
+
}}
|
| 29 |
+
table {{
|
| 30 |
+
border-collapse: collapse;
|
| 31 |
+
width: 90%;
|
| 32 |
+
margin: 10px auto;
|
| 33 |
+
background-color: rgba(255, 255, 255, 0.8);
|
| 34 |
+
}}
|
| 35 |
+
th, td {{
|
| 36 |
+
text-align: center;
|
| 37 |
+
padding: 8px;
|
| 38 |
+
border: 1px solid #ccc;
|
| 39 |
+
font-size: 12px;
|
| 40 |
+
height: 30px;
|
| 41 |
+
}}
|
| 42 |
+
th {{
|
| 43 |
+
background-color: #f2f2f2;
|
| 44 |
+
color: #333;
|
| 45 |
+
}}
|
| 46 |
+
td {{
|
| 47 |
+
background-color: #ffffff;
|
| 48 |
+
color: #333;
|
| 49 |
+
}}
|
| 50 |
+
td.weekend {{
|
| 51 |
+
background-color: #ffeb3b; /* Yellow for weekends */
|
| 52 |
+
}}
|
| 53 |
+
td.empty {{
|
| 54 |
+
background-color: rgba(255, 255, 255, 0.3); /* Light for empty cells */
|
| 55 |
+
}}
|
| 56 |
+
td.highlight {{
|
| 57 |
+
background-color: #76d7c4; /* Light teal for highlight */
|
| 58 |
+
}}
|
| 59 |
+
</style>
|
| 60 |
+
""", unsafe_allow_html=True)
|
| 61 |
|
| 62 |
# Create the table
|
| 63 |
table_html = "<div class='calendar'><table>"
|
|
|
|
| 90 |
# Streamlit app title
|
| 91 |
st.title('2025 Calendar Viewer')
|
| 92 |
|
| 93 |
+
# File uploader to upload images
|
| 94 |
+
st.subheader('Upload images for each month')
|
| 95 |
+
uploaded_files = {}
|
| 96 |
+
months = list(calendar.month_name[1:])
|
| 97 |
+
for month in months:
|
| 98 |
+
uploaded_files[month] = st.file_uploader(f"Upload image for {month}", type=["jpg", "png"])
|
| 99 |
+
|
| 100 |
+
# Map the uploaded images to each month
|
| 101 |
+
month_images = {}
|
| 102 |
+
for month, image in uploaded_files.items():
|
| 103 |
+
if image is not None:
|
| 104 |
+
month_images[calendar.month_name.index(month)] = image
|
| 105 |
+
|
| 106 |
# Get user input for the month (default to 2025)
|
| 107 |
year = 2025
|
| 108 |
month = st.slider('Select month:', 1, 12, 1)
|
| 109 |
|
| 110 |
# Display the calendar for the selected month of the year 2025
|
| 111 |
+
display_full_calendar(year, month, month_images)
|
| 112 |
|
| 113 |
# Optionally, display all months in 2025
|
| 114 |
if st.checkbox('Show all months for 2025'):
|
| 115 |
for month in range(1, 13):
|
| 116 |
+
display_full_calendar(year, month, month_images)
|
| 117 |
+
|