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