Added dynamic hour range

This commit is contained in:
Maximilian Giller 2019-04-09 12:17:12 +02:00
parent 5cb04d9dcf
commit d7137ac9c1

View file

@ -5,6 +5,7 @@ from HourListDesign import HourListDesign
header_size = (1, 0.2) header_size = (1, 0.2)
hourlist_size = (1, 1 - header_size[1]) hourlist_size = (1, 1 - header_size[1])
showhours_count = 12
class DayViewPanel (PanelDesign): class DayViewPanel (PanelDesign):
"""Overview that focuses on the current day and """Overview that focuses on the current day and
@ -40,9 +41,18 @@ class DayViewPanel (PanelDesign):
self.__header__.pos = (0, 0) self.__header__.pos = (0, 0)
def __init_hourlist__ (self): def __init_hourlist__ (self):
self.__hourlist__ = HourListDesign(self.__abs_co__(hourlist_size), 6, 18) start, end = self.__get_current_hour_range__()
self.__hourlist__ = HourListDesign(self.__abs_co__(hourlist_size), start, end)
self.__hourlist__.pos = (0, self.__header__.size[1]) self.__hourlist__.pos = (0, self.__header__.size[1])
def __get_current_hour_range__(self):
start_hour = datetime.now().hour
if start_hour + showhours_count > 23:
start_hour = 23 - showhours_count
return start_hour, start_hour + showhours_count
def __abs_co__ (self, coordinates): def __abs_co__ (self, coordinates):
return (int(coordinates[0] * self.size[0]),int(coordinates[1] * self.size[1])) return (int(coordinates[0] * self.size[0]),int(coordinates[1] * self.size[1]))