diff --git a/main.py b/main.py index 7f4c222..34ec415 100644 --- a/main.py +++ b/main.py @@ -7,11 +7,34 @@ con = sqlite3.connect("todo.db") cur = con.cursor() -def add_item(): +def add_item_dialog(): + input_field = tk.Tk() + input_field.title("Add Item") + + input_window_width = 640 + input_window_height = 320 + + # find the center point + input_center_x = int(screen_width / 2 - input_window_width / 2) + input_center_y = int(screen_height / 2 - input_window_height / 2) + + input_field.geometry(f'{input_window_width}x{input_window_height}+{input_center_x}+{input_center_y}') + + # Create an entry for adding items + entry = tk.Entry(input_field, width=50) + entry.pack(padx=10, pady=5) + + input_confirm = tk.Button(input_field, text="Confirm", command=lambda: add_item(entry, input_field)) + input_confirm.pack(side=tk.BOTTOM, padx=5, pady=5) + input_field.mainloop() + + +def add_item(entry, input_field): item = entry.get() + print("a") if item: listbox.insert(tk.END, item) - entry.delete(0, tk.END) # deletes input + input_field.destroy() def remove_item(): @@ -21,8 +44,8 @@ def remove_item(): def update_list(): - listbox.delete(0,listbox.size()) # clear listbox - cur_time = (datetime.now() - datetime(1970, 1, 1)).total_seconds() + time.timezone + listbox.delete(0, listbox.size()) # clear listbox + cur_time = (datetime.now() - datetime(1970, 1, 1)).total_seconds() + time.timezone # timezone so we get utc time! total_time = [] remaining_time = [] @@ -46,17 +69,28 @@ def update_list(): root = tk.Tk() root.title("Ion-Todo-Planner") +# get the screen dimension +screen_width = root.winfo_screenwidth() +screen_height = root.winfo_screenheight() + +window_width = 1280 +window_height = 720 + +# find the center point +center_x = int(screen_width / 2 - window_width / 2) +center_y = int(screen_height / 2 - window_height / 2) + +# set the position of the window to the center of the screen +root.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}') + +root.minsize(window_width, window_height) # prevent making it smaller than min size + # 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 = tk.Button(root, text="Add", command=add_item_dialog) add_button.pack(side=tk.LEFT, padx=5, pady=5) remove_button = tk.Button(root, text="Remove", command=remove_item) diff --git a/todo.db b/todo.db index 976169c..b130d80 100644 Binary files a/todo.db and b/todo.db differ