Skip to content

Commit ae165e8

Browse files
The required changes are done
1 parent 8546cdf commit ae165e8

File tree

4 files changed

+106
-5
lines changed

4 files changed

+106
-5
lines changed

CapCut.lnk

1.34 KB
Binary file not shown.

To Do App/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
**#To-Do List Application**
2+
A simple and intuitive To-Do List application built with Python's Tkinter library for the GUI and SQLite for persistent task storage. This application helps you manage tasks with categories, due dates, and priority levels, allowing easy organization of daily activities.
3+
4+
**Features**
5+
6+
Add Tasks: Add tasks with a description, category, due date, and priority level (High, Medium, Low).
7+
8+
View Tasks: View all tasks, or filter tasks to see only completed or pending ones.
9+
10+
Search Tasks: Quickly search tasks by their name or category using the search bar.
11+
12+
Toggle Theme: Switch between dark and light themes to match your preference.
13+
14+
Mark Tasks as Complete: Mark tasks as completed to keep track of what’s done.
15+
16+
Persistent Storage: All tasks are saved in an SQLite database, ensuring data is saved even after closing the app.
17+
18+
19+
**Prerequisites**
20+
21+
Python 3.6+
22+
Tkinter (Usually included with Python)
23+
SQLite (Included in Python’s standard library)
24+
tkcalendar: Install using pip install tkcalendar
25+
26+
**Usage Instructions**
27+
28+
1. Add a Task
29+
Enter a task description in the Task field.
30+
Specify the Category for better organization.
31+
Select a Due Date from the date picker.
32+
Choose a Priority from the drop-down menu (High, Medium, Low).
33+
Click Add Task to save it.
34+
35+
2. View All Tasks
36+
Click on View All Tasks in the sidebar to display a list of all tasks.
37+
Tasks are displayed with their description, category, due date, and priority level.
38+
39+
3. View Completed Tasks
40+
Click View Completed Tasks in the sidebar to see tasks that have been marked as complete.
41+
42+
4. View Pending Tasks
43+
Click View Pending Tasks in the sidebar to view tasks that are yet to be completed.
44+
45+
5. Search Tasks
46+
Use the Search bar in the sidebar to find tasks by their description or category.
47+
The list of tasks will update as you type, showing only those that match the search term.
48+
49+
6. Mark Tasks as Complete
50+
Select a task from the list and click Mark as Complete (add this button in your application).
51+
Completed tasks will no longer appear in the pending tasks view.
52+
53+
7. Toggle Dark/Light Theme
54+
Click Toggle Theme in the sidebar to switch between dark and light modes.
55+
This changes the background color, text color, and button styles for a better visual experience.
56+
57+
8. Close the Application
58+
Close the application by clicking the window close button (X) or selecting Exit.
59+
The application safely saves your tasks and closes the database connection.
60+
61+
62+
**Database Structure**
63+
The application uses an SQLite database with the following table structure:
64+
65+
Table Name: tasks
66+
67+
Column Name Type Description
68+
69+
id INTEGER Primary key, unique task ID
70+
task TEXT Description of the task
71+
category TEXT Category of the task (e.g., Work, Home)
72+
due_date TEXT Due date of the task
73+
priority TEXT Priority level (High, Medium, Low)
74+
completed INTEGER Status (0 = Pending, 1 = Completed)
75+
76+
**License**
77+
This project is licensed under the MIT License. See the LICENSE file for details.
78+
79+
**Acknowledgments**
80+
Thanks to the Python community for their extensive libraries and documentation.
81+
Special thanks to the creators of tkcalendar for providing a simple date picker widget for Tkinter.

ToDoAppTkInter/To_Do_AppTkInter.py renamed to To Do App/To_Do_AppTkInter.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class TodoApp:
77
def __init__(self, root):
88
self.root = root
9-
self.root.title("Advanced To-Do List")
9+
self.root.title("To-Do List App")
1010
self.root.geometry("900x600")
1111

1212
# Initialize attributes
@@ -25,6 +25,9 @@ def __init__(self, root):
2525
self.create_sidebar()
2626
self.load_tasks()
2727

