forked from sherigar/HacktoberFest-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToDo.py
45 lines (35 loc) · 1.19 KB
/
ToDo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import tkinter as tk
def add_task():
task = entry.get()
if task:
listbox.insert(tk.END, task)
entry.delete(0, tk.END)
def remove_task():
selected_task = listbox.curselection()
if selected_task:
listbox.delete(selected_task)
def mark_completed():
selected_task = listbox.curselection()
if selected_task:
task = listbox.get(selected_task)
listbox.delete(selected_task)
completed_listbox.insert(tk.END, task)
# Create the main window
root = tk.Tk()
root.title("To-Do List")
# Entry for adding tasks
entry = tk.Entry(root, width=40)
entry.pack()
# Buttons for adding, marking as completed, and removing tasks
add_button = tk.Button(root, text="Add Task", command=add_task)
mark_button = tk.Button(root, text="Mark Completed", command=mark_completed)
remove_button = tk.Button(root, text="Remove Task", command=remove_task)
add_button.pack()
mark_button.pack()
remove_button.pack()
# Lists for displaying tasks and completed tasks
listbox = tk.Listbox(root, selectmode=tk.SINGLE, height=10, width=40)
completed_listbox = tk.Listbox(root, selectmode=tk.SINGLE, height=10, width=40)
listbox.pack()
completed_listbox.pack()
root.mainloop()