Skip to content

Commit 81a4473

Browse files
hello
1 parent 1347001 commit 81a4473

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed

todoapp/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# To-Do List Notebook
2+
3+
A simple to-do list application built with Python's Tkinter library, designed to look like a notebook page. Users can add tasks, mark them as complete, and delete completed tasks with ease.
4+
5+
## Features
6+
7+
- **Notebook-Styled UI**: The app has a light beige, lined background to resemble a notebook page.
8+
- **Add Tasks**: Add tasks using the `+` button.
9+
- **Delete Tasks**: Delete only tasks that are ticked as complete using the "Delete" button.
10+
- **Task Management**: Checkboxes allow users to mark tasks as completed, changing their appearance to indicate completion.
11+
12+
## Screenshot
13+
14+
![To-Do List Notebook Screenshot](assets/screenshot.png)
15+
16+
17+
## Requirements
18+
19+
- **Python 3.x**
20+
- **Tkinter** (Python's standard GUI library, usually included with Python)
21+
22+
## How to Run
23+
24+
1. Clone or download this repository.
25+
2. Open a terminal in the project folder.
26+
3. Run the following command:
27+
28+
```bash
29+
python todo_notebook.py
30+
```
31+
32+
4. The To-Do List Notebook app window should open.
33+
34+
## Code Overview
35+
36+
- **`add_task()`**: Adds a new task with a checkbox to mark it as completed.
37+
- **`toggle_complete()`**: Updates the checkbox color when a task is marked complete or incomplete.
38+
- **`delete_completed_tasks()`**: Deletes tasks that have been checked as completed.
39+
- **`update_task_list()`**: Refreshes the display of tasks.
40+
41+
## Customization
42+
43+
You can easily modify the app to fit your preferences by adjusting:
44+
- **Colors**: Modify the `button_color`, `button_hover_color`, or `notebook_color` variables to customize the theme.
45+
- **Fonts**: Change the `header_font` and `task_font` for different text styles.
46+
47+
## Known Issues
48+
49+
- **Limited Responsiveness**: The UI is best viewed at the specified window size (450x500) but may not scale perfectly on resizing.
50+
51+
## License
52+
53+
This project is open-source and available under the [MIT License](LICENSE).
54+
55+
## Acknowledgements
56+
57+
- **Tkinter**: For providing the GUI framework.
58+
- **Python Community**: For documentation and resources to build this app.
59+

todoapp/app.py

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import tkinter as tk
2+
from tkinter import messagebox, font
3+
4+
# Initialize the main app window
5+
app = tk.Tk()
6+
app.title("To-Do List Notebook")
7+
app.geometry("450x500")
8+
app.config(bg="#f0f4f8")
9+
10+
# Set custom fonts and colors
11+
header_font = font.Font(family="Helvetica", size=18, weight="bold")
12+
task_font = font.Font(family="Arial", size=12)
13+
button_color = "#4CAF50"
14+
button_hover_color = "#45a049"
15+
task_complete_color = "#2e8b57"
16+
notebook_color = "#FFF8DC" # Light beige to mimic a notebook page
17+
18+
# Task list to hold tasks
19+
todo_list = []
20+
21+
# Functions to manage tasks
22+
def add_task():
23+
"""Add a new task with a checkbox to mark as completed."""
24+
task_text = entry_task.get()
25+
if task_text:
26+
task_var = tk.BooleanVar()
27+
task_frame = tk.Frame(task_list_frame, bg=notebook_color, padx=5, pady=3)
28+
29+
checkbox = tk.Checkbutton(
30+
task_frame,
31+
text=task_text,
32+
variable=task_var,
33+
command=lambda: toggle_complete(task_var, checkbox),
34+
font=task_font,
35+
bg=notebook_color,
36+
fg="black",
37+
selectcolor="white",
38+
activeforeground=button_color
39+
)
40+
41+
checkbox.pack(anchor="w", pady=2)
42+
todo_list.append({"task": task_text, "completed": task_var, "frame": task_frame})
43+
task_frame.pack(anchor="w", padx=10, pady=5, fill="x")
44+
entry_task.delete(0, tk.END)
45+
else:
46+
messagebox.showwarning("Input Error", "Please enter a task!")
47+
48+
def toggle_complete(task_var, checkbox):
49+
"""Update the checkbox color when the task is marked complete or incomplete."""
50+
if task_var.get():
51+
checkbox.config(fg=task_complete_color, font=task_font)
52+
else:
53+
checkbox.config(fg="black", font=task_font)
54+
55+
def delete_completed_tasks():
56+
"""Delete only ticked tasks from the list."""
57+
global todo_list
58+
for task in todo_list[:]:
59+
if task["completed"].get():
60+
task["frame"].destroy()
61+
todo_list.remove(task)
62+
update_task_list()
63+
64+
def update_task_list():
65+
"""Refresh the display of tasks."""
66+
for widget in task_list_frame.winfo_children():
67+
widget.destroy()
68+
for task in todo_list:
69+
task["frame"].pack(anchor="w", padx=10, pady=5, fill="x")
70+
71+
def on_hover(button, color):
72+
"""Change button color on hover."""
73+
button.config(bg=color)
74+
75+
# Header
76+
header = tk.Label(app, text="My Notebook To-Do List", font=header_font, bg="#f0f4f8", fg=button_color)
77+
header.pack(pady=10)
78+
79+
# Notebook look-alike frame for tasks with lines
80+
task_list_frame = tk.Canvas(app, bg=notebook_color, bd=0, highlightthickness=0)
81+
task_list_frame.pack(expand=True, fill="both", padx=15, pady=10)
82+
83+
# Draw lines to mimic notebook paper
84+
for i in range(0, 500, 20):
85+
task_list_frame.create_line(10, i, 440, i, fill="#d3d3d3")
86+
87+
# Frame for entry, add, and delete buttons
88+
frame_task = tk.Frame(app, bg="#f0f4f8")
89+
frame_task.pack(pady=15)
90+
91+
# Entry for new tasks
92+
entry_task = tk.Entry(frame_task, width=30, font=task_font, relief="solid", bd=1)
93+
entry_task.pack(side=tk.LEFT, padx=10)
94+
95+
# "+" button for adding tasks
96+
button_add_task = tk.Button(frame_task, text="+", command=add_task, font=("Arial", 20, "bold"), bg=button_color, fg="white",
97+
relief="flat", width=3, height=1)
98+
button_add_task.pack(side=tk.LEFT)
99+
button_add_task.bind("<Enter>", lambda e: on_hover(button_add_task, button_hover_color))
100+
button_add_task.bind("<Leave>", lambda e: on_hover(button_add_task, button_color))
101+
102+
# Delete button for deleting only completed tasks
103+
button_delete_task = tk.Button(app, text="Delete completed task", command=delete_completed_tasks, font=task_font,
104+
bg=button_color, fg="white", relief="flat", padx=10, pady=5)
105+
button_delete_task.pack(pady=10)
106+
button_delete_task.bind("<Enter>", lambda e: on_hover(button_delete_task, button_hover_color))
107+
button_delete_task.bind("<Leave>", lambda e: on_hover(button_delete_task, button_color))
108+
109+
# Run the main loop
110+
app.mainloop()

todoapp/assets/app.png

28.6 KB
Loading

0 commit comments

Comments
 (0)