28+
# Bind the window close event to close the database connection
29+
self.root.protocol("WM_DELETE_WINDOW", self.close_app)
30+
2831
def create_sidebar(self):
2932
"""Create the sidebar with navigation options."""
3033
tk.Label(self.sidebar_frame, text="Menu", font=("Helvetica", 16), bg="#3A3A3A", fg="#FFFFFF").pack(pady=10)
@@ -110,6 +113,7 @@ def toggle_theme(self):
110113
def create_database(self):
111114
"""Create the tasks table if it doesn't exist."""
112115
self.conn = sqlite3.connect("tasks.db")
116+
# Create the table if it doesn't exist yet
113117
with self.conn:
114118
self.conn.execute("""
115119
CREATE TABLE IF NOT EXISTS tasks (
@@ -157,53 +161,69 @@ def create_widgets(self):
157161
self.task_listbox.pack(pady=10, padx=20, fill=tk.BOTH, expand=True)
158162

159163
def load_tasks(self):
160-
"""Load all tasks from the database."""
164+
"""Load all pending tasks from the database."""
161165
self.task_listbox.delete(0, tk.END)
162166
cursor = self.conn.cursor()
167+
# Retrieve tasks that are not yet completed (completed=0)
163168
cursor.execute("SELECT * FROM tasks WHERE completed=0")
164169
for row in cursor.fetchall():
170+
# Format the task details for display in the listbox
165171
self.task_listbox.insert(tk.END, f"{row[1]} | {row[2]} | Due: {row[3]} | Priority: {row[4]}")
166172

167173
def load_completed_tasks(self):
168-
"""Load completed tasks."""
174+
"""Load completed tasks from the database."""
169175
self.task_listbox.delete(0, tk.END)
170176
cursor = self.conn.cursor()
177+
# Retrieve tasks that are marked as completed (completed=1)
171178
cursor.execute("SELECT * FROM tasks WHERE completed=1")
172179
for row in cursor.fetchall():
173180
self.task_listbox.insert(tk.END, f"{row[1]} | {row[2]} | Due: {row[3]} | Priority: {row[4]}")
174181

175182
def load_pending_tasks(self):
176183
"""Load pending tasks."""
184+
# Reuse the load_tasks method since it already loads pending tasks
177185
self.load_tasks()
178186

179187
def add_task(self):
180-
"""Add a new task."""
188+
"""Add a new task to the database."""
181189
task = self.task_entry.get()
182190
category = self.category_entry.get()
183191
due_date = self.due_date_entry.get()
184192
priority = self.priority_var.get()
185193

194+
# Validate that required fields are filled
186195
if task and category and due_date:
187196
with self.conn:
197+
# Insert a new task into the database
188198
self.conn.execute("INSERT INTO tasks (task, category, due_date, priority) VALUES (?, ?, ?, ?)",
189199
(task, category, due_date, priority))
200+
# Refresh the task list to show the new entry
190201
self.load_tasks()
202+
# Clear the input fields after adding the task
191203
self.task_entry.delete(0, tk.END)
192204
self.category_entry.delete(0, tk.END)
193205
else:
194206
messagebox.showwarning("Input Error", "Please fill all fields.")
195207

196208
def search_tasks(self, event):
197-
"""Search tasks based on input."""
209+
"""Search tasks based on input in the search bar."""
198210
query = self.search_entry.get().lower()
199211
self.task_listbox.delete(0, tk.END)
200212
cursor = self.conn.cursor()
213+
# Retrieve all tasks and filter by the search query
201214
cursor.execute("SELECT * FROM tasks WHERE completed=0")
202215
for row in cursor.fetchall():
203216
task_str = f"{row[1]} | {row[2]} | Due: {row[3]} | Priority: {row[4]}"
217+
# Display only tasks that match the search query
204218
if query in task_str.lower():
205219
self.task_listbox.insert(tk.END, task_str)
206220

221+
def close_app(self):
222+
"""Close the database connection and exit the application."""
223+
if self.conn:
224+
self.conn.close()
225+
self.root.destroy()
226+
207227
if __name__ == "__main__":
208228
root = tk.Tk()
209229
app = TodoApp(root)
File renamed without changes.

0 commit comments

Comments
 (0)