Skip to content

Commit 9693164

Browse files
authored
Merge pull request #71 from RithwikBejadi/main
To-Do List Folder Addition
2 parents 7aa5b80 + a108ed6 commit 9693164

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

To Do List/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# To-Do List App
2+
3+
This is a simple To-Do List app built with Python using `tkinter` for the user interface and `sqlite3` for data storage.
4+
5+
## Features
6+
7+
- Add tasks
8+
- View tasks
9+
- Delete tasks
10+
- Save tasks to database
11+
12+
## Requirements
13+
14+
- Python 3.8.10
15+
- `tkinter`
16+
- `sqlite3`
17+
18+
## Installation
19+
20+
1. Clone the repository:
21+
```bash
22+
git clone <repository-url>

To Do List/main.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from tkinter import *
2+
import sqlite3
3+
4+
root = Tk()
5+
root.title("To-Do List App")
6+
root.geometry("400x400")
7+
8+
conn = sqlite3.connect('todolist.db')
9+
c = conn.cursor()
10+
11+
# Create table
12+
c.execute('''CREATE TABLE IF NOT EXISTS tasks
13+
(id INTEGER PRIMARY KEY, task TEXT NOT NULL)''')
14+
15+
def add_task():
16+
task = task_entry.get()
17+
if task:
18+
c.execute("INSERT INTO tasks (task) VALUES (?)", (task,))
19+
conn.commit()
20+
task_entry.delete(0, END)
21+
populate_tasks()
22+
23+
def delete_task():
24+
task_id = task_list.get(ACTIVE).split('.')[0]
25+
c.execute("DELETE FROM tasks WHERE id=?", (task_id,))
26+
conn.commit()
27+
populate_tasks()
28+
29+
def populate_tasks():
30+
task_list.delete(0, END)
31+
c.execute("SELECT * FROM tasks")
32+
tasks = c.fetchall()
33+
for task in tasks:
34+
task_list.insert(END, f"{task[0]}. {task[1]}")
35+
36+
# Task entry
37+
task_entry = Entry(root, width=50)
38+
task_entry.pack(pady=10)
39+
40+
# Add task button
41+
add_task_button = Button(root, text="Add Task", command=add_task)
42+
add_task_button.pack(pady=5)
43+
44+
# Task list
45+
task_list = Listbox(root, width=50, height=15)
46+
task_list.pack(pady=10)
47+
48+
# Delete task button
49+
delete_task_button = Button(root, text="Delete Task", command=delete_task)
50+
delete_task_button.pack(pady=5)
51+
52+
# Populate tasks on startup
53+
populate_tasks()
54+
55+
# Run the main loop
56+
root.mainloop()
57+
58+
conn.close()

To Do List/requirement.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tk
2+
sqlite3

To Do List/runtime.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-3.8.10

0 commit comments

Comments
 (0)