X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/df7d9f3578c68b22c95ab9daa23bd0fa168f6d11..1a3a68d135903b60ad9aa5ee829cec58d663754a:/lib/python/Components/ConditionalWidget.py diff --git a/lib/python/Components/ConditionalWidget.py b/lib/python/Components/ConditionalWidget.py index 07d59e02..f4b99837 100644 --- a/lib/python/Components/ConditionalWidget.py +++ b/lib/python/Components/ConditionalWidget.py @@ -1,30 +1,9 @@ -import skin -from GUIComponent import * +from GUIComponent import GUIComponent +from enigma import eTimer -from enigma import * - -class Widget(GUIComponent): - def __init__(self): - GUIComponent.__init__(self) - - def GUIcreate(self, parent): - self.instance = self.createWidget(parent) - if self.state == self.HIDDEN: - self.instance.hide() - - def GUIdelete(self): - self.removeWidget(self.instance) - self.instance = None - - def removeWidget(self, w): - pass - - def move(self, x, y): - self.instance.move(ePoint(int(x), int(y))) - -class ConditionalWidget(Widget): +class ConditionalWidget(GUIComponent): def __init__(self, withTimer = True): - Widget.__init__(self) + GUIComponent.__init__(self) self.setConnect(None) @@ -32,37 +11,32 @@ class ConditionalWidget(Widget): self.conditionCheckTimer = eTimer() self.conditionCheckTimer.timeout.get().append(self.update) self.conditionCheckTimer.start(1000) - + + def postWidgetCreate(self, instance): + self.visible = 0 + def setConnect(self, conditionalFunction): self.conditionalFunction = conditionalFunction def activateCondition(self, condition): - if (condition): - if self.state == self.HIDDEN: - self.show() + if condition: + self.visible = 1 else: - if self.state == self.SHOWN: - self.hide() + self.visible = 0 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) - -import time -class BlinkingWidget(Widget): +class BlinkingWidget(GUIComponent): def __init__(self): - Widget.__init__(self) - - self.blinking = True - + GUIComponent.__init__(self) + self.blinking = False self.setBlinkTime(500) - self.timer = eTimer() self.timer.timeout.get().append(self.blink) @@ -71,10 +45,7 @@ class BlinkingWidget(Widget): def blink(self): if self.blinking == True: - if self.state == self.SHOWN: - self.hide() - elif self.state == self.HIDDEN: - self.show() + self.visible = not self.visible def startBlinking(self): self.blinking = True @@ -82,10 +53,10 @@ class BlinkingWidget(Widget): def stopBlinking(self): self.blinking = False - if self.state == self.SHOWN: + if self.visible: self.hide() self.timer.stop() - + class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget): def __init__(self): BlinkingWidget.__init__(self)