Ok, I've been doing some tutorials on python and today decided to type in the code for an led clock. This isn't my code, I am just trying to get familiar with python, so I retyped the code line for line, but the thing is when I try to run it I get absolutely no errors, yet nothing happens.
Any ideas what could be wrong?
here is the code:
Code:
# use the wxPython LEDNumberCtrl widget for nice LED clock
# Python25 and wxPython28 by HAB 07/30/2007
#! /usr/bin/python
import time
import wx
import wx.gizmos as gizmos
class LED_clock(wx.Frame):
"""
create nice LED clock showing the current time
"""
def __init__(self, parent, id):
pos = wx.DefaultPosition
wx.Frame.__init__(self, parent, id, title='LED Clock' , pos=pos,
size=(350, 100))
size = wx.DefaultSize
style = gizmos.LED_ALIGN_CENTER
self.led = gizmos.LEDNumberCtrl(self, -1, pos, size, style)
# default colors are green on black
self.led.SetBackgroundColour("blue")
self.led.SetForegroundColour("yellow")
self.OnTimer(none)
self.timer = wx.Timer(self, -1)
# update clock digits every second (1000ms)
self.timer.Start(1000)
self.Bind(wx.EVT_TIMER, self.OnTimer)
#self.Centre()
def OnTimer(self, event):
#get current time from computer
current = time.localtime(time.time())
# time string can have characters 0..9, -, period, or space
ts = time.strftime("%H %M %S", current)
self.led.SetValue(ts)
#test the clock
if __name__ == '__main__':
app = wx.App()
frame = LED_clock(none, -1)
frame.Show(true)
app.SetTopWindow(frame)
app.MainLoop()
Bookmarks