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
34 class ConditionalWidget(Widget):
35 def __init__(self, withTimer = True):
41 self.conditionCheckTimer = eTimer()
42 self.conditionCheckTimer.timeout.get().append(self.update)
43 self.conditionCheckTimer.start(1000)
45 def setConnect(self, conditionalFunction):
46 self.conditionalFunction = conditionalFunction
48 def activateCondition(self, condition):
50 if (self.state == self.HIDDEN):
51 print "update: " + str(self) + " SHOW"
54 if (self.state == self.SHOWN):
55 print "update: " + str(self) + " HIDE"
59 if (self.conditionalFunction != None):
61 self.conditionalFunction() # check, if the conditionalfunction is still valid
63 self.conditionalFunction = None
64 self.activateCondition(False)
66 self.activateCondition(self.conditionalFunction())