def getEvents(self): chosenDate = self.dateVar.get() #xd = datetime.strptime(self.dateVar.get(), '%d/%m/%y') if (chosenDate != ''): self.listbox.delete(0, tk.END) dateToGet = date.fromisoformat(chosenDate) searchQuery = self.searchQueryI.get("1.0", tk.END) if (self.eventDateCheckALL.get() == 1): eventList = myBackend.getEvents() elif (self.eventDateCheckBF.get() == 1): eventList = myBackend.getEventsBefore(dateToGet) else: eventList = myBackend.getEventsAfter(dateToGet) eventList = myBackend.filterNLP(eventList, searchQuery, self.master.searchE) self.eventL = eventList longestid = 1 for event in eventList: newid = len(str(event.id)) if (newid > longestid): longestid = newid for event in eventList: toAdd = str(event.id) + ". " if (len(toAdd) - 2 < longestid): for i in range(longestid - len(toAdd) + 2): toAdd += " " toAdd += " " + event.dateStart.strftime( "%Y-%m-%d") + " | " + event.dateStart.strftime( "%H:%M") + " - " + event.dateEnd.strftime("%H:%M") toAdd += " " toAdd += "| Name: " + event.name self.listbox.insert(tk.END, toAdd)
def updateEvent(self): if (self.eventNameI.get().replace(" ", "") == ""): self.setMessage("Event name can't contain only whitespaces", False) return if (self.eventDescI.get("1.0", tk.END).replace(" ", "").replace("\n", "") == ""): self.setMessage("Description can't contain only whitespaces", False) return if (self.eventTimeStartHI.get() == ""): self.setMessage("You have to put starting hour", False) return if (self.eventTimeEndHI.get() == ""): self.setMessage("You have to put ending hour", False) return if (self.eventTimeStartMI.get() == ""): self.setMessage("You have to put starting minute", False) return if (self.eventTimeStartMI.get() == ""): self.setMessage("You have to put starting minute", False) return startTime = timedelta(hours=int(self.eventTimeStartHI.get()), minutes=int(self.eventTimeStartMI.get())) endTime = timedelta(hours=int(self.eventTimeEndHI.get()), minutes=int(self.eventTimeEndMI.get())) if (int(self.evenTimeEndNextDayCheck.get()) == 1): endTime = endTime + timedelta(days=1) else: if (startTime >= endTime): self.setMessage("StartTime is larger then EndTime", False) return dateStart = datetime.strptime( self.eventDateStartI.get_date().strftime("%Y-%m-%d %H:%M:%S"), "%Y-%m-%d %H:%M:%S") + startTime dateEnd = datetime.strptime( self.eventDateStartI.get_date().strftime("%Y-%m-%d %H:%M:%S"), "%Y-%m-%d %H:%M:%S") + endTime newEvent = dbClass.Event( **{ 'id': eventId, 'name': self.eventNameI.get(), 'dateStart': dateStart, 'dateEnd': dateEnd, 'description': self.eventDescI.get("1.0", tk.END) }) msg, succ = myBackend.updateEvent(newEvent, eventId) self.setMessage(msg, succ) if (succ): self.event = newEvent
def addEventButton(self): msg, succ = myBackend.addEventButton( str(self.eventNameI.get()), str(self.eventDescI.get("1.0", tk.END)), self.eventDateStartI.get_date(), str(self.eventTimeStartHI.get()), str(self.eventTimeEndHI.get()), str(self.eventTimeStartMI.get()), str(self.eventTimeEndMI.get()), str(self.evenTimeEndNextDayCheck.get()), str(self.eventRecurrCheck.get()), str(self.eventRecurrAmountI.get()), str(self.menuRecurrVal.get())) self.setMessage(msg, succ)
def deleteEvent(self): myBackend.deleteEvent(eventId) self.closeWindow()
def getValuesFromEvent(self): e = myBackend.getEvent(eventId) if (e == "Error"): self.destroy() else: self.event = e
def deleteChosen(self): self.listbox.delete(0, tk.END) myBackend.deleteEventList(self.eventL)
def addEventFromFile(self): fileName = str(self.eventAddFromFileI.get()) msg, succ = myBackend.addEventsFromFile(fileName) self.setMessage(msg, succ)