diff --git a/inkycal/custom/functions.py b/inkycal/custom/functions.py index 47fd682..debe21e 100644 --- a/inkycal/custom/functions.py +++ b/inkycal/custom/functions.py @@ -99,12 +99,12 @@ def auto_fontsize(font, max_height): A PIL font object with modified height. """ text_bbox = font.getbbox("hg") - text_height = text_bbox[3] - text_bbox[1] + text_height = text_bbox[3] fontsize = text_height while text_height <= (max_height * 0.80): fontsize += 1 font = ImageFont.truetype(font.path, fontsize) - text_height = text_bbox[3] - text_bbox[1] + text_height = text_bbox[3] return font diff --git a/inkycal/modules/inkycal_agenda.py b/inkycal/modules/inkycal_agenda.py index b5adbd2..e1ccba5 100755 --- a/inkycal/modules/inkycal_agenda.py +++ b/inkycal/modules/inkycal_agenda.py @@ -1,5 +1,3 @@ -#!python3 - """ Inkycal Agenda Module Copyright by aceinnolab @@ -100,7 +98,7 @@ class Agenda(inkycal_module): line_spacing = 1 text_bbox_height = self.font.getbbox("hg") - line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing + line_height = text_bbox_height[3] + line_spacing line_width = im_width max_lines = im_height // line_height logger.debug(f'max lines: {max_lines}') @@ -111,9 +109,11 @@ class Agenda(inkycal_module): # Create a list of dates for the next days agenda_events = [ - {'begin': today.shift(days=+_), - 'title': today.shift(days=+_).format( - self.date_format, locale=self.language)} + { + 'begin': today.shift(days=+_), + 'title': today.shift(days=+_).format( + self.date_format, locale=self.language) + } for _ in range(max_lines)] # Load icalendar from config @@ -137,7 +137,7 @@ class Agenda(inkycal_module): # Set the width for date, time and event titles date_width = int(max([self.font.getlength( dates['begin'].format(self.date_format, locale=self.language)) - for dates in agenda_events]) * 1.2) + for dates in agenda_events]) * 1.2) logger.debug(f'date_width: {date_width}') # Calculate positions for each line @@ -152,7 +152,7 @@ class Agenda(inkycal_module): time_width = int(max([self.font.getlength( events['begin'].format(self.time_format, locale=self.language)) - for events in upcoming_events]) * 1.2) + for events in upcoming_events]) * 1.2) logger.debug(f'time_width: {time_width}') # Calculate x-pos for time @@ -227,7 +227,3 @@ class Agenda(inkycal_module): # return the images ready for the display return im_black, im_colour - - -if __name__ == '__main__': - print(f'running {__name__} in standalone mode') diff --git a/inkycal/modules/inkycal_calendar.py b/inkycal/modules/inkycal_calendar.py index a6d3154..9c85984 100755 --- a/inkycal/modules/inkycal_calendar.py +++ b/inkycal/modules/inkycal_calendar.py @@ -1,5 +1,3 @@ -#!python3 - """ Inkycal Calendar Module Copyright by aceinnolab @@ -267,7 +265,7 @@ class Calendar(inkycal_module): # find out how many lines can fit at max in the event section line_spacing = 2 text_bbox_height = self.font.getbbox("hg") - line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing + line_height = text_bbox_height[3] + line_spacing max_event_lines = events_height // (line_height + line_spacing) # generate list of coordinates for each line @@ -356,7 +354,7 @@ class Calendar(inkycal_module): ) text_bbox_height = self.font.getbbox("hg") - line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing + line_height = text_bbox_height[3] + line_spacing event_width_s = im_width - date_width - time_width event_width_l = im_width - date_width @@ -433,7 +431,3 @@ class Calendar(inkycal_module): # return the images ready for the display return im_black, im_colour - - -if __name__ == '__main__': - print(f'running {__name__} in standalone mode') diff --git a/inkycal/modules/inkycal_feeds.py b/inkycal/modules/inkycal_feeds.py index e354b89..d7bdde3 100644 --- a/inkycal/modules/inkycal_feeds.py +++ b/inkycal/modules/inkycal_feeds.py @@ -1,5 +1,3 @@ -#!python3 - """ Feeds module for InkyCal Project Copyright by aceinnolab @@ -94,7 +92,7 @@ class Feeds(inkycal_module): line_width = im_width text_bbox_height = self.font.getbbox("hg") - line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing + line_height = text_bbox_height[3] + line_spacing max_lines = (im_height // (line_height + line_spacing)) # Calculate padding from top so the lines look centralised @@ -151,7 +149,3 @@ class Feeds(inkycal_module): # return images return im_black, im_colour - - -if __name__ == '__main__': - print(f'running {__name__} in standalone/debug mode') diff --git a/inkycal/modules/inkycal_jokes.py b/inkycal/modules/inkycal_jokes.py index deb4a41..5f0085e 100755 --- a/inkycal/modules/inkycal_jokes.py +++ b/inkycal/modules/inkycal_jokes.py @@ -1,5 +1,3 @@ -#!python3 - """ iCanHazDadJoke module for InkyCal Project Special thanks to Erik Fredericks (@efredericks) for the template! @@ -56,7 +54,7 @@ class Jokes(inkycal_module): # Set some parameters for formatting feeds line_spacing = 5 text_bbox = self.font.getbbox("hg") - line_height = text_bbox[3] - text_bbox[1] + line_spacing + line_height = text_bbox[3] + line_spacing line_width = im_width max_lines = (im_height // (line_height + line_spacing)) @@ -98,7 +96,3 @@ class Jokes(inkycal_module): # Return images for black and colour channels return im_black, im_colour - - -if __name__ == '__main__': - print(f'running {__name__} in standalone/debug mode') diff --git a/inkycal/modules/inkycal_textfile_to_display.py b/inkycal/modules/inkycal_textfile_to_display.py index cd522d9..0680cdf 100644 --- a/inkycal/modules/inkycal_textfile_to_display.py +++ b/inkycal/modules/inkycal_textfile_to_display.py @@ -1,4 +1,3 @@ -#!python3 """ Textfile module for InkyCal Project @@ -68,7 +67,7 @@ class TextToDisplay(inkycal_module): # Set some parameters for formatting feeds line_spacing = 4 text_bbox_height = self.font.getbbox("hg") - line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing + line_height = text_bbox_height[3] + line_spacing line_width = im_width max_lines = im_height // line_height @@ -110,7 +109,3 @@ class TextToDisplay(inkycal_module): # return images return im_black, im_colour - - -if __name__ == '__main__': - print(f'running {__name__} in standalone/debug mode') diff --git a/inkycal/modules/inkycal_todoist.py b/inkycal/modules/inkycal_todoist.py index f290253..55e725e 100644 --- a/inkycal/modules/inkycal_todoist.py +++ b/inkycal/modules/inkycal_todoist.py @@ -1,5 +1,3 @@ -#!python3 - """ Inkycal Todoist Module Copyright by aceinnolab @@ -87,7 +85,7 @@ class Todoist(inkycal_module): # Set some parameters for formatting todos line_spacing = 1 text_bbox_height = self.font.getbbox("hg") - line_height = text_bbox_height[3] - text_bbox_height[1] + line_spacing + line_height = text_bbox_height[3] + line_spacing line_width = im_width max_lines = im_height // line_height @@ -198,7 +196,3 @@ class Todoist(inkycal_module): # return the images ready for the display return im_black, im_colour - - -if __name__ == '__main__': - print(f'running {__name__} in standalone/debug mode')