fix something
[enigma2.git] / lib / python / Components / ConditionalWidget.py
index eec5b4360a8a4b903cf8f8c46cf50f47c4d35770..3d855b2728e5dc694277aa030576851d7a5fa4ef 100644 (file)
@@ -40,7 +40,7 @@ class ConditionalWidget(Widget):
                if (withTimer):
                        self.conditionCheckTimer = eTimer()
                        self.conditionCheckTimer.timeout.get().append(self.update)
                if (withTimer):
                        self.conditionCheckTimer = eTimer()
                        self.conditionCheckTimer.timeout.get().append(self.update)
-                       self.conditionCheckTimer.start(1000)
+                       self.conditionCheckTimer.start(500)
                
        def setConnect(self, conditionalFunction):
                self.conditionalFunction = conditionalFunction
                
        def setConnect(self, conditionalFunction):
                self.conditionalFunction = conditionalFunction
@@ -48,19 +48,66 @@ class ConditionalWidget(Widget):
        def activateCondition(self, condition):
                if (condition):
                        if (self.state == self.HIDDEN):
        def activateCondition(self, condition):
                if (condition):
                        if (self.state == self.HIDDEN):
-                               print "update: " + str(self) + " SHOW"
                                self.showWidget()
                else:
                        if (self.state == self.SHOWN):
                                self.showWidget()
                else:
                        if (self.state == self.SHOWN):
-                               print "update: " + str(self) + " HIDE"
                                self.hideWidget()
 
        def update(self):
                if (self.conditionalFunction != None):
                        try:
                                self.conditionalFunction() # check, if the conditionalfunction is still valid
                                self.hideWidget()
 
        def update(self):
                if (self.conditionalFunction != None):
                        try:
                                self.conditionalFunction() # check, if the conditionalfunction is still valid
+                               self.activateCondition(self.conditionalFunction())
                        except:
                                self.conditionalFunction = None
                                self.activateCondition(False)
                        
                        except:
                                self.conditionalFunction = None
                                self.activateCondition(False)
                        
-                       self.activateCondition(self.conditionalFunction())
+
+
+                       
+                       
+import time
+
+class BlinkingWidget(Widget):
+       def __init__(self):
+               Widget.__init__(self)
+               
+               self.blinking = True
+               
+               self.setBlinkTime(500)
+
+               self.timer = eTimer()
+               self.timer.timeout.get().append(self.blink)
+       
+       def setBlinkTime(self, time):
+               self.blinktime = time
+               
+       def blink(self):
+               if self.blinking == True:
+                       if (self.state == self.SHOWN):
+                               self.hideWidget()
+                       elif (self.state == self.HIDDEN):
+                               self.showWidget()
+                       
+       def startBlinking(self):
+               self.blinking = True
+               self.timer.start(self.blinktime)
+               
+       def stopBlinking(self):
+               self.blinking = False
+               if (self.state == self.SHOWN):
+                       self.hideWidget()
+               self.timer.stop()
+               
+class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
+       def __init__(self):
+               BlinkingWidget.__init__(self)
+               ConditionalWidget.__init__(self)
+               
+       def activateCondition(self, condition):
+               if (condition):
+                       if not self.blinking: # we are already blinking
+                               self.startBlinking()
+               else:
+                       if self.blinking: # we are blinking
+                               self.stopBlinking()                     
\ No newline at end of file