🐍 Lesson 44: To-Do List App (Python Project)
1. Project Overview
မြန်မာ → To-Do List App ဆိုတာ daily tasks တွေကို စုဆောင်းပြီး စီမံခန့်ခွဲနိုင်တဲ့ app ဖြစ်တယ်။ User က task အသစ်ထည့်နိုင်မယ်၊ ပြီးသွားတဲ့ task ကို ဖျက်နိုင်မယ်၊ မပြီးသေးတဲ့ task တွေကို စာရင်းအနေနဲ့ ပြနိုင်မယ်။
English → A To-Do List App helps users manage daily tasks by adding, viewing, and deleting tasks.
2. Why Build a To-Do List App?
- File storage သုံးပြီး data persist လုပ်နည်း လေ့ကျင့်နိုင်မယ်
- List, dictionary, loops, functions ကို practice လုပ်နိုင်မယ်
- CLI version နဲ့ GUI version နှစ်မျိုးလုံး စမ်းနိုင်မယ်
3. အကျဉ်းချုပ်
✅ To-Do List App = beginner-friendly + practical project
✅ CLI version → file storage + loops practice
✅ GUI version → Tkinter + listbox
✅ Error handling → invalid input, empty task
python
# ===== 1. File Storage Functions =====
import os
FILE_NAME = "tasks.txt"
def load_tasks():
if not os.path.exists(FILE_NAME):
return []
with open(FILE_NAME, "r") as f:
return [line.strip() for line in f]
def save_tasks(tasks):
with open(FILE_NAME, "w") as f:
for task in tasks:
f.write(task + "\n")
# ===== 2. Display Tasks =====
def show_tasks(tasks):
if not tasks:
print("No tasks yet!")
else:
for i, task in enumerate(tasks, 1):
print(f"{i}. {task}")
# ===== 3. Main To-Do List App =====
tasks = load_tasks()
print("===== To-Do List App =====")
print("Options: 1=Show, 2=Add, 3=Delete, 4=Quit\n")
# Simulated user interactions for demo
# In real app, use: choice = input("Choose: ")
# Example: Add tasks
tasks.append("Learn Python")
tasks.append("Build To-Do App")
save_tasks(tasks)
print("Tasks added!")
# Show tasks
print("\nCurrent Tasks:")
show_tasks(tasks)
# Example: Delete task
if len(tasks) > 0:
tasks.pop(0) # Remove first task
save_tasks(tasks)
print("\nAfter deletion:")
show_tasks(tasks)You should see
===== To-Do List App ===== Options: 1=Show, 2=Add, 3=Delete, 4=Quit Tasks added! Current Tasks: 1. Learn Python 2. Build To-Do App After deletion: 1. Build To-Do App