Update app.py
Browse files
app.py
CHANGED
|
@@ -3,14 +3,43 @@ import calendar
|
|
| 3 |
|
| 4 |
# Function to display the full calendar for a specific month and year
|
| 5 |
def display_full_calendar(year, month):
|
| 6 |
-
# Display the
|
| 7 |
st.write(f"### {calendar.month_name[month]} {year}")
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Streamlit app title
|
| 11 |
st.title('2025 Calendar Viewer')
|
| 12 |
|
| 13 |
-
# Get user input for the month
|
| 14 |
year = 2025
|
| 15 |
month = st.slider('Select month:', 1, 12, 1)
|
| 16 |
|
|
@@ -21,3 +50,4 @@ display_full_calendar(year, month)
|
|
| 21 |
if st.checkbox('Show all months for 2025'):
|
| 22 |
for month in range(1, 13):
|
| 23 |
display_full_calendar(year, month)
|
|
|
|
|
|
| 3 |
|
| 4 |
# Function to display the full calendar for a specific month and year
|
| 5 |
def display_full_calendar(year, month):
|
| 6 |
+
# Display the month and year
|
| 7 |
st.write(f"### {calendar.month_name[month]} {year}")
|
| 8 |
+
|
| 9 |
+
# Get the calendar for the month (returns a list of weeks)
|
| 10 |
+
month_calendar = calendar.monthcalendar(year, month)
|
| 11 |
+
|
| 12 |
+
# Days of the week headers
|
| 13 |
+
days_of_week = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
|
| 14 |
+
|
| 15 |
+
# Create a formatted HTML table
|
| 16 |
+
table_html = "<table style='border-collapse: collapse; width: 100%;'>"
|
| 17 |
+
|
| 18 |
+
# Add the days of the week as the header row
|
| 19 |
+
table_html += "<tr>"
|
| 20 |
+
for day in days_of_week:
|
| 21 |
+
table_html += f"<th style='border: 1px solid black; padding: 8px; text-align: center;'>{day}</th>"
|
| 22 |
+
table_html += "</tr>"
|
| 23 |
+
|
| 24 |
+
# Add the weeks to the table
|
| 25 |
+
for week in month_calendar:
|
| 26 |
+
table_html += "<tr>"
|
| 27 |
+
for day in week:
|
| 28 |
+
if day == 0:
|
| 29 |
+
table_html += "<td style='border: 1px solid black; height: 40px;'></td>" # Empty cell for days of the week that are not part of the month
|
| 30 |
+
else:
|
| 31 |
+
table_html += f"<td style='border: 1px solid black; height: 40px; text-align: center;'>{day}</td>"
|
| 32 |
+
table_html += "</tr>"
|
| 33 |
+
|
| 34 |
+
table_html += "</table>"
|
| 35 |
+
|
| 36 |
+
# Display the formatted calendar as HTML
|
| 37 |
+
st.markdown(table_html, unsafe_allow_html=True)
|
| 38 |
|
| 39 |
# Streamlit app title
|
| 40 |
st.title('2025 Calendar Viewer')
|
| 41 |
|
| 42 |
+
# Get user input for the month (default to 2025)
|
| 43 |
year = 2025
|
| 44 |
month = st.slider('Select month:', 1, 12, 1)
|
| 45 |
|
|
|
|
| 50 |
if st.checkbox('Show all months for 2025'):
|
| 51 |
for month in range(1, 13):
|
| 52 |
display_full_calendar(year, month)
|
| 53 |
+
|