Dearsawan commited on
Commit
2b136cd
·
verified ·
1 Parent(s): 1362911

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -9
app.py CHANGED
@@ -1,6 +1,22 @@
1
  import streamlit as st
2
  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 month and year
@@ -12,13 +28,50 @@ def display_full_calendar(year, month):
12
  # Days of the week headers
13
  days_of_week = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
14
 
15
- # Create a formatted HTML table with colors
16
- table_html = "<table style='border-collapse: collapse; width: 80%; margin: 20px auto;'>"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- # Add the days of the week as the header row with background color
19
- table_html += "<tr style='background-color: #f0f0f0;'>"
20
  for day in days_of_week:
21
- table_html += f"<th style='border: 1px solid #ccc; padding: 5px; text-align: center; background-color: #e0e0e0;'>{day}</th>"
22
  table_html += "</tr>"
23
 
24
  # Add the weeks to the table
@@ -26,16 +79,16 @@ def display_full_calendar(year, month):
26
  table_html += "<tr>"
27
  for i, day in enumerate(week):
28
  if day == 0:
29
- table_html += "<td style='border: 1px solid #ccc; height: 30px;'></td>" # Empty cell for days not in the month
30
  else:
31
  # Color weekends (Saturday and Sunday)
32
  if i == 5 or i == 6:
33
- table_html += f"<td style='border: 1px solid #ccc; height: 30px; text-align: center; background-color: #ffeb3b;'>{day}</td>"
34
  else:
35
- table_html += f"<td style='border: 1px solid #ccc; height: 30px; text-align: center; background-color: #ffffff;'>{day}</td>"
36
  table_html += "</tr>"
37
 
38
- table_html += "</table>"
39
 
40
  # Display the formatted calendar as HTML
41
  st.markdown(table_html, unsafe_allow_html=True)
 
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
 
28
  # Days of the week headers
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
+ }}
42
+ table {{
43
+ border-collapse: collapse;
44
+ width: 100%;
45
+ }}
46
+ th, td {{
47
+ text-align: center;
48
+ padding: 5px;
49
+ border: 1px solid #ccc;
50
+ font-size: 14px;
51
+ height: 30px;
52
+ }}
53
+ th {{
54
+ background-color: rgba(255, 255, 255, 0.8);
55
+ }}
56
+ td {{
57
+ background-color: rgba(255, 255, 255, 0.6);
58
+ }}
59
+ td.weekend {{
60
+ background-color: rgba(255, 233, 59, 0.8); /* Yellow for weekends */
61
+ }}
62
+ td.empty {{
63
+ background-color: rgba(255, 255, 255, 0.2); /* Light for empty cells */
64
+ }}
65
+ </style>
66
+ """, unsafe_allow_html=True)
67
+
68
+ # Create the table
69
+ table_html = "<div class='calendar'><table>"
70
 
71
+ # Add the days of the week as the header row
72
+ table_html += "<tr>"
73
  for day in days_of_week:
74
+ table_html += f"<th>{day}</th>"
75
  table_html += "</tr>"
76
 
77
  # Add the weeks to the table
 
79
  table_html += "<tr>"
80
  for i, day in enumerate(week):
81
  if day == 0:
82
+ table_html += "<td class='empty'></td>" # Empty cell for days not in the month
83
  else:
84
  # Color weekends (Saturday and Sunday)
85
  if i == 5 or i == 6:
86
+ table_html += f"<td class='weekend'>{day}</td>"
87
  else:
88
+ table_html += f"<td>{day}</td>"
89
  table_html += "</tr>"
90
 
91
+ table_html += "</table></div>"
92
 
93
  # Display the formatted calendar as HTML
94
  st.markdown(table_html, unsafe_allow_html=True)