Added global color settings

This commit is contained in:
Maximilian Giller 2019-04-05 11:37:51 +02:00
parent c93210356a
commit 6a37255b57
14 changed files with 43 additions and 49 deletions

View file

@ -1,11 +1,10 @@
from DesignEntity import DesignEntity from DesignEntity import DesignEntity
from Assets import defaultfontsize from Assets import defaultfontsize, colors
from datetime import datetime, date, timedelta from datetime import datetime, date, timedelta
from TableTextDesign import TableTextDesign from TableTextDesign import TableTextDesign
from PIL import ImageDraw from PIL import ImageDraw
from TextFormatter import date_summary_str, event_time_detailed from TextFormatter import date_summary_str, event_time_detailed
line_color = "black"
line_width = 1 line_width = 1
class AgendaListDesign (DesignEntity): class AgendaListDesign (DesignEntity):
@ -65,4 +64,4 @@ class AgendaListDesign (DesignEntity):
pos = (0, ypos) pos = (0, ypos)
positions = [ pos, (self.size[0], ypos) ] positions = [ pos, (self.size[0], ypos) ]
ImageDraw.Draw(self.__image__).line(positions, fill=line_color, width=line_width) ImageDraw.Draw(self.__image__).line(positions, fill=colors["fg"], width=line_width)

View file

@ -42,4 +42,10 @@ weathericons = {
'03n': 'wi-night-cloudy', '04n': 'wi-night-cloudy', '03n': 'wi-night-cloudy', '04n': 'wi-night-cloudy',
'09n': 'wi-night-showers', '10n':'wi-night-rain', '09n': 'wi-night-showers', '10n':'wi-night-rain',
'11n':'wi-night-thunderstorm', '13n':'wi-night-snow', '11n':'wi-night-thunderstorm', '13n':'wi-night-snow',
'50n': 'wi-night-alt-cloudy-windy'} '50n': 'wi-night-alt-cloudy-windy'}
colors = {
"hl" : "red",
"fg" : "black",
"bg" : "white"
}

View file

@ -4,7 +4,7 @@ from TextDesign import TextDesign
from WeatherColumnDesign import WeatherColumnDesign from WeatherColumnDesign import WeatherColumnDesign
from datetime import date, timedelta, datetime from datetime import date, timedelta, datetime
from SingelDayEventListDesign import SingelDayEventListDesign from SingelDayEventListDesign import SingelDayEventListDesign
from Assets import fonts from Assets import fonts, colors
numberbox_ypos = 0.15 numberbox_ypos = 0.15
numberbox_height = 1 - 2 * numberbox_ypos numberbox_height = 1 - 2 * numberbox_ypos
@ -18,18 +18,15 @@ weathercolumn_y_size = (0.4, 1)
eventlist_y_fontsize = 0.093 eventlist_y_fontsize = 0.093
eventlist_padding = monthbox_xpadding eventlist_padding = monthbox_xpadding
numberbox_font_color = "white" numberbox_font_color = colors["bg"]
numberbox_background_color = "red" numberbox_background_color = colors["hl"]
general_text_color = "black"
background_color = "white"
highlight_color = "red"
weekday_font = fonts["bold"] weekday_font = fonts["bold"]
class DayHeaderDesign (DesignEntity): class DayHeaderDesign (DesignEntity):
"""Detailed and big view of a given date.""" """Detailed and big view of a given date."""
def __init__ (self, size, date): def __init__ (self, size, date):
super(DayHeaderDesign, self).__init__(size) super(DayHeaderDesign, self).__init__(size)
self.__init_image__(color=background_color) self.__init_image__()
self.date = date self.date = date
def add_weather (self, weather): def add_weather (self, weather):
@ -68,7 +65,7 @@ class DayHeaderDesign (DesignEntity):
size = (self.size[0] - pos[0] - weather_width, self.size[1] - pos[1] - box_ypos) size = (self.size[0] - pos[0] - weather_width, self.size[1] - pos[1] - box_ypos)
fontsize = eventlist_y_fontsize * self.size[1] fontsize = eventlist_y_fontsize * self.size[1]
event_list = SingelDayEventListDesign(size, events, fontsize, general_color=general_text_color, background_color=background_color, highlight_color=highlight_color) event_list = SingelDayEventListDesign(size, events, fontsize)
event_list.pos = pos event_list.pos = pos
self.draw_design(event_list) self.draw_design(event_list)
@ -95,7 +92,7 @@ class DayHeaderDesign (DesignEntity):
box_size = (int(monthbox_width * self.size[0]), box_height) box_size = (int(monthbox_width * self.size[0]), box_height)
month_name = self.date.strftime("%B") month_name = self.date.strftime("%B")
month = TextDesign(box_size, text=month_name, fontsize=font_size, color=general_text_color, background_color=background_color) month = TextDesign(box_size, text=month_name, fontsize=font_size)
month.pos = box_pos month.pos = box_pos
self.draw_design(month) self.draw_design(month)

