# Ion-Todo-Planner # Copyright (C) 2024 Ione 15 # # This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License along with this program. If not, see . import sqlite3 from datetime import datetime import time import tkinter as tk con = sqlite3.connect("todo.db") cur = con.cursor() def add_item(): item = entry.get() if item: listbox.insert(tk.END, item) entry.delete(0, tk.END) # deletes input def remove_item(): selected_index = listbox.curselection() if selected_index: listbox.delete(selected_index) def update_list(): cur_time = (datetime.now() - datetime(1970, 1, 1)).total_seconds() + time.timezone total_time = [] remaining_time = [] importance = [] res = cur.execute("SELECT * FROM todo").fetchall() for i, tmp1 in enumerate(res): total_time.append(res[i][3] - res[i][2]) remaining_time.append(res[i][3] - cur_time) importance.append(total_time[i] / remaining_time[i] * res[i][4]) if int(importance[i]) == 0: importance[i] = 1 print("UPDATE todo SET IMP = %s WHERE ID = %s" % (int(importance[i]), i + 1)) cur.execute("UPDATE todo SET IMP = %s WHERE ID = %s" % (int(importance[i]), i + 1)) print(i) listbox.insert(tk.END, res[i][0]) con.commit() # Create the main window root = tk.Tk() root.title("Ion-Todo-Planner") # Create a listbox to display the items listbox = tk.Listbox(root, width=100) listbox.pack(padx=5, pady=5) # Create an entry for adding items entry = tk.Entry(root, width=50) entry.pack(padx=10, pady=5) # Create buttons to add and remove items add_button = tk.Button(root, text="Add", command=add_item) add_button.pack(side=tk.LEFT, padx=5, pady=5) remove_button = tk.Button(root, text="Remove", command=remove_item) remove_button.pack(side=tk.LEFT, padx=5, pady=5) update_button = tk.Button(root, text="Update", command=update_list) update_button.pack(padx=5, pady=5) # Run the Tkinter event loop root.mainloop()