blob: df7f81b2a68e50bb1b510a02d795d477db0c82fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
from Source import Source
from Components.Element import cached
from enigma import eTimer
# a small warning:
# you can use that boolean well to express screen-private
# conditional expressions.
#
# however, if you think that there is ANY interest that another
# screen could use your expression, please put your calculation
# into a seperate Source, providing a "boolean"-property.
class Boolean(Source, object):
def __init__(self, fixed = False, function = None, poll = 0):
Source.__init__(self)
self.function = function
self.fixed = fixed
if poll > 0:
self.poll_timer = eTimer()
self.poll_timer.timeout.get().append(self.poll)
self.poll_timer.start(poll)
@cached
def getBoolean(self):
if self.function is not None:
return self.function()
else:
return self.fixed
boolean = property(getBoolean)
def poll(self):
self.changed((self.CHANGED_ALL,))
|