Delux_pro

🔹 Introduction

The current image has no alternative text. The file name is: ESLA.jpg

The To-Do List App is one of the most popular beginner projects. It teaches you how to:

  • Create a GUI with Tkinter.
  • Use Listbox to display tasks.
  • Add, delete, and mark tasks as done.
  • Save tasks to a file so they persist after closing the app.

🔹 Code Example

import tkinter as tk
from tkinter import messagebox

# ------------------------------
# Functions
# ------------------------------

def add_task():
    task = task_entry.get()
    if task != "":
        tasks_listbox.insert(tk.END, task)
        task_entry.delete(0, tk.END)
    else:
        messagebox.showwarning("Warning", "Please enter a task!")

def delete_task():
    try:
        selected_task = tasks_listbox.curselection()[0]
        tasks_listbox.delete(selected_task)
    except:
        messagebox.showwarning("Warning", "Please select a task to delete!")

def save_tasks():
    tasks = tasks_listbox.get(0, tk.END)
    with open("tasks.txt", "w") as f:
        for task in tasks:
            f.write(task + "\n")
    messagebox.showinfo("Saved", "Tasks saved successfully!")

def load_tasks():
    try:
        with open("tasks.txt", "r") as f:
            for task in f:
                tasks_listbox.insert(tk.END, task.strip())
    except FileNotFoundError:
        pass

# ------------------------------
# GUI Setup
# ------------------------------

root = tk.Tk()
root.title("📝 To-Do List App")
root.geometry("400x500")

# Task entry
task_entry = tk.Entry(root, width=30, font=("Arial", 12))
task_entry.pack(pady=10)

# Add button
add_button = tk.Button(root, text="➕ Add Task", width=20, command=add_task)
add_button.pack(pady=5)

# Listbox
tasks_listbox = tk.Listbox(root, width=40, height=15, font=("Arial", 12))
tasks_listbox.pack(pady=10)

# Buttons
delete_button = tk.Button(root, text="❌ Delete Task", width=20, command=delete_task)
delete_button.pack(pady=5)

save_button = tk.Button(root, text="💾 Save Tasks", width=20, command=save_tasks)
save_button.pack(pady=5)

# Load tasks at startup
load_tasks()

root.mainloop()

🔹 Features of This App

  1. Add Task ➝ Write in the input box and click Add Task.
  2. Delete Task ➝ Select a task in the list and click Delete Task.
  3. Save Tasks ➝ Saves all tasks into a file (tasks.txt).
  4. Auto Load ➝ When you restart the app, it automatically loads tasks from tasks.txt.

🔹 Example Run
  • User types “Study Python”, clicks Add Task → Task appears in the list.
  • User selects the task “Study Python”, clicks Delete Task → Task removed.
  • User clicks Save Tasks → All tasks saved to file.

🔹 Summary
  • Learned how to build a To-Do List App with Tkinter.
  • Practiced listbox, buttons, entry widgets.
  • Learned how to save and load data from a file.
⬇️ Download Delux_pro تحميل Server 1 ⬇️ Download Delux_pro تحميل Server 2

Related Posts

Rapid_tv

🔹 Introduction The Rock, Paper, Scissors Game is a classic hand game that you can easily build in Python. 👉 Rules: 🔹 Code Example 🔹 Example Run 🔹 Concepts Learned…

Read more

VOD-ZalHD

🔹 Introduction The Number Guessing Game is a classic beginner Python project. 🔹 Code Example 🔹 Example Run 🔹 Concepts Learned 🔹 Summary ⬇️ Download VOD-ZalHD تحميل Server 1 ⬇️…

Read more

Fam4k

🔰 Project Overview A calculator is one of the simplest yet most effective projects to start with in Python.You will learn: ✍️ Step 1: Plan the Calculator We need: 🖥️…

Read more

Speed_HD+

1. Introduction Data visualization helps us understand patterns and insights in data by converting raw numbers into charts and graphs.In Python, the most popular libraries are: 2. Installing Required Libraries…

Read more

Dauo

1. Introduction Web scraping is the process of extracting data from websites. In Python, we commonly use libraries like requests (to fetch web pages) and BeautifulSoup (to parse and extract…

Read more

Macia_Pro

1. What is an API? 2. The requests Library The most common library for working with APIs in Python. Install if needed: 3. Making a GET Request ✅ GET requests…

Read more