I'm writing a simple to-do list program with Tkinter and I've ran in a problem: the "Add task" button doesn't do anything! Please tell me what's wrong with my program and how to fix it. Here's the code:
import tkinter as tk
tasks = ["Enter a new task...", "Enter a new task...", "Enter a new task..."]
window = tk.Tk()
title = tk.Label(text="To-Do List")
t0 = tk.Label(text=tasks[0])
t1 = tk.Label(text=tasks[1])
t2 = tk.Label(text=tasks[2])
def addTask():
count = 0
tasks[count] = newTask.get()
count += 1
if count == 3:
count = 0
newTask = tk.Entry()
newTaskButton = tk.Button(text="Add task", command=addTask())
t0.pack()
t1.pack()
t2.pack()
newTask.pack()
newTaskButton.pack()
window.mainloop()