View file

@ -11,7 +11,6 @@ from RssPostListDesign import RssPostListDesign
todayheader_pos = (0,0) todayheader_pos = (0,0)
todayheader_size = (1,0.25) todayheader_size = (1,0.25)
line_color = "black"
lines_thickness = 1 lines_thickness = 1
infoarea_replacedrowscount = 3 infoarea_replacedrowscount = 3
@ -100,7 +99,7 @@ class DayListPanel (PanelDesign):
for ypos in positions: for ypos in positions:
line_start = (0, ypos) line_start = (0, ypos)
line_end = (self.size[0], ypos) line_end = (self.size[0], ypos)
ImageDraw.Draw(self.__image__).line([line_start, line_end], fill=line_color, width=lines_thickness) ImageDraw.Draw(self.__image__).line([line_start, line_end], fill=colors["fg"], width=lines_thickness)
def __finish_image__(self): def __finish_image__(self):
for design in self.__day_rows__: for design in self.__day_rows__:

View file

@ -3,7 +3,7 @@ from TextDesign import TextDesign
from settings import week_starts_on, owm_paid_subscription from settings import week_starts_on, owm_paid_subscription
from DesignEntity import DesignEntity from DesignEntity import DesignEntity
from datetime import datetime from datetime import datetime
from Assets import weathericons, wpath, fonts from Assets import weathericons, wpath, fonts, colors
from SingelDayEventListDesign import SingelDayEventListDesign from SingelDayEventListDesign import SingelDayEventListDesign
daynumber_y_size = (1, 0.65) daynumber_y_size = (1, 0.65)
@ -17,16 +17,13 @@ eventlist_xpadding = 5
eventlist_ypos = 0.1 eventlist_ypos = 0.1
eventlist_y_fontsize = 0.2 eventlist_y_fontsize = 0.2
general_text_color = "black"
highlight_text_color = "red"
background_color = "white"
font = fonts["regular"] font = fonts["regular"]
class DayRowDesign (DesignEntity): class DayRowDesign (DesignEntity):
"""Detailed view of a given date.""" """Detailed view of a given date."""
def __init__ (self, size, date): def __init__ (self, size, date):
super(DayRowDesign, self).__init__(size) super(DayRowDesign, self).__init__(size)
self.__init_image__(color=background_color) self.__init_image__()
self.date = date self.date = date
def add_weather (self, weather): def add_weather (self, weather):
@ -51,7 +48,7 @@ class DayRowDesign (DesignEntity):
fontsize = eventlist_y_fontsize * self.size[1] fontsize = eventlist_y_fontsize * self.size[1]
events = calendar.get_day_events(self.date) events = calendar.get_day_events(self.date)
event_list = SingelDayEventListDesign(size, events, fontsize, line_spacing=0, general_color=general_text_color, background_color=background_color, highlight_color=highlight_text_color) event_list = SingelDayEventListDesign(size, events, fontsize, line_spacing=0)
event_list.pos = pos event_list.pos = pos
self.draw_design(event_list) self.draw_design(event_list)
@ -82,7 +79,7 @@ class DayRowDesign (DesignEntity):
color = self.__get_day_color__() color = self.__get_day_color__()
week_day_name = self.date.strftime("%a") week_day_name = self.date.strftime("%a")
week_day = TextDesign(size, text=week_day_name, font=font, background_color=background_color, color=color, fontsize=font_size, horizontalalignment="center", verticalalignment="top") week_day = TextDesign(size, text=week_day_name, font=font, color=color, fontsize=font_size, horizontalalignment="center", verticalalignment="top")
week_day.pos = pos week_day.pos = pos
self.draw_design(week_day) self.draw_design(week_day)
@ -94,7 +91,7 @@ class DayRowDesign (DesignEntity):
day_text = self.__get_day_text__() day_text = self.__get_day_text__()
color = self.__get_day_color__() color = self.__get_day_color__()
number = TextDesign(size, text=day_text, font=font, background_color=background_color, color=color, fontsize=font_size, horizontalalignment="center", verticalalignment="bottom") number = TextDesign(size, text=day_text, font=font, color=color, fontsize=font_size, horizontalalignment="center", verticalalignment="bottom")
number.pos = pos number.pos = pos
self.draw_design(number) self.draw_design(number)
@ -107,8 +104,8 @@ class DayRowDesign (DesignEntity):
def __get_day_color__ (self): def __get_day_color__ (self):
"""Depending on week_starts_on""" """Depending on week_starts_on"""
if week_starts_on == "Monday" and self.date.strftime("%w") == "0": if week_starts_on == "Monday" and self.date.strftime("%w") == "0":
return highlight_text_color return colors["hl"]
elif week_starts_on == "Sunday" and self.date.strftime("%w") == "6": elif week_starts_on == "Sunday" and self.date.strftime("%w") == "6":
return highlight_text_color return colors["hl"]
else: else:
return general_text_color return colors["fg"]

