I'm quite new to python programming and I was attempting to create a countdown timer. I wrote down the following code for the timer but it's not working. Can you help in figuring out where the error is? (I did a bit of research on this site and found a few questions relating to timers. In fact most of this code is written based on another answer but I did some changes to it because that code was for a clock and I'm trying to make a timer.)
from tkinter import *
from tkinter import messagebox
class alarmclock():
def __init__(self):
self.alarm = Tk()
self.l0 = Label(self.alarm, text = '----------- Alarm clock 1 -----------')
self.l1 = Label(self.alarm, text = 'Please type in the time:')
self.e0 = Entry(self.alarm)
self.l2 = Label(self.alarm)
self.b0 = Button(self.alarm, text = 'Start countdown', command = lambda: self.timer)
self.l0.grid(row = 0, column = 0, columnspan = 2)
self.l1.grid(row = 1, column = 0, padx = 10, pady =5)
self.e0.grid(row = 1, column = 1, padx = 10)
self.l2.grid(row = 2, column = 1, padx = 10)
self.b0.grid(row = 3, column = 0, columnspan = 2, pady = 5)
self.alarm.mainloop()
def timer(self):
self.b = float(self.e0.get())
self.l2.configure(text = str(self.b))
self.b-=1
if self.b != 0:
self.alarm.after(1000, self.timer)
if self.b == 0:
self.l2.configure(text = str(self.b))
self.messagebox.showwarning('Alarm Clock', 'Time\'s up!')
command = lambda: self.timer()thencommand = self.timer. Note the lack of parentheses.self.b = float(self.e0.get())....check your logic.