Skip to content

Commit 867f4af

Browse files
committed
A GUI supported to-do list made in python.
1 parent 5589a3c commit 867f4af

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Python Programs/to-do.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import tkinter as tk
2+
3+
def add_task():
4+
task = entry.get()
5+
if task:
6+
listbox.insert(tk.END, task)
7+
entry.delete(0, tk.END)
8+
9+
def remove_task():
10+
selected_task = listbox.curselection()
11+
if selected_task:
12+
listbox.delete(selected_task)
13+
14+
# Create the main window
15+
root = tk.Tk()
16+
root.title("Cool To-Do List")
17+
18+
# Entry widget for adding tasks
19+
entry = tk.Entry(root, font=('Helvetica', 18))
20+
entry.grid(row=0, column=0, columnspan=2)
21+
22+
# Button to add tasks
23+
add_button = tk.Button(root, text="Add", font=('Helvetica', 14), command=add_task)
24+
add_button.grid(row=0, column=2)
25+
26+
# Button to remove tasks
27+
remove_button = tk.Button(root, text="Remove", font=('Helvetica', 14), command=remove_task)
28+
remove_button.grid(row=0, column=3)
29+
30+
# Listbox to display tasks
31+
listbox = tk.Listbox(root, font=('Helvetica', 18), selectmode=tk.SINGLE, selectbackground="#a5a5a5")
32+
listbox.grid(row=1, column=0, columnspan=4)
33+
34+
# Start the GUI main loop
35+
root.mainloop()

0 commit comments

Comments
 (0)