config rewrite. some extensions still need to be updated.
[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 import time
11 # now some "real" components:
12
13 class Clock(VariableText, HTMLComponent, GUIComponent):
14         def __init__(self):
15                 VariableText.__init__(self)
16                 GUIComponent.__init__(self)
17                 self.doClock()
18                 
19                 self.clockTimer = eTimer()
20                 self.clockTimer.timeout.get().append(self.doClock)
21
22         def onShow(self):
23                 self.doClock()
24                 self.clockTimer.start(1000)
25         
26         def onHide(self):
27                 self.clockTimer.stop()
28
29         def doClock(self):
30                 t = time.localtime()
31                 timestr = "%2d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec)
32                 self.setText(timestr)
33
34         def createWidget(self, parent):
35                 return eLabel(parent)
36
37         def removeWidget(self, w):
38                 del self.clockTimer
39
40         def produceHTML(self):
41                 return self.getText()