For some strange reason I felt the urge to build something in Python on Thursday.
I am not really sure what brought it on, I guess its just one of those random things. I thought about trying to do two new things. First I wanted to use a timer and second I wanted to try and get a system beep. The best way I could think of combining these two elements would be to build a countdown timer that produces a beep when the time is up.
Here is the code for you to look at:
#!/usr/bin/python
import time
import threadingmsg = ’Input Time In Minutes: ’
uin = raw_input(msg).strip()
intSecAsMin= int(uin) * 60class Timer(threading.Thread):
def __init__(self, seconds):
self.runTime = seconds
threading.Thread.__init__(self)
def run(self):
time.sleep(self.runTime)
print ’\a’
print ”Time Up!”t = Timer(intSecAsMin)
t.start()
Sadly the beep part is not working. I have tried one or two things but nothing seems to work. I have also started a thread on Ubuntu Forums seeking help. I am beginning to think the only way to produce an audio alert would be to have the python script play an mp3 file. Not quite what I am after but an alternative. Still, its been a fun little program I wrote for no particular reason. Learnt one or two things, so not a complete waste of time.
Edit: WordPress seems to have messed up the indintation and consiquently the code will now not run without some adjustments.

