- split of Components into different files
[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 import time
9 # now some "real" components:
10
11 class Clock(HTMLComponent, GUIComponent, VariableText):
12         def __init__(self):
13                 VariableText.__init__(self)
14                 GUIComponent.__init__(self)
15                 self.doClock()
16                 
17                 self.clockTimer = eTimer()
18                 self.clockTimer.timeout.get().append(self.doClock)
19                 self.clockTimer.start(1000)
20
21 # "funktionalitaet"     
22         def doClock(self):
23                 t = time.localtime()
24                 self.setText("%2d:%02d:%02d" % (t[3], t[4], t[5]))
25
26 # realisierung als GUI
27         def createWidget(self, parent, skindata):
28                 return eLabel(parent)
29
30         def removeWidget(self, w):
31                 del self.clockTimer
32
33 # ...und als HTML:
34         def produceHTML(self):
35                 return self.getText()
36