View file

@ -1,4 +1,5 @@
from PIL import Image, ImageOps, ImageDraw from PIL import Image, ImageOps, ImageDraw
from Assets import colors
masking_threshold = 100 masking_threshold = 100
@ -14,7 +15,7 @@ class DesignEntity (object):
self.__finished_image__ = False self.__finished_image__ = False
self.color_key = color_key self.color_key = color_key
def __init_image__ (self, color = 'white'): def __init_image__ (self, color = colors["bg"]):
rounded_size = (int(self.size[0]),int(self.size[1])) rounded_size = (int(self.size[0]),int(self.size[1]))
self.__image__ = Image.new('RGB', rounded_size, color=color) self.__image__ = Image.new('RGB', rounded_size, color=color)

View file

@ -1,13 +1,13 @@
from DesignEntity import DesignEntity from DesignEntity import DesignEntity
from TableTextDesign import TableTextDesign from TableTextDesign import TableTextDesign
from settings import language from settings import language
from Assets import defaultfontsize from Assets import defaultfontsize, colors
from TextFormatter import date_str from TextFormatter import date_str
class EventListDesign (DesignEntity): class EventListDesign (DesignEntity):
"""Creates a TableTextDesign filled with event """Creates a TableTextDesign filled with event
begin date and title""" begin date and title"""
def __init__ (self, size, events, text_size = defaultfontsize, line_spacing = 2, col_spacing = 10, event_prefix_func = None, font_family = None, general_color = "black", background_color = "white", highlight_color = "red", show_more_info = False): def __init__ (self, size, events, text_size = defaultfontsize, line_spacing = 2, col_spacing = 10, event_prefix_func = None, font_family = None, general_color = colors["fg"], background_color = colors["bg"], highlight_color = colors["hl"], show_more_info = False):
super(EventListDesign, self).__init__(size) super(EventListDesign, self).__init__(size)
self.events = events self.events = events
self.__event_matrix__ = [] self.__event_matrix__ = []

View file

