From b01969d2da021c80b8a1044df4a682c168ecc71e Mon Sep 17 00:00:00 2001 From: Max G Date: Tue, 26 Mar 2019 22:31:05 +0100 Subject: [PATCH] Partially integrated TextFormatter --- Calendar/EventListDesign.py | 8 ++------ Calendar/SingelDayEventListDesign.py | 16 ++-------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/Calendar/EventListDesign.py b/Calendar/EventListDesign.py index b91f414..326866f 100644 --- a/Calendar/EventListDesign.py +++ b/Calendar/EventListDesign.py @@ -2,6 +2,7 @@ from DesignEntity import DesignEntity from TableTextDesign import TableTextDesign from settings import language from Assets import defaultfontsize +from TextFormatter import date_str class EventListDesign (DesignEntity): """Creates a TableTextDesign filled with event @@ -21,7 +22,7 @@ class EventListDesign (DesignEntity): self.highlight_color = highlight_color self.event_prefix_func = event_prefix_func if self.event_prefix_func is None: - self.event_prefix_func = lambda x : self.__remove_leading_zero__(x.begin_datetime.strftime('%d %b')) + self.event_prefix_func = lambda x : date_str(x.begin_datetime) def __finish_image__ (self): self.visible_event_count = int(int(self.size[1]) // (self.line_spacing + int(self.text_size))) @@ -34,11 +35,6 @@ class EventListDesign (DesignEntity): def __get_formatted_event__ (self, event): prefix = self.event_prefix_func(event) return [ prefix, event.title ] - - def __remove_leading_zero__ (self, text): - while text[0] is '0': - text = text[1:] - return text def __fill_event_matrix__ (self): visible_events = self.events diff --git a/Calendar/SingelDayEventListDesign.py b/Calendar/SingelDayEventListDesign.py index a5d0bb3..9a9ba8c 100644 --- a/Calendar/SingelDayEventListDesign.py +++ b/Calendar/SingelDayEventListDesign.py @@ -1,24 +1,12 @@ from EventListDesign import EventListDesign from settings import hours from Assets import fonts, defaultfontsize +from TextFormatter import event_time_summary -eventlist_allday_char = "•" font = fonts["regular"] class SingelDayEventListDesign (EventListDesign): """Specialized event list for day list design.""" def __init__ (self, size, events, font_size = defaultfontsize, line_spacing=2, col_spacing=5, general_color="black", background_color="white", highlight_color="red"): prefix_func = lambda x : self.__get_event_prefix__(x) - super().__init__(size, events, text_size=font_size, line_spacing=line_spacing, col_spacing=col_spacing, event_prefix_func=prefix_func, font_family=font, show_more_info=True, general_color=general_color, background_color=background_color, highlight_color = highlight_color) - - def __get_event_prefix__ (self, event): - if event.allday: - return eventlist_allday_char - else: - return self.__get_time__(event.begin_datetime) - - def __get_time__ (self, time): - if hours == "24": - return time.strftime('%H:%M') - else: - return time.strftime('%I:%M') \ No newline at end of file + super().__init__(size, events, text_size=font_size, line_spacing=line_spacing, col_spacing=col_spacing, event_prefix_func=event_time_summary, font_family=font, show_more_info=True, general_color=general_color, background_color=background_color, highlight_color = highlight_color) \ No newline at end of file