X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/1557c715e461d5a7deb04bb008c6497441351bbe..3f5acc5cef5475cef339c967f8ca7da54b1625e3:/lib/python/Components/Converter/ConditionalShowHide.py diff --git a/lib/python/Components/Converter/ConditionalShowHide.py b/lib/python/Components/Converter/ConditionalShowHide.py index cc98288f..d2e89ba4 100644 --- a/lib/python/Components/Converter/ConditionalShowHide.py +++ b/lib/python/Components/Converter/ConditionalShowHide.py @@ -1,11 +1,58 @@ +from enigma import eTimer from Converter import Converter class ConditionalShowHide(Converter, object): - - def __init__(self, type): + def __init__(self, argstr): Converter.__init__(self, type) - self.invert = type == "Invert" + args = argstr.split(',') + self.invert = "Invert" in args + self.blink = "Blink" in args + if self.blink: + self.blinktime = 500 + self.timer = eTimer() + self.timer.timeout.get().append(self.blinkFunc) - def changed(self, what): + def blinkFunc(self): + if self.blinking == True: + for x in self.downstream_elements: + x.visible = not x.visible + + def startBlinking(self): + self.blinking = True + self.timer.start(self.blinktime) + + def stopBlinking(self): + self.blinking = False for x in self.downstream_elements: - x.visible = self.source.boolean + if x.visible: + x.hide() + self.timer.stop() + + def calcVisibility(self): + b = self.source.boolean + if b is None: + return True + b ^= self.invert + return b + + def changed(self, what): + vis = self.calcVisibility() + if self.blink: + if vis: + self.startBlinking() + else: + self.stopBlinking() + else: + for x in self.downstream_elements: + x.visible = vis + + def connectDownstream(self, downstream): + Converter.connectDownstream(self, downstream) + vis = self.calcVisibility() + if self.blink: + if vis: + self.startBlinking() + else: + self.stopBlinking() + else: + downstream.visible = self.calcVisibility()