Fix TypeError in calendar update by returning y_pos on draw_event error

This commit is contained in:
ChuckBuilds
2025-04-21 14:22:48 -05:00
parent bbf855b60a
commit 16321ccc9c

View File

@@ -98,6 +98,7 @@ class CalendarManager:
def draw_event(self, event, y_start=1):
"""Draw a single calendar event on the canvas."""
y_pos_at_start = y_start # Store the starting position
try:
# Get event details
summary = event.get('summary', 'No Title')
@@ -136,9 +137,11 @@ class CalendarManager:
break
self.display_manager.draw_text(line, y=y_pos, color=self.text_color, small_font=True)
y_pos += 8 + 2 # Move down for the next line, add 2px spacing
return y_pos # Return the final y position if successful
except Exception as e:
logging.error(f"Error drawing calendar event: {str(e)}", exc_info=True)
return y_pos_at_start # Return the original starting position on error
def _wrap_text(self, text, max_width, font):
"""Wrap text to fit within max_width using the provided font."""