Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,24 @@
|
|
1 |
import streamlit as st
|
2 |
import calendar
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# Function to display the full calendar for a specific month and year
|
6 |
-
def display_full_calendar(year, month
|
7 |
# Display the month and year
|
8 |
st.write(f"### {calendar.month_name[month]} {year}")
|
9 |
|
@@ -14,50 +29,49 @@ def display_full_calendar(year, month, month_images):
|
|
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,
|
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 |
-
""", unsafe_allow_html=True)
|
61 |
|
62 |
# Create the table
|
63 |
table_html = "<div class='calendar'><table>"
|
@@ -90,28 +104,14 @@ def display_full_calendar(year, month, month_images):
|
|
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
|
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
|
117 |
-
|
|
|
1 |
import streamlit as st
|
2 |
import calendar
|
3 |
+
|
4 |
+
# Define images for each month (seasonal backgrounds) - you can change this to URLs of your choice
|
5 |
+
month_images = {
|
6 |
+
1: "https://via.placeholder.com/150/0000FF/808080?Text=January", # Placeholder image for January
|
7 |
+
2: "https://via.placeholder.com/150/FF0000/FFFFFF?Text=February", # Placeholder image for February
|
8 |
+
3: "https://via.placeholder.com/150/00FF00/FFFFFF?Text=March", # Placeholder image for March
|
9 |
+
4: "https://via.placeholder.com/150/FFFF00/000000?Text=April", # Placeholder image for April
|
10 |
+
5: "https://via.placeholder.com/150/FF00FF/FFFFFF?Text=May", # Placeholder image for May
|
11 |
+
6: "https://via.placeholder.com/150/00FFFF/000000?Text=June", # Placeholder image for June
|
12 |
+
7: "https://via.placeholder.com/150/FF7F00/FFFFFF?Text=July", # Placeholder image for July
|
13 |
+
8: "https://via.placeholder.com/150/7FFF00/000000?Text=August", # Placeholder image for August
|
14 |
+
9: "https://via.placeholder.com/150/8A2BE2/FFFFFF?Text=September", # Placeholder image for September
|
15 |
+
10: "https://via.placeholder.com/150/FF1493/FFFFFF?Text=October", # Placeholder image for October
|
16 |
+
11: "https://via.placeholder.com/150/DC143C/FFFFFF?Text=November", # Placeholder image for November
|
17 |
+
12: "https://via.placeholder.com/150/800080/FFFFFF?Text=December", # Placeholder image 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 |
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 |
+
st.markdown(
|
34 |
+
f"""
|
35 |
+
<style>
|
36 |
+
.calendar {{
|
37 |
+
background-image: url('{bg_image_url}');
|
38 |
+
background-size: cover;
|
39 |
+
background-position: center;
|
40 |
+
padding: 20px;
|
41 |
+
border-radius: 10px;
|
42 |
+
}}
|
43 |
+
table {{
|
44 |
+
border-collapse: collapse;
|
45 |
+
width: 90%;
|
46 |
+
margin: 10px auto;
|
47 |
+
background-color: rgba(255, 255, 255, 0.8);
|
48 |
+
}}
|
49 |
+
th, td {{
|
50 |
+
text-align: center;
|
51 |
+
padding: 8px;
|
52 |
+
border: 1px solid #ccc;
|
53 |
+
font-size: 12px;
|
54 |
+
height: 30px;
|
55 |
+
}}
|
56 |
+
th {{
|
57 |
+
background-color: #f2f2f2;
|
58 |
+
color: #333;
|
59 |
+
}}
|
60 |
+
td {{
|
61 |
+
background-color: #ffffff;
|
62 |
+
color: #333;
|
63 |
+
}}
|
64 |
+
td.weekend {{
|
65 |
+
background-color: #ffeb3b; /* Yellow for weekends */
|
66 |
+
}}
|
67 |
+
td.empty {{
|
68 |
+
background-color: rgba(255, 255, 255, 0.3); /* Light for empty cells */
|
69 |
+
}}
|
70 |
+
td.highlight {{
|
71 |
+
background-color: #76d7c4; /* Light teal for highlight */
|
72 |
+
}}
|
73 |
+
</style>
|
74 |
+
""", unsafe_allow_html=True)
|
|
|
75 |
|
76 |
# Create the table
|
77 |
table_html = "<div class='calendar'><table>"
|
|
|
104 |
# Streamlit app title
|
105 |
st.title('2025 Calendar Viewer')
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
# Get user input for the month (default to 2025)
|
108 |
year = 2025
|
109 |
month = st.slider('Select month:', 1, 12, 1)
|
110 |
|
111 |
# Display the calendar for the selected month of the year 2025
|
112 |
+
display_full_calendar(year, month)
|
113 |
|
114 |
# Optionally, display all months in 2025
|
115 |
if st.checkbox('Show all months for 2025'):
|
116 |
for month in range(1, 13):
|
117 |
+
display_full_calendar(year, month)
|
|