From 3356790549b6e8d595d80f9bd9d5862b42539b26 Mon Sep 17 00:00:00 2001 From: Ace Date: Mon, 16 Dec 2019 00:50:55 +0100 Subject: [PATCH 1/3] Added option to change string of all day events --- modules/inkycal_agenda.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/inkycal_agenda.py b/modules/inkycal_agenda.py index 6c7b938..40c2533 100644 --- a/modules/inkycal_agenda.py +++ b/modules/inkycal_agenda.py @@ -14,6 +14,7 @@ fontsize = 14 show_events = True print_events = False style = 'D MMM YY HH:mm' +all_day_str = 'All day' """Add a border to increase readability""" border_top = int(middle_section_height * 0.02) @@ -79,12 +80,12 @@ def main(): 'type':'timed_event'}) else: if events.duration.days == 1: - agenda_events.append({'date': events.begin,'time':'All day', + agenda_events.append({'date': events.begin,'time': all_day_str, 'name': events.name,'type':'full_day_event'}) else: for day in range(events.duration.days): agenda_events.append({'date': events.begin.replace(days=+day), - 'time':'All day','name':events.name, 'type':'full_day_event'}) + 'time': all_day_str,'name':events.name, 'type':'full_day_event'}) """Sort events and dates in chronological order""" agenda_events = sorted(agenda_events, key = lambda event: event['date']) From 4d67fab755e55e1c07863a5952cc3db118b1b9cb Mon Sep 17 00:00:00 2001 From: Ace Date: Mon, 16 Dec 2019 00:58:45 +0100 Subject: [PATCH 2/3] Localisation support + better events handling It's now possible to change the strings used in events (today, tomorrow, at) to a custom string (of your local language). The events section within the calendar module now only shows events from today which have not passed yet. If some lines are empty in the weather section, they'll be filled with events from the next 40 days. Also, some minor code improvements. --- modules/inkycal_calendar.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/modules/inkycal_calendar.py b/modules/inkycal_calendar.py index a2a2cbe..03e5978 100644 --- a/modules/inkycal_calendar.py +++ b/modules/inkycal_calendar.py @@ -13,12 +13,15 @@ from PIL import Image, ImageDraw print_events = False show_events = True -fontsize = 16 +today_in_your_language = 'today' +tomorrow_in_your_language = 'tomorrow' +at_in_your_language = 'at' event_icon = 'square' # dot #square style = "DD MMM" +fontsize = 16 font = ImageFont.truetype(NotoSans+'.ttf', fontsize) -space_between_lines = 1 +space_between_lines = 0 if show_events == True: from inkycal_icalendar import fetch_events @@ -156,15 +159,25 @@ def main(): """Add a small section showing events of today and tomorrow""" - event_list = ['{0} at {1} : {2}'.format('today', event.begin.format( - 'HH:mm' if hours == 24 else 'hh:mm'), event.name) - for event in calendar_events if event.begin.day == now.day] - - event_list += ['{0} at {1} : {2}'.format('tomorrow', event.begin.format( - 'HH:mm' if hours == 24 else 'hh:mm'), event.name) - for event in calendar_events if event.begin.day == now.replace(days=+1).day] + event_list = ['{0} {1} {2} : {3}'.format(today_in_your_language, + at_in_your_language, event.begin.format('HH:mm' if hours == 24 else + 'hh:mm'), event.name) for event in calendar_events if event.begin.day + == now.day and now < event.end] - del event_list[max_lines:] + + event_list += ['{0} {1} {2} : {3}'.format(tomorrow_in_your_language, + at_in_your_language, event.begin.format('HH:mm' if hours == 24 else + 'hh:mm'), event.name) for event in calendar_events if event.begin.day + == now.replace(day=1).day] + + after_two_days = now.replace(days=2).floor('day') + + event_list += ['{0} {1} {2} : {3}'.format(event.begin.format('D MMM'), + at_in_your_language, event.begin.format('HH:mm' if hours == 24 else + 'hh:mm'), event.name) for event in upcoming_events if event.end > + after_two_days] + + del event_list[max_event_lines:] if event_list: for lines in event_list: @@ -173,7 +186,7 @@ def main(): fill_height = 0.7) else: write_text(main_area_width, int(events_height/max_event_lines), - 'No events today or tomorrow', event_lines[0], alignment='left', + 'No upcoming events', event_lines[0], alignment='left', fill_height = 0.7) """Set print_events_to True to print all events in this month""" From a36375df1ef40e4ee4322511a37b581ede9db984 Mon Sep 17 00:00:00 2001 From: Ace Date: Mon, 16 Dec 2019 01:00:45 +0100 Subject: [PATCH 3/3] Added option to change 'now' string --- modules/inkycal_weather.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/inkycal_weather.py b/modules/inkycal_weather.py index a2b6489..4fb3ff8 100644 --- a/modules/inkycal_weather.py +++ b/modules/inkycal_weather.py @@ -24,6 +24,7 @@ round_windspeed = True use_beaufort = True show_wind_direction = False use_wind_direction_icon = False +now_str = 'now' """Set the optional parameters""" @@ -243,7 +244,7 @@ def main(): moonphase = get_moon_phase() """Add weather details in column 1""" - write_text(coloumn_width, row_height, 'now', text_now_pos, font = font) + write_text(coloumn_width, row_height, now_str, text_now_pos, font = font) write_text(icon_medium, icon_medium, weathericons[weather_icon_now], weather_icon_now_pos, font = w_font, fill_width = 0.9)