audio: add language display
[enigma2.git] / lib / python / Components / Pixmap.py
1 import skin
2 from GUIComponent import *
3
4 from enigma import *
5
6 class Pixmap(GUIComponent):
7         """Pixmap can be used for components which diplay a pixmap"""
8         
9         SHOWN = 0
10         HIDDEN = 1
11         
12         def __init__(self):
13                 GUIComponent.__init__(self)
14                 self.instance = None
15                 self.state = self.SHOWN
16         
17         def GUIcreate(self, parent):
18                 self.instance = self.createWidget(parent)
19         
20         def GUIdelete(self):
21                 self.removeWidget(self.instance)
22                 self.instance = None
23         
24         def getePixmap(self, parent):
25                 #pixmap = ePixmap(parent)
26                 #pixmap.setPixmapFromFile(self.filename)
27                 return ePixmap(parent)
28         
29         def createWidget(self, parent):
30                 return self.getePixmap(parent)
31
32         def removeWidget(self, w):
33                 pass
34         
35         def showPixmap(self):
36                 print "Show pixmap"
37                 self.state = self.SHOWN
38                 self.instance.show()
39
40         def hidePixmap(self):
41                 print "Hide pixmap"
42                 self.state = self.HIDDEN
43                 self.instance.hide()
44         
45         def removeWidget(self, instance):
46                 pass
47
48 class PixmapConditional(Pixmap):
49         def __init__(self, withTimer = True):
50                 Pixmap.__init__(self)
51                 
52                 self.setConnect(None)
53                 
54                 if (withTimer):
55                         self.conditionCheckTimer = eTimer()
56                         self.conditionCheckTimer.timeout.get().append(self.update)
57                         self.conditionCheckTimer.start(1000)
58                 
59         def setConnect(self, conditionalFunction):
60                 self.conditionalFunction = conditionalFunction
61                 
62         def activateCondition(self, condition):
63                 if (condition):
64                         if (self.state == self.HIDDEN):
65                                 self.showPixmap()
66                 else:
67                         if (self.state == self.SHOWN):
68                                 self.hidePixmap()
69
70         def update(self):
71                 if (self.conditionalFunction != None):
72                         try:
73                                 self.conditionalFunction() # check, if the conditionalfunction is still valid
74                         except:
75                                 self.conditionalFunction = None
76                                 self.activateCondition(False)
77                         
78                         self.activateCondition(self.conditionalFunction())