diff --git a/main.py b/main.py index 95b1793..194262c 100644 --- a/main.py +++ b/main.py @@ -44,13 +44,18 @@ def add_item(entry, input_field): "'%s', '%s','%s', '%s', '%s' )" % (item, get_time(), get_time(), 100, 0)) con.commit() input_field.destroy() + update_list() def remove_item(): selected_index = listbox.curselection() if selected_index: listbox.delete(selected_index) - print(selected_index) + print(selected_index[0]) + cur.execute("DELETE FROM todo WHERE ID = %s" % list(tasklist.keys())[selected_index[0]]) + print("DELETE FROM todo WHERE ID = %s" % list(tasklist.keys())[selected_index[0]]) + con.commit() + update_list() def update_list(): @@ -60,6 +65,7 @@ def update_list(): total_time = [] # cleanup and init remaining_time = [] importance = [] + tasklist.clear() res = cur.execute("SELECT * FROM todo").fetchall() for i, tmp1 in enumerate(res):