2 from GUIComponent import *
6 class ConditionalWidget(GUIComponent):
7 def __init__(self, withTimer = True):
8 GUIComponent.__init__(self)
13 self.conditionCheckTimer = eTimer()
14 self.conditionCheckTimer.timeout.get().append(self.update)
15 self.conditionCheckTimer.start(1000)
17 def setConnect(self, conditionalFunction):
18 self.conditionalFunction = conditionalFunction
20 def activateCondition(self, condition):
22 self.state = self.SHOWN
24 self.state = self.HIDDEN
27 if (self.conditionalFunction != None):
29 self.conditionalFunction() # check, if the conditionalfunction is still valid
30 self.activateCondition(self.conditionalFunction())
32 self.conditionalFunction = None
33 self.activateCondition(False)
37 class BlinkingWidget(GUIComponent):
39 GUIComponent.__init__(self)
43 self.setBlinkTime(500)
46 self.timer.timeout.get().append(self.blink)
48 def setBlinkTime(self, time):
52 if self.blinking == True:
53 if self.state == self.SHOWN:
55 elif self.state == self.HIDDEN:
58 def startBlinking(self):
60 self.timer.start(self.blinktime)
62 def stopBlinking(self):
64 if self.state == self.SHOWN:
68 class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
70 BlinkingWidget.__init__(self)
71 ConditionalWidget.__init__(self)
73 def activateCondition(self, condition):
75 if not self.blinking: # we are already blinking
78 if self.blinking: # we are blinking