fix typo
[enigma2.git] / lib / python / Components / Clock.py
1 from HTMLComponent import *
2 from GUIComponent import *
3 from VariableText import *
4
5 #from enigma import eTimer
6 #from enigma import eLabel
7
8 from enigma import *
9
10 from config import config
11
12 import time
13 # now some "real" components:
14
15 class Clock(VariableText, HTMLComponent, GUIComponent):
16         def __init__(self):
17                 VariableText.__init__(self)
18                 GUIComponent.__init__(self)
19                 self.doClock()
20                 
21                 self.clockTimer = eTimer()
22                 self.clockTimer.timeout.get().append(self.doClock)
23
24         def onShow(self):
25                 self.doClock()
26                 self.clockTimer.start(1000)
27         
28         def onHide(self):
29                 self.clockTimer.stop()
30
31 # "funktionalitaet"     
32         def doClock(self):
33                 t = time.localtime()
34                 timestr = "%2d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec)
35                 self.setText(timestr)
36
37 # realisierung als GUI
38         def createWidget(self, parent):
39                 return eLabel(parent)
40
41         def removeWidget(self, w):
42                 del self.clockTimer
43
44 # ...und als HTML:
45         def produceHTML(self):
46         #       return T.b[self.getText()]
47                 return self.getText()