From d7137ac9c13c6fe98860749b92ad50f3b95dd762 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 9 Apr 2019 12:17:12 +0200 Subject: [PATCH] Added dynamic hour range --- Calendar/DayViewPanel.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Calendar/DayViewPanel.py b/Calendar/DayViewPanel.py index 3a5b747..3314db5 100644 --- a/Calendar/DayViewPanel.py +++ b/Calendar/DayViewPanel.py @@ -5,6 +5,7 @@ from HourListDesign import HourListDesign header_size = (1, 0.2) hourlist_size = (1, 1 - header_size[1]) +showhours_count = 12 class DayViewPanel (PanelDesign): """Overview that focuses on the current day and @@ -40,9 +41,18 @@ class DayViewPanel (PanelDesign): self.__header__.pos = (0, 0) 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]) + 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): return (int(coordinates[0] * self.size[0]),int(coordinates[1] * self.size[1]))