Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To do list gui #2039

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Mini-Projects/Python/to-do-list-app-gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import tkinter as tk
from tkinter import messagebox

# Functionality to add tasks
def add_task():
task = entry_task.get()
if task != "":
listbox_tasks.insert(tk.END, task)
entry_task.delete(0, tk.END)
else:
messagebox.showwarning("Input Error", "Please enter a task.")

# Functionality to delete selected task
def delete_task():
try:
task_index = listbox_tasks.curselection()[0]
listbox_tasks.delete(task_index)
except:
messagebox.showwarning("Selection Error", "Please select a task to delete.")

# Functionality to mark a task as completed
def mark_done():
try:
task_index = listbox_tasks.curselection()[0]
task = listbox_tasks.get(task_index)
listbox_tasks.delete(task_index)
listbox_tasks.insert(tk.END, task + " (Completed)")
except:
messagebox.showwarning("Selection Error", "Please select a task to mark as completed.")

# Setting up the main application window
window = tk.Tk()
window.title("To-Do List App")

# Task entry widget
entry_task = tk.Entry(window, width=35)
entry_task.pack(pady=10)

# Add task button
button_add_task = tk.Button(window, text="Add Task", width=40, command=add_task)
button_add_task.pack(pady=5)

# Listbox to display tasks
listbox_tasks = tk.Listbox(window, width=40, height=10)
listbox_tasks.pack(pady=10)

# Buttons to delete or mark tasks as completed
button_delete_task = tk.Button(window, text="Delete Task", width=40, command=delete_task)
button_delete_task.pack(pady=5)

button_mark_done = tk.Button(window, text="Mark as Completed", width=40, command=mark_done)
button_mark_done.pack(pady=5)

# Running the GUI loop
window.mainloop()