From 47207740112f1bea7cdfda49100483bce1090d42 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 8 Apr 2019 11:20:33 +0200 Subject: [PATCH] Added some optional technical data to print --- Calendar/AgendaListPanel.py | 2 +- Calendar/DayListPanel.py | 2 +- Calendar/DayViewPanel.py | 2 +- Calendar/PanelDesign.py | 17 +++++++++++++- Calendar/TechnicalDataDesign.py | 40 +++++++++++++++++++++++++++++++++ Calendar/settings.py.sample | 3 ++- 6 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 Calendar/TechnicalDataDesign.py diff --git a/Calendar/AgendaListPanel.py b/Calendar/AgendaListPanel.py index 7ed8c34..0cc618d 100644 --- a/Calendar/AgendaListPanel.py +++ b/Calendar/AgendaListPanel.py @@ -43,7 +43,7 @@ class AgendaListPanel (PanelDesign): def add_taks (self, tasks): pass - def __finish_image__(self): + def __finish_panel__(self): self.__draw_calendar__() if general_settings["weather-info"]: self.__draw_weather__() diff --git a/Calendar/DayListPanel.py b/Calendar/DayListPanel.py index 0b2ffae..d517da9 100644 --- a/Calendar/DayListPanel.py +++ b/Calendar/DayListPanel.py @@ -101,7 +101,7 @@ class DayListPanel (PanelDesign): line_end = (self.size[0], ypos) ImageDraw.Draw(self.__image__).line([line_start, line_end], fill=colors["fg"], width=lines_thickness) - def __finish_image__(self): + def __finish_panel__(self): for design in self.__day_rows__: self.draw_design(design) self.__draw_lines__() diff --git a/Calendar/DayViewPanel.py b/Calendar/DayViewPanel.py index b746686..61f09e1 100644 --- a/Calendar/DayViewPanel.py +++ b/Calendar/DayViewPanel.py @@ -30,7 +30,7 @@ class DayViewPanel (PanelDesign): def add_taks (self, tasks): pass - def __finish_image__ (self): + def __finish_panel__ (self): self.draw_design(self.__header__) self.draw_design(self.__hourlist__) diff --git a/Calendar/PanelDesign.py b/Calendar/PanelDesign.py index c8b46b0..53e65dc 100644 --- a/Calendar/PanelDesign.py +++ b/Calendar/PanelDesign.py @@ -1,9 +1,13 @@ from DesignEntity import DesignEntity +from TechnicalDataDesign import TechnicalDataDesign +from settings import print_technical_data +from datetime import datetime class PanelDesign (DesignEntity): """Defined general interface for panel designs.""" def __init__ (self, size): super(PanelDesign, self).__init__(size) + self.start_timestamp = datetime.now() def add_weather (self, weather): raise NotImplementedError("Functions needs to be implemented") @@ -15,4 +19,15 @@ class PanelDesign (DesignEntity): raise NotImplementedError("Functions needs to be implemented") def add_taks (self, tasks): - raise NotImplementedError("Functions needs to be implemented") \ No newline at end of file + raise NotImplementedError("Functions needs to be implemented") + + def __finish_panel__(self): + pass + + def __finish_image__(self): + self.__finish_panel__() + + if print_technical_data: + td = TechnicalDataDesign(self.size, self.start_timestamp, datetime.now()) + td.mask = True + self.draw_design(td) \ No newline at end of file diff --git a/Calendar/TechnicalDataDesign.py b/Calendar/TechnicalDataDesign.py new file mode 100644 index 0000000..4c3b7cf --- /dev/null +++ b/Calendar/TechnicalDataDesign.py @@ -0,0 +1,40 @@ +from DesignEntity import DesignEntity +from TextDesign import TextDesign +from Assets import colors + +font_size = 20 + +class TechnicalDataDesign(DesignEntity): + '''Prints data about the current loop ontop of the panel''' + def __init__(self, size, start, stop): + super(TechnicalDataDesign, self).__init__(size, mask = True) + self.start = start + self.stop = stop + + def __finish_image__(self): + data = self.__get_data__() + + txt = TextDesign(self.size, text=data, fontsize=font_size) + txt.color = colors["fg"] + txt.pos = (0, 0) + self.draw_design(txt) + + txt = TextDesign(self.size, text=data, fontsize=font_size) + txt.color = colors["hl"] + txt.pos = (1, 1) + self.draw_design(txt) + + txt = TextDesign(self.size, text=data, fontsize=font_size) + txt.color = colors["fg"] + txt.pos = (2, 2) + self.draw_design(txt) + + def __get_data__(self): + data = "START: " + data += str(self.start) + data += "\nDURATION BEFOR RENDER: " + dur = self.stop - self.start + data += str(dur) + data += "\nSTOP: " + data += str(self.stop) + return data \ No newline at end of file diff --git a/Calendar/settings.py.sample b/Calendar/settings.py.sample index df3a142..8573312 100644 --- a/Calendar/settings.py.sample +++ b/Calendar/settings.py.sample @@ -35,4 +35,5 @@ general_settings = { # General settings that designs may use """DEBUG""" render_to_display = True render_to_file = False # Will be called "design_exported.png" in Calendar-directory -calibrate_hours = [0, 12, 18] \ No newline at end of file +calibrate_hours = [0, 12, 18] +print_technical_data = False \ No newline at end of file