Partially integrated TextFormatter

This commit is contained in:
Maximilian Giller 2019-03-26 22:31:05 +01:00
parent 59d2401f81
commit b01969d2da
2 changed files with 4 additions and 20 deletions

View file

@ -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

View file

@ -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')
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)