def onApply(self, data): """Reads the information from the dialog and saves the task.""" # Get the information from the dialog and save it to the database t = Task() # Make sure that there was text in the text box if len(self.widgets.get_widget('TaskEntry').get_text()) > 1: # Set the task name to the value of the text box t.name = self.widgets.get_widget('TaskEntry').get_text() # Set the priority to the value of the combo box t.priority = self.widgets.get_widget('PriorityEntry').get_active() # Set the status to not completed t.status = self.widgets.get_widget('StatusEntry').get_active() # Set the id of the task t.id = self.taskid # Set the due date of the task t.duedate = self.widgets.get_widget('DateEntry').get_date() # Save the task in the database self.db.saveTask(t) # Close the dialog self.dialog.destroy()
errordialog = gtk.MessageDialog(None, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, 'Error in reading a task from database:\n\n' + message.message) errordialog.run() errordialog.destroy() # Fetch one result and store it result = cursor.fetchone() # Create a Task object to store the information in t = Task() # Set the values from the database results t.name = result[0] t.priority = result[1] t.status = result[2] t.id = result[3] t.duedate = (result[4], result[5], result[6]) # Return the task object return t def readTasks(self): """Reads all of the tasks from the database and returns them in a list""" # Create a cursor for the database cursor = sqlite.connect(DBPATH).cursor() # Create a tuple with the constant for completed tasks for the query data = task.TASK_COMPLETED, # Try to get all of the tasks that are not completed try: cursor.execute('SELECT * from tasks\