Added some optional technical data to print

This commit is contained in:
Maximilian Giller 2019-04-08 11:20:33 +02:00
parent a7605e3473
commit 4720774011
6 changed files with 61 additions and 5 deletions

View file

@ -43,7 +43,7 @@ class AgendaListPanel (PanelDesign):
def add_taks (self, tasks): def add_taks (self, tasks):
pass pass
def __finish_image__(self): def __finish_panel__(self):
self.__draw_calendar__() self.__draw_calendar__()
if general_settings["weather-info"]: if general_settings["weather-info"]:
self.__draw_weather__() self.__draw_weather__()

View file

@ -101,7 +101,7 @@ class DayListPanel (PanelDesign):
line_end = (self.size[0], ypos) line_end = (self.size[0], ypos)
ImageDraw.Draw(self.__image__).line([line_start, line_end], fill=colors["fg"], width=lines_thickness) 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__: for design in self.__day_rows__:
self.draw_design(design) self.draw_design(design)
self.__draw_lines__() self.__draw_lines__()

View file

@ -30,7 +30,7 @@ class DayViewPanel (PanelDesign):
def add_taks (self, tasks): def add_taks (self, tasks):
pass pass
def __finish_image__ (self): def __finish_panel__ (self):
self.draw_design(self.__header__) self.draw_design(self.__header__)
self.draw_design(self.__hourlist__) self.draw_design(self.__hourlist__)

View file

@ -1,9 +1,13 @@
from DesignEntity import DesignEntity from DesignEntity import DesignEntity
from TechnicalDataDesign import TechnicalDataDesign
from settings import print_technical_data
from datetime import datetime
class PanelDesign (DesignEntity): class PanelDesign (DesignEntity):
"""Defined general interface for panel designs.""" """Defined general interface for panel designs."""
def __init__ (self, size): def __init__ (self, size):
super(PanelDesign, self).__init__(size) super(PanelDesign, self).__init__(size)
self.start_timestamp = datetime.now()
def add_weather (self, weather): def add_weather (self, weather):
raise NotImplementedError("Functions needs to be implemented") raise NotImplementedError("Functions needs to be implemented")
@ -16,3 +20,14 @@ class PanelDesign (DesignEntity):
def add_taks (self, tasks): def add_taks (self, tasks):
raise NotImplementedError("Functions needs to be implemented") 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)

View file

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

View file

@ -36,3 +36,4 @@ general_settings = { # General settings that designs may use
render_to_display = True render_to_display = True
render_to_file = False # Will be called "design_exported.png" in Calendar-directory render_to_file = False # Will be called "design_exported.png" in Calendar-directory
calibrate_hours = [0, 12, 18] calibrate_hours = [0, 12, 18]
print_technical_data = False