@ -2,6 +2,7 @@ from DesignEntity import DesignEntity
from settings import hours, language from settings import hours, language
from TextDesign import TextDesign from TextDesign import TextDesign
from PIL import ImageDraw from PIL import ImageDraw
from Assets import colors
hourbox_y_width = 1 hourbox_y_width = 1
hour_box_fontsize = 0.75 hour_box_fontsize = 0.75
@ -12,13 +13,10 @@ line_thickness = 1
class HourListDesign (DesignEntity): class HourListDesign (DesignEntity):
"""Hours of a day are listed vertically and """Hours of a day are listed vertically and
resemble a timeline.""" resemble a timeline."""
def __init__ (self, size, first_hour = 0, last_hour = 23, background_color="white", general_color="black", highlight_color="red"): def __init__ (self, size, first_hour = 0, last_hour = 23):
super(HourListDesign, self).__init__(size) super(HourListDesign, self).__init__(size)
self.first_hour = first_hour self.first_hour = first_hour
self.last_hour = last_hour self.last_hour = last_hour
self.bg_color = background_color
self.color = general_color
self.highlight_color = highlight_color
self.__calc_metrics__() self.__calc_metrics__()
def add_events (self, events): def add_events (self, events):
@ -72,7 +70,7 @@ class HourListDesign (DesignEntity):
ypos = i * self.__row_size__[1] ypos = i * self.__row_size__[1]
line_start = (0, ypos) line_start = (0, ypos)
line_end = (self.size[0], ypos) line_end = (self.size[0], ypos)
ImageDraw.Draw(self.__image__).line([line_start, line_end], fill=self.color, width=line_thickness) ImageDraw.Draw(self.__image__).line([line_start, line_end], fill=colors["fg"], width=line_thickness)
def __get_hour_sub_text__(self, hour): def __get_hour_sub_text__(self, hour):
if language is "de": if language is "de":

View file

@ -34,7 +34,7 @@ class MonthBlockDesign (DesignEntity):
if self.highlight_today: if self.highlight_today:
self.__draw_highlight_box__(self.__abs_pos__(dayhighlightboxsize), self.__get_today_box_pos__(), width=3) self.__draw_highlight_box__(self.__abs_pos__(dayhighlightboxsize), self.__get_today_box_pos__(), width=3)
def __draw_highlight_box__ (self, size, pos, color='black', width=1): def __draw_highlight_box__ (self, size, pos, color=colors["fg"], width=1):
design = BoxDesign(size, outline=color, width = width) design = BoxDesign(size, outline=color, width = width)
design.pos = pos design.pos = pos
self.draw_design(design) self.draw_design(design)

View file

@ -126,12 +126,12 @@ class MonthOvPanel (PanelDesign):
posx, posy = self.__abs_pos__(weekdayrowpos) posx, posy = self.__abs_pos__(weekdayrowpos)
return (int(posx + day_of_week * partialwidth), int(posy)) return (int(posx + day_of_week * partialwidth), int(posy))
def __draw_highlight_box__ (self, size, pos, color = 'black', width = 1): def __draw_highlight_box__ (self, size, pos, color = colors["fg"], width = 1):
design = BoxDesign(size, outline=color, width = width) design = BoxDesign(size, outline=color, width = width)
design.pos = pos design.pos = pos
self.draw_design(design) self.draw_design(design)
def __draw_highlight_circle__ (self, size, pos, color = 'black', width = 1): def __draw_highlight_circle__ (self, size, pos, color = colors["fg"], width = 1):
design = EllipseDesign(size, outline=color, width = width) design = EllipseDesign(size, outline=color, width = width)
design.pos = pos design.pos = pos
self.draw_design(design) self.draw_design(design)

View file

