aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Converter/ConditionalShowHide.py
blob: 2d4b99a228d0b28744d43e59e9efaae65a203e2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from Converter import Converter

class ConditionalShowHide(Converter, object):
	def __init__(self, type):
		Converter.__init__(self, type)
		self.invert = type == "Invert"

	def calcVisibility(self):
		b = self.source.boolean
		if b is None:
			return True
		b ^= self.invert
		return b

	def changed(self, what):
		vis = self.calcVisibility()
		for x in self.downstream_elements:
			x.visible = vis

	def connectDownstream(self, downstream):
		Converter.connectDownstream(self, downstream)
		downstream.visible = self.calcVisibility()