To-Do List App in Python (With Tkinter)

In this tutorial, we will build a simple To-Do List application using Python with a graphical user interface.

Users can add tasks, delete tasks, and manage their daily activities easily.

1. Requirements

Make sure Python is installed on your system.

Download Python: https://www.python.org/downloads/

2. Steps to Run the Project

Step 1: Install Python IDE.

Step 2: Copy and paste the code into your IDE.

Step 3: Run the program.

Step 4: Enter a task in the input box.

Step 5: Add or delete tasks using buttons.

3. Python Code

Python
To-Do List App using Tkinter
import tkinter as tk
from tkinter import messagebox


def add_task():
    task = entry.get()
    if task != "":
        listbox.insert(tk.END, task)
        entry.delete(0, tk.END)
    else:
        messagebox.showwarning("Warning", "Enter a task")


def delete_task():
    try:
        selected = listbox.curselection()[0]
        listbox.delete(selected)
    except:
        messagebox.showwarning("Warning", "Select a task to delete")


root = tk.Tk()
root.title("To-Do List")

entry = tk.Entry(root, width=40)
entry.pack(pady=10)

add_btn = tk.Button(root, text="Add Task", command=add_task)
add_btn.pack()

delete_btn = tk.Button(root, text="Delete Task", command=delete_task)
delete_btn.pack()

listbox = tk.Listbox(root, width=50)
listbox.pack(pady=10)

root.mainloop()

4. Output

A GUI window appears where users can manage tasks.

Tasks can be added and removed dynamically.

The list updates instantly based on user actions.

Conclusion

This project helps in understanding list handling and GUI interactions in Python.

It is a practical application useful for daily task management.