2019-03-17 12:12:58 +01:00
|
|
|
from PanelDesign import PanelDesign
|
|
|
|
from datetime import datetime, timedelta, date
|
2019-03-17 20:55:45 +01:00
|
|
|
from DayHeaderDesign import DayHeaderDesign
|
2019-03-17 22:05:49 +01:00
|
|
|
from HourListDesign import HourListDesign
|
2019-03-17 20:55:45 +01:00
|
|
|
|
|
|
|
header_size = (1, 0.2)
|
2019-03-17 22:05:49 +01:00
|
|
|
hourlist_size = (1, 1 - header_size[1])
|
2019-03-17 12:12:58 +01:00
|
|
|
|
|
|
|
class DayViewPanel (PanelDesign):
|
|
|
|
"""Overview that focuses on the current day and
|
|
|
|
shows a timeline split into hours."""
|
|
|
|
def __init__ (self, size):
|
|
|
|
super(DayViewPanel, self).__init__(size)
|
|
|
|
self.__first_render__()
|
|
|
|
|
|
|
|
def __first_render__ (self):
|
2019-03-17 20:55:45 +01:00
|
|
|
self.__init_header__()
|
2019-03-17 22:05:49 +01:00
|
|
|
self.__init_hourlist__()
|
2019-03-17 12:12:58 +01:00
|
|
|
|
|
|
|
def add_weather (self, weather):
|
2019-03-17 20:55:45 +01:00
|
|
|
self.__header__.add_weather(weather)
|
2019-03-17 12:12:58 +01:00
|
|
|
|
|
|
|
def add_calendar (self, calendar):
|
2019-03-17 20:55:45 +01:00
|
|
|
self.__add_allday_events__(calendar)
|
2019-03-17 22:05:49 +01:00
|
|
|
self.__add_timed_events__(calendar)
|
2019-03-17 12:12:58 +01:00
|
|
|
|
|
|
|
def add_rssfeed (self, rss):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def add_taks (self, tasks):
|
|
|
|
pass
|
|
|
|
|
2019-03-17 20:55:45 +01:00
|
|
|
def __finish_image__ (self):
|
|
|
|
self.draw_design(self.__header__)
|
2019-03-17 22:05:49 +01:00
|
|
|
self.draw_design(self.__hourlist__)
|
2019-03-17 20:55:45 +01:00
|
|
|
|
|
|
|
def __init_header__ (self):
|
|
|
|
self.__header__ = DayHeaderDesign(self.__abs_co__(header_size), date.today())
|
|
|
|
self.__header__.pos = (0, 0)
|
|
|
|
|
2019-03-17 22:05:49 +01:00
|
|
|
def __init_hourlist__ (self):
|
2019-04-04 21:27:29 +02:00
|
|
|
self.__hourlist__ = HourListDesign(self.__abs_co__(hourlist_size), 6, 18)
|
2019-03-17 22:05:49 +01:00
|
|
|
self.__hourlist__.pos = (0, self.__header__.size[1])
|
|
|
|
|
2019-03-17 20:55:45 +01:00
|
|
|
def __add_allday_events__ (self, calendar):
|
|
|
|
allday_events = [event for event in calendar.get_today_events() if event.allday]
|
|
|
|
self.__header__.add_events(allday_events)
|
2019-03-17 12:12:58 +01:00
|
|
|
|
2019-03-17 22:05:49 +01:00
|
|
|
def __add_timed_events__ (self, calendar):
|
|
|
|
timed_events = [event for event in calendar.get_today_events() if event.allday is False]
|
|
|
|
self.__hourlist__.add_events(timed_events)
|
|
|
|
|
2019-03-17 20:55:45 +01:00
|
|
|
def __abs_co__ (self, coordinates):
|
2019-03-17 12:12:58 +01:00
|
|
|
return (int(coordinates[0] * self.size[0]),int(coordinates[1] * self.size[1]))
|