Hey guys. I have to create an alarm clock in python. i really really need some help in creating this thing.. seeing that i have absolutely no clue what i am doing. I have found some basic code that supposedly makes a clock which updates but the bleeeding thing just wont update... it just shows the current time. and then i have been fiddling about and got another program which can make the alarm noise and a snooze button. no idea how to link them together. any help would be top notch! code beneath.
And also pls tell me to bugger off if i am being a bit of a knob. thx

Funny button that beeps! as follows!

class Alarm(Frame):
def repeater(self): # on every N millisecs
self.bell() # beep now
self.stopper.flash() # flash button now
self.after(self.msecs, self.repeater) # reschedule handler
def __init__(self, msecs=1000): # default = 1 second
Frame.__init__(self)
self.msecs = msecs
self.pack()
stopper = Button(self, text='~Snooze~', command=self.quit)
stopper.pack()
stopper.config(bg='navy', fg='white', bd=8)
self.stopper = stopper
self.repeater()

if __name__ == '__main__': Alarm(msecs=1000).mainloop()

and now silly clock code that doesn't seem to work.


from Tkinter import *

import time

root = Tk()

time1 = ''

clock = Label(root, font=('ariel', 25, 'bold'), bg='grey')

clock.pack(fill=BOTH, expand=1)


def updatetime():

global time1

# get the current local time from the PC

time2 = time.strftime('%H:%M:%S')

# if time string has changed, update it

if time2 != time1:

time1 = time2

clock.config(text=time2)

# calls itself every 200 milliseconds

# to update the time display as needed

# could use >200 ms, but display gets jerky

clock.after(200, updatetime)

updatetime()

root.mainloop( )

Please use code tags with your code to preserve the indentations. Otherwise the code is very difficult to read and not too many folks will help.

[code=python]
your Python code here

[/code]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.