Featured
- Get link
- X
- Other Apps
Python Code for " To-Do List " using " TKinter " GUI library. Computer Science project
HERE'S A PYTHON CODE FOR A To-Do LIST USING THE TKINTER GUI LIBRARY:
SOURCE CODE-
import tkinter as tk
class ToDoList:
def __init__(self):
self.tasks = []
# Create the main window
self.root = tk.Tk()
self.root.title("To-Do List")
# Create the listbox to display the tasks
self.task_list = tk.Listbox(self.root)
self.task_list.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
# Create the entry widget and the "Add Task" button
self.entry = tk.Entry(self.root)
self.entry.pack(side=tk.TOP, fill=tk.BOTH)
add_button = tk.Button(self.root, text="Add Task", command=self.add_task)
add_button.pack(side=tk.TOP)
# Create the "Delete Task" button
delete_button = tk.Button(self.root, text="Delete Task", command=self.delete_task)
delete_button.pack(side=tk.TOP)
# Start the main loop
self.root.mainloop()
def add_task(self):
# Add the task to the list and the listbox
task = self.entry.get()
if task:
self.tasks.append(task)
self.task_list.insert(tk.END, task)
self.entry.delete(0, tk.END)
def delete_task(self):
# Delete the selected task from the list and the listbox
selected_tasks = self.task_list.curselection()
for task_index in reversed(selected_tasks):
del self.tasks[task_index]
self.task_list.delete(task_index)
if __name__ == '__main__':
ToDoList()
DESCRIPTION:
This code creates a GUI window using the Tkinter library. The to-do list is displayed in a Listbox widget, and there is an Entry widget and a "Add Task" button for adding new tasks to the list. The user can select tasks in the list and then click the "Delete Task" button to remove them. When a task is added or deleted, the program updates both the tasks list and the Listbox widget.
- Get link
- X
- Other Apps
Popular Posts
Python code for " Simple Calculator " . Computer science project
- Get link
- X
- Other Apps
Python Code for " To-Do List ". Computer Science project for BEGINNER
- Get link
- X
- Other Apps

Comments
Post a Comment