|
import streamlit as st |
|
import calendar |
|
|
|
|
|
month_images = { |
|
1: "https://via.placeholder.com/150/0000FF/808080?Text=January", |
|
2: "https://via.placeholder.com/150/FF0000/FFFFFF?Text=February", |
|
3: "https://via.placeholder.com/150/00FF00/FFFFFF?Text=March", |
|
4: "https://via.placeholder.com/150/FFFF00/000000?Text=April", |
|
5: "https://via.placeholder.com/150/FF00FF/FFFFFF?Text=May", |
|
6: "https://via.placeholder.com/150/00FFFF/000000?Text=June", |
|
7: "https://via.placeholder.com/150/FF7F00/FFFFFF?Text=July", |
|
8: "https://via.placeholder.com/150/7FFF00/000000?Text=August", |
|
9: "https://via.placeholder.com/150/8A2BE2/FFFFFF?Text=September", |
|
10: "https://via.placeholder.com/150/FF1493/FFFFFF?Text=October", |
|
11: "https://via.placeholder.com/150/DC143C/FFFFFF?Text=November", |
|
12: "https://via.placeholder.com/150/800080/FFFFFF?Text=December", |
|
} |
|
|
|
|
|
def display_full_calendar(year, month): |
|
|
|
st.write(f"### {calendar.month_name[month]} {year}") |
|
|
|
|
|
month_calendar = calendar.monthcalendar(year, month) |
|
|
|
|
|
days_of_week = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] |
|
|
|
|
|
bg_image_url = month_images.get(month, "") |
|
st.markdown( |
|
f""" |
|
<style> |
|
.calendar {{ |
|
background-image: url('{bg_image_url}'); |
|
background-size: cover; |
|
background-position: center; |
|
padding: 20px; |
|
border-radius: 10px; |
|
}} |
|
table {{ |
|
border-collapse: collapse; |
|
width: 90%; |
|
margin: 10px auto; |
|
background-color: rgba(255, 255, 255, 0.8); |
|
}} |
|
th, td {{ |
|
text-align: center; |
|
padding: 8px; |
|
border: 1px solid #ccc; |
|
font-size: 12px; |
|
height: 30px; |
|
}} |
|
th {{ |
|
background-color: #f2f2f2; |
|
color: #333; |
|
}} |
|
td {{ |
|
background-color: #ffffff; |
|
color: #333; |
|
}} |
|
td.weekend {{ |
|
background-color: #ffeb3b; /* Yellow for weekends */ |
|
}} |
|
td.empty {{ |
|
background-color: rgba(255, 255, 255, 0.3); /* Light for empty cells */ |
|
}} |
|
td.highlight {{ |
|
background-color: #76d7c4; /* Light teal for highlight */ |
|
}} |
|
</style> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
table_html = "<div class='calendar'><table>" |
|
|
|
|
|
table_html += "<tr>" |
|
for day in days_of_week: |
|
table_html += f"<th>{day}</th>" |
|
table_html += "</tr>" |
|
|
|
|
|
for week in month_calendar: |
|
table_html += "<tr>" |
|
for i, day in enumerate(week): |
|
if day == 0: |
|
table_html += "<td class='empty'></td>" |
|
else: |
|
|
|
if i == 5 or i == 6: |
|
table_html += f"<td class='weekend'>{day}</td>" |
|
else: |
|
table_html += f"<td>{day}</td>" |
|
table_html += "</tr>" |
|
|
|
table_html += "</table></div>" |
|
|
|
|
|
st.markdown(table_html, unsafe_allow_html=True) |
|
|
|
|
|
st.title('2025 Calendar Viewer') |
|
|
|
|
|
year = 2025 |
|
month = st.slider('Select month:', 1, 12, 1) |
|
|
|
|
|
display_full_calendar(year, month) |
|
|
|
|
|
if st.checkbox('Show all months for 2025'): |
|
for month in range(1, 13): |
|
display_full_calendar(year, month) |
|
|