Exemplo n.º 1
0
    def _add_event(self, event):
        event_start      = max(event.start, self.range[0])
        event_end        = min(event.end,   self.range[1])
        event_off_days   = (event_start - self.range[0]).days
        event_width_days = (event_end - event_start).days + 1

        # Create the event.
        item = CanvasEvent(self.cal, event)
        self.event_items[event] = item
        item.connect('button-press-event',   self.on_event_button_press_event)
        item.connect('button-release-event', self.on_event_button_release_event)
        self.table.add(item,
                       event_off_days,
                       event_off_days + event_width_days,
                       len(self.event_items))
        item.set_text(event.caption)
        if event.all_day:
            item.set_property('color', color.to_int(event.bg_color))
        if self.show_normal and not util.same_day(event.start, event.end):
            item.set_property('color', color.to_int(event.bg_color))
        elif not event.all_day:
            time = self._format_time(event)
            item.set_text(time)
            item.set_text_properties(xalign = hippo.ALIGNMENT_START)
        if event.text_color is not None:
            item.set_text_color(event.text_color)
        radius_top_left     = 10
        radius_top_right    = 10
        radius_bottom_left  = 10
        radius_bottom_right = 10
        if event.end > self.range[1]:
            radius_top_right    = 0
            radius_bottom_right = 0
        if event.start < self.range[0]:
            radius_top_left    = 0
            radius_bottom_left = 0
        item.set_properties(radius_top_left     = radius_top_left,
                            radius_top_right    = radius_top_right,
                            radius_bottom_left  = radius_bottom_left,
                            radius_bottom_right = radius_bottom_right)
Exemplo n.º 2
0
    def _add_event(self, event):
        event_start = max(event.start, self.range[0])
        event_end = min(event.end, self.range[1])
        event_off_days = (event_start - self.range[0]).days
        event_width_days = (event_end - event_start).days + 1

        # Create the event.
        item = CanvasEvent(self.cal, event)
        self.event_items[event] = item
        item.connect('button-press-event', self.on_event_button_press_event)
        item.connect('button-release-event',
                     self.on_event_button_release_event)
        self.table.add(item, event_off_days, event_off_days + event_width_days,
                       len(self.event_items))
        item.set_text(event.caption, event.description)
        item.set_property('color', color.to_int(event.bg_color))
        if self.show_normal and not util.same_day(event.start, event.end):
            item.set_property('color', color.to_int(event.bg_color))
        elif not event.all_day:
            time = self._format_time(event)
            item.set_text(time, event.description)
            item.set_text_properties(xalign=hippo.ALIGNMENT_START)
        if event.text_color is not None:
            item.set_text_color(event.text_color)
        radius_top_left = 10
        radius_top_right = 10
        radius_bottom_left = 10
        radius_bottom_right = 10
        if event.end > self.range[1]:
            radius_top_right = 0
            radius_bottom_right = 0
        if event.start < self.range[0]:
            radius_top_left = 0
            radius_bottom_left = 0
        item.set_properties(radius_top_left=radius_top_left,
                            radius_top_right=radius_top_right,
                            radius_bottom_left=radius_bottom_left,
                            radius_bottom_right=radius_bottom_right)
Exemplo n.º 3
0
    def _add_event(self, event):
        rows, cols = self.table.get_size()
        event_start = max(event.start, self.range[0])
        event_end = min(event.end, self.range[1])
        event_off = (event_start - self.range[0]).seconds
        event_len = (event_end - event_start).seconds
        range_len = self.range[1] - self.range[0]
        seconds = range_len.days * 24 * 60 * 60 + range_len.seconds
        row_seconds = ceil(seconds / float(rows))
        event_off_rows = int(ceil(event_off / float(row_seconds)))
        event_len_rows = int(ceil(event_len / float(row_seconds)))
        event_end_rows = event_off_rows + event_len_rows

        # Create the event.
        item = CanvasEvent(self.cal, event)
        self.event_items[event] = item
        item.connect("button-press-event", self.on_event_button_press_event)
        item.connect("button-release-event", self.on_event_button_release_event)
        self.table.set_column_expand(cols, True)
        self.table.add(item, cols + 1, cols + 2, event_off_rows, event_end_rows)
        item.set_text(event.caption)
        item.set_property("color", color.to_int(event.bg_color))
        if event.text_color is not None:
            item.set_text_color(event.text_color)

        radius_top_left = 10
        radius_top_right = 10
        radius_bottom_left = 10
        radius_bottom_right = 10
        if event.end > self.range[1]:
            radius_bottom_left = 0
            radius_bottom_right = 0
        if event.start < self.range[0]:
            radius_top_left = 0
            radius_top_right = 0
        item.set_properties(
            radius_top_left=radius_top_left,
            radius_top_right=radius_top_right,
            radius_bottom_left=radius_bottom_left,
            radius_bottom_right=radius_bottom_right,
        )
Exemplo n.º 4
0
    def _add_event(self, event):
        rows, cols = self.table.get_size()
        event_start = max(event.start, self.range[0])
        event_end = min(event.end, self.range[1])
        event_off = (event_start - self.range[0]).seconds
        event_len = (event_end - event_start).seconds
        range_len = self.range[1] - self.range[0]
        seconds = range_len.days * 24 * 60 * 60 + range_len.seconds
        row_seconds = ceil(seconds / float(rows))
        event_off_rows = int(ceil(event_off / float(row_seconds)))
        event_len_rows = int(ceil(event_len / float(row_seconds)))
        event_end_rows = event_off_rows + event_len_rows

        # Create the event.
        item = CanvasEvent(self.cal, event)
        self.event_items[event] = item
        item.connect('button-press-event', self.on_event_button_press_event)
        item.connect('button-release-event',
                     self.on_event_button_release_event)
        self.table.set_column_expand(cols, True)
        self.table.add(item, cols + 1, cols + 2, event_off_rows,
                       event_end_rows)
        item.set_text(event.caption)
        item.set_property('color', color.to_int(event.bg_color))
        if event.text_color is not None:
            item.set_text_color(event.text_color)

        radius_top_left = 10
        radius_top_right = 10
        radius_bottom_left = 10
        radius_bottom_right = 10
        if event.end > self.range[1]:
            radius_bottom_left = 0
            radius_bottom_right = 0
        if event.start < self.range[0]:
            radius_top_left = 0
            radius_top_right = 0
        item.set_properties(radius_top_left=radius_top_left,
                            radius_top_right=radius_top_right,
                            radius_bottom_left=radius_bottom_left,
                            radius_bottom_right=radius_bottom_right)
Exemplo n.º 5
0
 def set_text_color(self, newcolor):
     self.text.props.color = color.to_int(newcolor)
Exemplo n.º 6
0
 def set_text_color(self, newcolor):
     self.text.props.color = color.to_int(newcolor)