Exemplo n.º 1
0
    def __init__(self, caption, start, end=None, **kwargs):
        """
        Constructor.

        start -- datetime
        end -- datetime
        """
        assert caption is not None
        assert start is not None
        self.id = None
        self.caption = caption
        self.start = start
        self.end = end
        self.all_day = kwargs.get('all_day', False)
        self.text_color = kwargs.get('text_color', None)
        self.bg_color = kwargs.get('bg_color', 'orangered')
        self.description = kwargs.get('description', '')

        if end is None:
            self.all_day = True
            self.end = start

        if end is not None:
            # Check if end date (deadline) have a time set to 00:00:00,
            # this means the event should really end on the day before,
            # so remove 'one' second.
            end_day = datetime.datetime(*end.timetuple()[:3])
            end_day_seconds = datetime.datetime(*end.timetuple()[:6])
            if end_day == end_day_seconds:
                self.end = end - datetime.timedelta(seconds=1)

        if self.all_day:
            self.end = util.end_of_day(self.end)
Exemplo n.º 2
0
    def __init__(self, caption, start, end = None, **kwargs):
        """
        Constructor.

        start -- datetime
        end -- datetime
        """
        assert caption is not None
        assert start   is not None
        self.id         = None
        self.caption    = caption
        self.start      = start
        self.end        = end
        self.all_day    = kwargs.get('all_day',    False)
        self.text_color = kwargs.get('text_color', None)
        self.bg_color   = kwargs.get('bg_color',   'orangered')
        self.description = kwargs.get('description','')

        if end is None:
            self.all_day = True
            self.end     = start

        if end is not None:
            # Check if end date (deadline) have a time set to 00:00:00,
            # this means the event should really end on the day before,
            # so remove 'one' second.
            end_day = datetime.datetime(*end.timetuple()[:3])
            end_day_seconds = datetime.datetime(*end.timetuple()[:6])
            if end_day == end_day_seconds:
                self.end = end - datetime.timedelta(seconds=1)

        if self.all_day:
            self.end = util.end_of_day(self.end)
Exemplo n.º 3
0
    def set_range(self, start, end):
        if start is None or end is None:
            return
        range = datetime.datetime(*start.timetuple()[:3]), \
                datetime.datetime(*end.timetuple()[:7])

        # Update end if it's a `datetime.date' and not a `datetime.datetime',
        # because day ranges are inclusive (so day must _end_ at 23:59:59)
        if isinstance(end, datetime.date):
            range = range[0], util.end_of_day(range[1])

        if self.range is not None \
          and self.range[0] == range[0] \
          and self.range[1] == range[1]:
            return
        self.range = range
        self.update()
Exemplo n.º 4
0
    def set_range(self, start, end):
        if start is None or end is None:
            return
        range = datetime.datetime(*start.timetuple()[:3]), \
                datetime.datetime(*end.timetuple()[:7])

        # Update end if it's a `datetime.date' and not a `datetime.datetime',
        # because day ranges are inclusive (so day must _end_ at 23:59:59)
        if isinstance(end, datetime.date):
            range = range[0], util.end_of_day(range[1])

        if self.range is not None \
          and self.range[0] == range[0] \
          and self.range[1] == range[1]:
            return
        self.range = range
        self.update()
Exemplo n.º 5
0
 def __init__(self, caption, start, end = None, **kwargs):
     """
     Constructor.
     
     start -- datetime
     end -- datetime
     """
     assert caption is not None
     assert start   is not None
     self.id         = None
     self.caption    = caption
     self.start      = start
     self.end        = end
     self.all_day    = kwargs.get('all_day',    False)
     self.text_color = kwargs.get('text_color', None)
     self.bg_color   = kwargs.get('bg_color',   'orangered')
     if end is None:
         self.all_day = True
         self.end     = start
     if self.all_day:
         self.end = util.end_of_day(self.end)
Exemplo n.º 6
0
    def update_one_row(self):
        self.scroll.set_policy(hippo.ORIENTATION_VERTICAL,
                               hippo.SCROLLBAR_ALWAYS)
        self.grid.set_properties(box_height = 800)
        self.allday_view.set_range(*self.range)
        self.allday_view.set_visible(True)
        self.padding_left.set_visible(True)
        self.padding_right.set_visible(True)

        # Hide all event views.
        for cell in [c for c in self.hevent_views]:
            self._remove_hevent_view(cell)
        current_children = self.grid.get_children()
        for cell in [c for c in self.vevent_views]:
            if cell not in current_children:
                self._remove_vevent_view(cell)

        # Create an event view on top of each cell.
        for child in self.grid.get_children():
            start = child.date
            end   = util.end_of_day(child.date)
            view  = self._get_event_view(child, start, end, False)
            self.allocs[view] = (0, 0, 0, 0)
Exemplo n.º 7
0
    def update_one_row(self):
        self.scroll.set_policy(hippo.ORIENTATION_VERTICAL,
                               hippo.SCROLLBAR_ALWAYS)
        self.grid.set_properties(box_height = 800)
        self.allday_view.set_range(*self.range)
        self.allday_view.set_visible(True)
        self.padding_left.set_visible(True)
        self.padding_right.set_visible(True)

        # Hide all event views.
        for cell in [c for c in self.hevent_views]:
            self._remove_hevent_view(cell)
        current_children = self.grid.get_children()
        for cell in [c for c in self.vevent_views]:
            if cell not in current_children:
                self._remove_vevent_view(cell)

        # Create an event view on top of each cell.
        for child in self.grid.get_children():
            start = child.date
            end   = util.end_of_day(child.date)
            view  = self._get_event_view(child, start, end, False)
            self.allocs[view] = (0, 0, 0, 0)