Beispiel #1
0
    def __init__(self, events: [EventEntity], date):
        self.date = date
        self.events = []

        for event in events:
            copy = EventEntity()
            copy.copy_from(event)
            self.events.append(copy)
Beispiel #2
0
 def insert_event(self, event: EventEntity):
     self.tree.insert('',
                      'end',
                      text=event.id,
                      values=(event.name,
                              event.get_single_line_description(),
                              event.get_start_str(), event.get_end_str(),
                              event.get_duration_str(), event.priority.name,
                              event.day_time.name.replace('_', ' ')))
Beispiel #3
0
def import_file(file_path: str) -> List[EventEntity]:
    with open(file_path, 'r') as f:
        text = f.read()
        c = Calendar(text)
        my_events: List[EventEntity] = []
        for event in c.events:
            my_event = EventEntity(event.name, event.begin.datetime, event.end.datetime, event.description)
            my_event.uid = event.uid
            parse_extras(my_event, event)
            my_events.append(my_event)

        return my_events
Beispiel #4
0
    def __init__(self, parent, event: EventEntity, color: str):
        self.parent = parent

        tk.Frame.__init__(self, parent, bg=color, highlightbackground="black", highlightcolor="black", highlightthickness=1,)

        self.name = tk.Label(self, text=event.name, bg=color)
        self.name.grid(row=0, column=0, sticky='w')

        self.time = tk.Label(self, text=event.get_time_label(), bg=color)
        self.time.grid(row=1, column=0,  sticky='w')

        self.delta = tk.Label(self, text=event.get_delta_label(), bg=color)
        self.delta.grid(row=2, column=0,  sticky='w')
 def get_event(self) -> EventEntity:
     event = EventEntity(self.name.get(), self.get_start_datetime(),
                         self.get_end_datetime(),
                         self.description.get(1.0,
                                              tk.END), self.duration.get(),
                         self.loose.get(), Priority[self.priority.get()],
                         DayTime[self.day_time.get().replace(' ', '_')],
                         self.time_window.get(),
                         self.get_before_timedelta(),
                         self.get_after_timedelta())
     event.id = self.id
     if self.uid is not None:
         event.uid = self.uid
     return event
Beispiel #6
0
def parse_extras(my_event: EventEntity, event:Event):
    for extra in event.extra:
        name = extra.name
        value = extra.value
        if name == "LOOSE":
            if value == 'True':
                my_event.loose = True
            else:
                my_event.loose = False
        elif name == "MYDURATION":
            my_event.duration = int(value)
        elif name == "PRIORITY":
            my_event.priority = Priority[value]
        elif name == "DAYTIME":
            my_event.day_time = DayTime[value]
        elif name == "TIMEWINDOW":
            if value == 'True':
                my_event.time_window = True
            else:
                my_event.time_window = False
        elif name == "TIMEBEFORE":
            my_event.time_before = parse_timedelta(value)
        elif name == "TIMEAFTER":
            my_event.time_after = parse_timedelta(value)
Beispiel #7
0
 def add_event(self, event: EventEntity, start: datetime, end: datetime):
     event.date_start = start
     event.date_end = end
     event.loose = False
     event.time_window = False
     self.events.append(event)