add possibility to have multiple windowstyles. LCD can have different colors now.
[enigma2.git] / lib / python / Components / Sources / Boolean.py
1 from Source import Source
2 from enigma import eTimer
3
4 # a small warning:
5 # you can use that boolean well to express screen-private
6 # conditional expressions.
7 #
8 # however, if you think that there is ANY interest that another
9 # screen could use your expression, please put your calculation
10 # into a seperate Source, providing a "boolean"-property.
11 class Boolean(Source, object):
12         def __init__(self, fixed = False, function = None, poll = 0):
13                 Source.__init__(self)
14                 if poll > 0:
15                         self.poll_timer = eTimer()
16                         self.poll_timer.timeout.get().append(self.poll)
17                         self.poll_timer.start(poll)
18
19         def getBoolean(self):
20                 if self.function is not None:
21                         return self.function()
22                 else:
23                         return self.fixed
24
25         boolean = property(getBoolean)
26
27         def poll(self):
28                 self.changed((self.CHANGED_ALL,))