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)
70 class BlinkingWidget(Widget):
76 self.setBlinkTime(500)
79 self.timer.timeout.get().append(self.blink)
81 def setBlinkTime(self, time):
85 if self.blinking == True:
86 if (self.state == self.SHOWN):
88 elif (self.state == self.HIDDEN):
91 def startBlinking(self):
93 self.timer.start(self.blinktime)
95 def stopBlinking(self):
97 if (self.state == self.SHOWN):
101 class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
103 BlinkingWidget.__init__(self)
104 ConditionalWidget.__init__(self)
106 def activateCondition(self, condition):
108 if not self.blinking: # we are already blinking
111 if self.blinking: # we are blinking