Python3

Python script: Todo List with GUI (using Tkinter or PyQt)


# Import the necessary libraries
import tkinter as tk

# Create the main application window
root = tk.Tk()
root.title("Todo List")

# Add a label for the title
title_label = tk.Label(root, text="My Todo List", font=("Helvetica", 16))
title_label.pack(pady=10)

# Create a listbox to display the tasks
tasks_list = tk.Listbox(root, width=50)
tasks_list.pack(padx=10, pady=10)

# Create an entry for the user to input tasks
task_entry = tk.Entry(root, width=40)
task_entry.pack(padx=10, pady=10)

# Function to add a new task to the list
def add_task():
task = task_entry.get()
if task:
tasks_list.insert(tk.END, task)
task_entry.delete(0, tk.END)

# Create a button to add tasks
add_button = tk.Button(root, text="Add Task", width=10, command=add_task)
add_button.pack(pady=10)

# Function to remove the selected task from the list
def remove_task():
selected_task = tasks_list.curselection()
tasks_list.delete(selected_task)

# Create a button to remove tasks
remove_button = tk.Button(root, text="Remove Task", width=10, command=remove_task)
remove_button.pack(pady=10)

# Run the main application loop
root.mainloop()

This Python script creates a simple Todo List application with a graphical user interface (GUI) using the Tkinter library. The application window includes a title label, a listbox to display tasks, an entry for users to input new tasks, buttons to add and remove tasks, and functionality to interact with the task list.

When the script is executed, a window titled “Todo List” will open. Users can type a task into the entry field and click the “Add Task” button to add it to the list. Tasks can be removed by selecting them in the list and clicking the “Remove Task” button.

This GUI application provides a basic implementation of a Todo List and can be further customized and enhanced based on specific requirements.