Added highlight box around current day.
This commit is contained in:
parent
e19bfa0b0b
commit
60b94c6783
1 changed files with 30 additions and 21 deletions
|
@ -6,15 +6,18 @@ from datetime import datetime, timedelta
|
|||
from WeatherHeaderDesign import WeatherHeaderDesign
|
||||
from PIL import ImageDraw
|
||||
from TextDesign import TextDesign
|
||||
from BoxDesign import BoxDesign
|
||||
from EllipseDesign import EllipseDesign
|
||||
|
||||
weatherheadersize = (1,0.113)
|
||||
seperatorplace = (0, 0.113)
|
||||
monthplace = (0, 0.11)
|
||||
monthplace = (0, 0.12)
|
||||
monthboxsize = (1, 0.085)
|
||||
daynumberboxsize = (0.143, 0.143)
|
||||
dayhighlightboxsize = (0.143, 0.07)
|
||||
daynumbersize = 25
|
||||
monthtextsize = 40
|
||||
monthovposition = (0, 0.225)
|
||||
monthovposition = (0, 0.23)
|
||||
monthovsize = (1, 0.5)
|
||||
weekdayrowpos = (0, 0.209)
|
||||
weekrowboxsize = (1, 0.044)
|
||||
|
@ -76,7 +79,7 @@ class MonthOvPanel (PanelDesign):
|
|||
partialwidth = maxwidth / 7
|
||||
partialheight = maxheight / 5
|
||||
posx, posy = self.__abs_pos__(monthovposition)
|
||||
return (posx + day_of_week * partialwidth, posy + week_in_month * partialheight)
|
||||
return (int(posx + day_of_week * partialwidth), int(posy + week_in_month * partialheight))
|
||||
|
||||
def __draw_month_overview__ (self):
|
||||
"""Using the built-in calendar function, draw icons for each
|
||||
|
@ -86,6 +89,8 @@ class MonthOvPanel (PanelDesign):
|
|||
for numbers in week:
|
||||
self.__draw_day_number__(numbers, self.__get_day_pos__(cal.index(week), week.index(numbers)))
|
||||
|
||||
self.__draw_highlight_box__(self.__abs_pos__(dayhighlightboxsize), self.__get_today_box_pos__(), width=3)
|
||||
|
||||
def __draw_week_row__ (self):
|
||||
week_days = self.__get_week_days_ordered__()
|
||||
|
||||
|
@ -94,23 +99,27 @@ class MonthOvPanel (PanelDesign):
|
|||
txt.pos = self.__get_week_day_pos__(day_of_week)
|
||||
self.draw_design(txt)
|
||||
|
||||
self.__draw_highlight_box__(self.__abs_pos__(weekrownameboxsize), self.__get_week_day_pos__(datetime.now().weekday()))
|
||||
self.__draw_highlight_box__(self.__abs_pos__(weekrownameboxsize), self.__get_week_day_pos__(datetime.now().weekday()), width=1)
|
||||
|
||||
def __get_week_day_pos__ (self, day_of_week):
|
||||
maxwidth, _ = self.__abs_pos__(monthovsize)
|
||||
partialwidth = maxwidth / 7
|
||||
posx, posy = self.__abs_pos__(weekdayrowpos)
|
||||
return (posx + day_of_week * partialwidth, posy)
|
||||
return (int(posx + day_of_week * partialwidth), int(posy))
|
||||
|
||||
def __draw_highlight_box__(self, size, pos, color='black'):
|
||||
topleft = pos
|
||||
bottomright = (pos[0] + size[0], pos[1] + size[1])
|
||||
ImageDraw.Draw(self.__image__).rectangle([topleft, bottomright], outline=color)
|
||||
def __get_today_box_pos__ (self):
|
||||
x, y = self.__get_day_pos__(int(datetime.now().day / 7), datetime.now().weekday())
|
||||
return (x, y + (self.__abs_pos__(daynumberboxsize)[1] - self.__abs_pos__(dayhighlightboxsize)[1]) / 2)
|
||||
|
||||
def __draw_highlight_circle__(self, size, pos, color='black'):
|
||||
topleft = pos
|
||||
bottomright = (pos[0] + size[0], pos[1] + size[1])
|
||||
ImageDraw.Draw(self.__image__).ellipse([topleft, bottomright], outline=color)
|
||||
def __draw_highlight_box__ (self, size, pos, color='black', width=1):
|
||||
design = BoxDesign(size, outline=color, width = width)
|
||||
design.pos = pos
|
||||
self.draw_design(design)
|
||||
|
||||
def __draw_highlight_circle__ (self, size, pos, color = 'black', width=1):
|
||||
design = EllipseDesign(size, outline=color, width = width)
|
||||
design.pos = pos
|
||||
self.draw_design(design)
|
||||
|
||||
def __get_week_days_ordered__ (self):
|
||||
cur_weekday = datetime.now().weekday()
|
||||
|
|
Loading…
Reference in a new issue