2 from GUIComponent import *
6 class Widget(GUIComponent):
12 GUIComponent.__init__(self)
14 self.state = self.SHOWN
16 def GUIcreate(self, parent):
17 self.instance = self.createWidget(parent)
20 self.removeWidget(self.instance)
23 def removeWidget(self, w):
27 self.state = self.SHOWN
31 self.state = self.HIDDEN
35 self.instance.move(ePoint(int(x), int(y)))
37 class ConditionalWidget(Widget):
38 def __init__(self, withTimer = True):
44 self.conditionCheckTimer = eTimer()
45 self.conditionCheckTimer.timeout.get().append(self.update)
46 self.conditionCheckTimer.start(1000)
48 def setConnect(self, conditionalFunction):
49 self.conditionalFunction = conditionalFunction
51 def activateCondition(self, condition):
53 if (self.state == self.HIDDEN):
56 if (self.state == self.SHOWN):
60 if (self.conditionalFunction != None):
62 self.conditionalFunction() # check, if the conditionalfunction is still valid
63 self.activateCondition(self.conditionalFunction())
65 self.conditionalFunction = None
66 self.activateCondition(False)
74 class BlinkingWidget(Widget):
80 self.setBlinkTime(500)
83 self.timer.timeout.get().append(self.blink)
85 def setBlinkTime(self, time):
89 if self.blinking == True:
90 if (self.state == self.SHOWN):
92 elif (self.state == self.HIDDEN):
95 def startBlinking(self):
97 self.timer.start(self.blinktime)
99 def stopBlinking(self):
100 self.blinking = False
101 if (self.state == self.SHOWN):
105 class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
107 BlinkingWidget.__init__(self)
108 ConditionalWidget.__init__(self)
110 def activateCondition(self, condition):
112 if not self.blinking: # we are already blinking
115 if self.blinking: # we are blinking