add a class PixmapConditional, in which the pixmap is only displayed, when a conditio...
[vuplus_dvbapp] / lib / python / Components / Pixmap.py
1 import skin
2
3 from enigma import *
4
5 class Pixmap:
6         """Pixmap can be used for components which diplay a pixmap"""
7         
8         def __init__(self):
9                 self.instance = None
10         
11         def GUIcreate(self, parent):
12                 self.instance = self.createWidget(parent)
13         
14         def GUIdelete(self):
15                 self.removeWidget(self.instance)
16                 self.instance = None
17         
18         def getePixmap(self, parent):
19                 #pixmap = ePixmap(parent)
20                 #pixmap.setPixmapFromFile(self.filename)
21                 return ePixmap(parent)
22         
23         def removeWidget(self, instance):
24                 pass
25
26 class PixmapConditional(Pixmap):
27         def __init__(self, withTimer = True):
28                 Pixmap.__init__(self)
29                 
30                 if (withTimer):
31                         self.conditionCheckTimer = eTimer()
32                         self.conditionCheckTimer.timeout.get().append(self.update)
33                         self.conditionCheckTimer.start(1000)
34                 
35         def setConnect(self, conditionalFunction):
36                 self.conditionalFunction = conditionalFunction
37                 
38         def activateCondition(self, condition):
39                 if (condition):
40                         self.instance.hide()
41                 else:
42                         self.instance.show()
43
44         def update(self):
45                 try:
46                         self.conditionalFunction() # check, if the conditionalfunction is still valid
47                 except:
48                         self.conditionalFunction = None
49                         self.activateCondition(False)
50                         
51                 self.activateCondition(self.conditionalFunction())