def callback(): if (self.taskDescEntryFieldList[self.numTasksOnDisplay - 1].get() == "" and self.numTasksOnDisplay == 1): errorLabel.config(text="Enter at least 1 item", fg="red") else: for i in sorted(self.deleteBeforeSave, reverse=True): self.taskDescLabelList.pop(i) self.weightScaleList.pop(i) finalTaskList = [] for f, b in zip(self.taskDescLabelList, self.weightScaleList): task = Task() task.description = f.cget("text") task.weight = str(b.get()) finalTaskList.append(task) if (self.taskDescEntryFieldList[self.numTasksOnDisplay - 1].get() != ""): task = Task() task.description = self.taskDescEntryFieldList[ self.numTasksOnDisplay - 1].get() task.weight = str( self.weightScaleList[self.numTasksOnDisplay - 1].get()) finalTaskList.append(task) finalTaskSet = TaskSet() finalTaskSet.taskList = finalTaskList finalTaskSet.version = "0" finalTaskSet.active = "Y" finalTaskSet.name = "Mithul's task set" finalTaskSet.dateCreated = datetime.date.today().strftime( "%d%m%Y") #finalTaskSet.viewTaskSet() finalTaskSet.saveToFile("data/TaskSets.dat") def clearScreen(): for i in self.taskDescLabelList: i.destroy() for i in self.weightScaleList: i.destroy() for i in self.removeButtonList: i.destroy() for i in self.taskDescEntryFieldList: i.destroy() root3 = Toplevel() root3.geometry('+%d+%d' % (self.winfo_rootx(), self.winfo_rooty())) app2 = DailyTracking(root3) root2.withdraw() clearScreen()
def callback(): if (self.taskDescEntryField.get() == "" and self.numTasksOnDisplay == 1): errorLabel.config(text="Enter at least 1 item", fg="red") else: for i in sorted(self.deleteBeforeSave, reverse=True): self.taskDescLabelList.pop(i) self.weightScaleList.pop(i) finalTaskList = [] for f, b in zip(self.taskDescLabelList, self.weightScaleList): task = Task() task.description = f.cget("text") task.weight = str(b.get()) finalTaskList.append(task) if (self.taskDescEntryField.get() != ""): task = Task() task.description = self.taskDescEntryField.get() task.weight = self.taskWeightScale.get() finalTaskList.append(task) finalTaskSet = TaskSet() finalTaskSet.taskList = finalTaskList finalTaskSet.active = "Y" finalTaskSet.name = "Mithul's task set" finalTaskSet.version = activeTaskSet.version finalTaskSet.dateCreated = datetime.date.today().strftime( "%d%m%Y") if (activeTaskSet.isDifferent(finalTaskSet)): print( "Taskset has changed. Appending new version to TaskSetFile" ) finalTaskSet.version = str(int(finalTaskSet.version) + 1) finalTaskSet.addNewVersionToFile("data/TaskSets.dat") else: print("No changes found in taskset") root3.geometry('+%d+%d' % (self.winfo_rootx(), self.winfo_rooty())) root3.deiconify() app.init_DailyTrackingWindow() root2.withdraw() clearScreen()
def add_subtask(toplevel, task): """Create Dialog to edit task title and description""" dialog = NewTaskDialog(toplevel, color=task.color) try: newTitle, newDescription, newDate, newColor = dialog.run() except TypeError: # Cancel return None finally: dialog.destroy() if not newTitle: return # Empty title = Cancel newTask = Task(newTitle) if newDescription: newTask.description = newDescription if newDate: newTask.date = newDate newTask.color = strFromColor(newColor) task.add_subtask(newTask) return newTask
def add_subtask(toplevel, task): """Create Dialog to edit task title and description""" dialog = NewTaskDialog(toplevel, color=task.color) try: newTitle, newDescription, newDate, newColor = dialog.run() except TypeError: # Cancel return None finally: dialog.destroy() if not newTitle: return # Empty title = Cancel newTask = Task(newTitle) if newDescription: newTask.description = newDescription if newDate: newTask.date = newDate newTask.color = strFromColor(newColor) task.add_subtask(newTask) return newTask
def convertTaskSetStringToTaskSet(self, taskSetString): descriptionList = [] weightList = [] positionList = [] taskList = [] taskSet = TaskSet() position = 0 for line in taskSetString.splitlines(): task = Task() if (line[:2] == "TS"): taskSet.active = line[3] taskSet.dateCreated = line[5:13] taskSet.version = self.getVersion(line) taskSet.name = self.getName(line) if (line[:2] == "TD"): descriptionList.append(line[3:]) positionList.append(position) position = position + 1 if (line[:2] == "TW"): weightList.append(line[3:]) for d, w, p in zip(descriptionList, weightList, positionList): task = Task() task.description = d task.weight = w task.position = p taskList.append(task) taskSet.taskList = taskList return taskSet
def load(self, filename): f = open(filename, 'r') f = FileWrapper(f) state = "Start" newtask = None newpomo = None skip_read = False while True: if not skip_read: line = f.readline() skip_read = False if line == "": break if state == "Start": if re.match("#### Task", line): newtask = Task("", "") state = "Task_State" skip_read = True if re.match("#### Pomodoro", line): newpomo = Pomo() state = "Pomo_Remaining" elif state == "Task_State": found, val = self._loadField(f, 'State', hasfield=True) if not found: return False newtask.state = val found, val = self._loadField(f, 'Blocked Reason', hasfield=True, multiline=True) if not found: return False if val is not None: newtask.blocked_reason = "".join(val).strip() found, val = self._loadField(f, 'Closed Reason', hasfield=True, multiline=True) if not found: return False if val is not None: newtask.closed_reason = "".join(val).strip() found, val = self._loadField(f, 'Id', hasfield=True) if not found: return False if val is not None: newtask.id = int(val) found, val = self._loadField(f, 'Date Created', hasfield=True) if not found: return False if val is not None: newtask.date_created = int(val) found, val = self._loadField(f, 'Date Closed', hasfield=True) if not found: return False if val is not None: newtask.date_closed = int(val) found, val = self._loadField(f, 'Date Due', hasfield=True) if not found: return False if val is not None: newtask.date_due = int(val) found, val = self._loadField(f, 'Time Estimate', hasfield=True) if not found: return False if val is not None: newtask.time_estimate = int(val) found, val = self._loadField(f, 'Time Spent', hasfield=True) if not found: return False if val is not None: newtask.time_spent = int(val) found, val = self._loadField(f, 'Summary', hasfield=True, multiline=True) if not found: return False if val is not None: newtask.summary = "".join(val).strip() found, val = self._loadField(f, 'Description', hasfield=True, multiline=True) if not found: return False if val is not None: newtask.description = "".join(val).strip() self.tasks.append(newtask) state = "End" elif state == "End": if re.match("#### Task", line) or re.match("#### Pomodoro", line): if re.match("#### Task", line): state = "Task_State" skip_read = True newtask = Task("", "") else: state = "Pomo_Remaining" newpomo = Pomo() elif state == "Pomo_Remaining": mo = re.match("## Time Remaining: (.*)", line) if mo: remainingTime = float(mo.group(1)) newpomo.set_remaining_time(remainingTime) self.pomo = newpomo state = "Pomo_Running" elif state == "Pomo_Running": mo = re.match("## Running: (.*)", line) if mo: if mo.group(1) == "true": state = "Pomo_SaveDate" else: state = "Start" elif state == "Pomo_SaveDate": mo = re.match("## Save Date: (.*)", line) if mo: saveDateUtc = float(mo.group(1)) elapsedSinceSave = self.time.time() - saveDateUtc remainingTime = newpomo.get_remaining_time(self.time.time()) - elapsedSinceSave newpomo.set_remaining_time( remainingTime if remainingTime > 0 else 0) newpomo.start(self.time.time()) state = "Start" if state == "End": state = "Start" f.close() return state == "Start"