@ -1,12 +1,12 @@
from EventListDesign import EventListDesign from EventListDesign import EventListDesign
from settings import hours from settings import hours
from Assets import fonts, defaultfontsize from Assets import fonts, defaultfontsize, colors
from TextFormatter import event_time_summary from TextFormatter import event_time_summary
font = fonts["regular"] font = fonts["regular"]
class SingelDayEventListDesign (EventListDesign): class SingelDayEventListDesign (EventListDesign):
"""Specialized event list for day list design.""" """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"): def __init__ (self, size, events, font_size = defaultfontsize, line_spacing=2, col_spacing=5, general_color=colors["fg"], background_color=colors["bg"], highlight_color=colors["hl"]):
prefix_func = lambda x : self.__get_event_prefix__(x) 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=event_time_summary, font_family=font, show_more_info=True, general_color=general_color, background_color=background_color, highlight_color = highlight_color) 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)

View file

@ -1,17 +1,17 @@
from TextDesign import TextDesign from TextDesign import TextDesign
from TextWraper import wrap_text_with_font from TextWraper import wrap_text_with_font
from Assets import defaultfontsize from Assets import defaultfontsize, colors
default_props = { default_props = {
"color" : "black", "color" : colors["fg"],
"background_color" : "white" "background_color" : colors["bg"]
} }
class TableTextDesign (TextDesign): class TableTextDesign (TextDesign):
"""Gets a matrix with text that is than """Gets a matrix with text that is than
displayed in a table without borders.""" displayed in a table without borders."""
def __init__ (self, size, text_matrix, max_col_size = None, max_row_size = None, font = None, fontsize = defaultfontsize, column_horizontal_alignments = [], mask = True, line_spacing = 0, col_spacing = 0, truncate_rows = True, truncate_cols = True, wrap = False, truncate_text=True, truncate_suffix="...", cell_properties=None, background_color = "white"): def __init__ (self, size, text_matrix, max_col_size = None, max_row_size = None, font = None, fontsize = defaultfontsize, column_horizontal_alignments = [], mask = True, line_spacing = 0, col_spacing = 0, truncate_rows = True, truncate_cols = True, wrap = False, truncate_text=True, truncate_suffix="...", cell_properties=None, background_color = colors["bg"]):
super(TableTextDesign, self).__init__(size, font=font, fontsize=fontsize, mask=mask) super(TableTextDesign, self).__init__(size, font=font, fontsize=fontsize, mask=mask)
self.__init_image__(background_color) self.__init_image__(background_color)
self.matrix = text_matrix self.matrix = text_matrix

View file

@ -1,6 +1,6 @@
from DesignEntity import DesignEntity from DesignEntity import DesignEntity
from PIL import ImageFont, ImageDraw, ImageOps from PIL import ImageFont, ImageDraw, ImageOps
from Assets import path, defaultfont from Assets import path, defaultfont, colors
from TextWraper import wrap_text_with_font from TextWraper import wrap_text_with_font
paddingcorrection = -3 paddingcorrection = -3
@ -9,7 +9,7 @@ truncateerror_fontsize = 0.5
class TextDesign (DesignEntity): class TextDesign (DesignEntity):
"""Object that manages all information relevant to text """Object that manages all information relevant to text
and prints it to an image""" and prints it to an image"""
def __init__ (self, size, color="black", background_color="white", font = None, fontsize = 12, text = "", horizontalalignment = "left", verticalalignment = "top", mask=True, truncate=False, truncate_suffix = '...', wrap=False): def __init__ (self, size, color=colors["fg"], background_color=colors["bg"], font = None, fontsize = 12, text = "", horizontalalignment = "left", verticalalignment = "top", mask=True, truncate=False, truncate_suffix = '...', wrap=False):
super(TextDesign, self).__init__(size, mask = mask) super(TextDesign, self).__init__(size, mask = mask)
if font is None: if font is None:
font = defaultfont font = defaultfont

View file

@ -1,7 +1,7 @@
from DesignEntity import DesignEntity from DesignEntity import DesignEntity
from TextDesign import TextDesign from TextDesign import TextDesign
from TableTextDesign import TableTextDesign from TableTextDesign import TableTextDesign
from Assets import wpath, weathericons, tempicon, humicon, windicon, no_response from Assets import wpath, weathericons, tempicon, humicon, windicon, no_response, colors
from PIL import Image from PIL import Image
from settings import hours from settings import hours
@ -15,9 +15,6 @@ numbers_x_ypos = icon_x_ypos + icon_width + info_x_height + 0.2
numbers_x_ypadding = 0.05 numbers_x_ypadding = 0.05
max_symbol_y_width = 0.15 max_symbol_y_width = 0.15
general_text_color = "black"
background_color = "white"
class WeatherColumnDesign (DesignEntity): class WeatherColumnDesign (DesignEntity):
"""Displays weather information in a column""" """Displays weather information in a column"""
def __init__ (self, size, forecast): def __init__ (self, size, forecast):