The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Task List GUI App in Python

A Task List GUI (Graphical User Interface) app in Python is a simple yet powerful project ideal for managing personal tasks efficiently. Below is a complete implementation using tkinter, Python’s built-in GUI toolkit. This app allows users to add, delete, and mark tasks as done, with a clean interface and persistent storage using a text file.

python
import tkinter as tk from tkinter import messagebox import os class TaskListApp: def __init__(self, root): self.root = root self.root.title("Task List App") self.root.geometry("400x500") self.root.resizable(False, False) self.task_file = "tasks.txt" self.tasks = [] self.create_widgets() self.load_tasks() def create_widgets(self): self.frame = tk.Frame(self.root) self.frame.pack(pady=10) self.task_entry = tk.Entry(self.frame, width=30, font=("Arial", 14)) self.task_entry.grid(row=0, column=0, padx=10) self.add_button = tk.Button(self.frame, text="Add Task", width=10, command=self.add_task) self.add_button.grid(row=0, column=1) self.task_listbox = tk.Listbox(self.root, height=20, width=45, font=("Arial", 12), selectbackground="lightblue") self.task_listbox.pack(pady=20) self.button_frame = tk.Frame(self.root) self.button_frame.pack() self.delete_button = tk.Button(self.button_frame, text="Delete Task", command=self.delete_task) self.delete_button.grid(row=0, column=0, padx=10) self.mark_done_button = tk.Button(self.button_frame, text="Mark as Done", command=self.mark_task_done) self.mark_done_button.grid(row=0, column=1, padx=10) self.clear_all_button = tk.Button(self.button_frame, text="Clear All", command=self.clear_all_tasks) self.clear_all_button.grid(row=0, column=2, padx=10) def add_task(self): task = self.task_entry.get().strip() if task: self.tasks.append(task) self.task_listbox.insert(tk.END, task) self.task_entry.delete(0, tk.END) self.save_tasks() else: messagebox.showwarning("Input Error", "Please enter a task.") def delete_task(self): try: selected_index = self.task_listbox.curselection()[0] task = self.task_listbox.get(selected_index) self.task_listbox.delete(selected_index) self.tasks.remove(task) self.save_tasks() except IndexError: messagebox.showwarning("Selection Error", "Please select a task to delete.") def mark_task_done(self): try: selected_index = self.task_listbox.curselection()[0] task = self.task_listbox.get(selected_index) if not task.startswith("[Done] "): task = "[Done] " + task self.tasks[selected_index] = task self.task_listbox.delete(selected_index) self.task_listbox.insert(selected_index, task) self.save_tasks() except IndexError: messagebox.showwarning("Selection Error", "Please select a task to mark as done.") def clear_all_tasks(self): confirm = messagebox.askyesno("Clear All", "Are you sure you want to clear all tasks?") if confirm: self.task_listbox.delete(0, tk.END) self.tasks.clear() self.save_tasks() def load_tasks(self): if os.path.exists(self.task_file): with open(self.task_file, "r") as file: for line in file: task = line.strip() if task: self.tasks.append(task) self.task_listbox.insert(tk.END, task) def save_tasks(self): with open(self.task_file, "w") as file: for task in self.tasks: file.write(task + "n") if __name__ == "__main__": root = tk.Tk() app = TaskListApp(root) root.mainloop()

Features:

  • Add Task: Users can input a new task using the entry box and add it to the list.

  • Delete Task: Selected tasks can be removed from the list.

  • Mark as Done: A selected task is prefixed with [Done] to indicate completion.

  • Clear All: Deletes all tasks after confirmation.

  • Persistent Storage: Tasks are stored in a tasks.txt file and automatically loaded on startup.

Requirements:

  • Python 3.x

  • No external libraries are needed since it uses tkinter, which comes with Python.

Customization Ideas:

  • Add deadlines or priorities.

  • Integrate calendar functionality.

  • Export task list to CSV.

  • Add dark mode or theme toggling.

This GUI app is an ideal beginner-to-intermediate project to learn Python GUI programming, file handling, and application design.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About