add blinking dish-picture if positioner is moving (we need a function which returns...
[enigma2.git] / lib / python / Components / BlinkingPixmap.py
1 from Pixmap import *
2
3 from enigma import *
4
5 import time
6
7 class BlinkingPixmap(Pixmap):
8         def __init__(self):
9                 Pixmap.__init__(self)
10                 
11                 self.blinking = True
12                 
13                 self.setBlinkTime(500)
14
15                 self.timer = eTimer()
16                 self.timer.timeout.get().append(self.blink)
17         
18         def setBlinkTime(self, time):
19                 self.blinktime = time
20                 
21         def blink(self):
22                 if self.blinking == True:
23                         if (self.state == self.SHOWN):
24                                 self.hidePixmap()
25                         elif (self.state == self.HIDDEN):
26                                 self.showPixmap()
27                         
28         def startBlinking(self):
29                 self.blinking = True
30                 self.timer.start(self.blinktime)
31                 
32         def stopBlinking(self):
33                 self.blinking = False
34                 if (self.state == self.SHOWN):
35                         self.hidePixmap()
36                 self.timer.stop()
37                 
38 class BlinkingPixmapConditional(BlinkingPixmap, PixmapConditional):
39         def __init__(self):
40                 BlinkingPixmap.__init__(self)
41                 PixmapConditional.__init__(self)
42                 
43         def activateCondition(self, condition):
44                 if (condition):
45                         if not self.blinking: # we are already blinking
46                                 self.startBlinking()
47                 else:
48                         if self.blinking: # we are blinking
49                                 self.stopBlinking()