To-Do List App using Tkinter in Python
Abstract
This document details the design and implementation of a To-Do List desktop app using
Python's Tkinter GUI library.
Source Code
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", "Please 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)
listbox = tk.Listbox(root, width=40)
listbox.pack(pady=10)
add_button = tk.Button(root, text="Add Task", command=add_task)
add_button.pack(pady=5)
delete_button = tk.Button(root, text="Delete Task", command=delete_task)
delete_button.pack(pady=5)
root.mainloop()