initial commit of my widget system. it is quite alpha, so please dont relay on the...
[enigma2-plugins.git] / widgets / src / widgets / counter / widget.py
1 from Plugins.Extensions.Widgets.Widget import Widget
2 from Components.Label import Label
3 from enigma import eTimer
4
5 class CounterWidget(Widget):
6     def __init__(self,session):
7         Widget.__init__(self,session,name="Simple Counter Widget",description="Example of a Widget with dynamicly changing Text",version="0.1",author="3c5x9",homepage="cvs://schwerkraft")
8         self.elements["counter_title"] = Label("0")
9         self.Timer = eTimer()
10         self.Timer.callback.append(self.TimerFire)
11         self.counter = 0
12        
13     def onLoadFinished(self,instance):
14         self.instance = instance
15         print "refresh CounterWidget"
16         
17         self.getElement("counter_title").setText("###")
18         self.Timer.start(200)
19         
20     def onClose(self):
21         self.Timer.stop()
22         
23     def TimerFire(self):
24         #print "TimerFire"
25         self.counter += 1
26         try:
27             self.getElement("counter_title").setText(str(self.counter))
28             self.Timer.start(200)
29         except Exception,e:
30             pass
31         
32 def get_widget(session):
33     return CounterWidget(session)