def del_task(self, task): """ Suppression de tâches """ rep = askyesno( _("Confirmation"), _("Are you sure you want to delete the task {task}? This action cannot be undone." ).format(task=task.capitalize())) if rep: CONFIG.remove_option("PomodoroTasks", task) # remove stats db = sqlite3.connect(PATH_STATS) cursor = db.cursor() try: cursor.execute('DROP TABLE {}'.format( scrub(task.lower().replace(' ', '_')))) db.commit() except sqlite3.OperationalError: pass # no stats yet db.close() self.tasks[task].destroy() self._tasks_btns[task].destroy() del self.tasks[task] del self._tasks_btns[task] if len(CONFIG.options("PomodoroTasks")) == 1: CONFIG.set("PomodoroTasks", _("Work"), CMAP[0]) self._tasks_btns[CONFIG.options("PomodoroTasks")[0]].state( ['disabled']) save_config()
def del_cat(self, cat): rep = askyesno( _("Confirmation"), _("Are you sure you want to delete the category {category}? This action cannot be undone." ).format(category=cat)) if rep: CONFIG.remove_option("Categories", cat) for w in self.cats[cat]: w.destroy() del self.cats[cat] save_config()