RemainingToText.py: more flexible use
[enigma2.git] / lib / python / Components / Button.py
1 from HTMLComponent import HTMLComponent
2 from GUIComponent import GUIComponent
3 from VariableText import VariableText
4
5 from enigma import eButton
6
7 class Button(VariableText, HTMLComponent, GUIComponent):
8         def __init__(self, text="", onClick = [ ]):
9                 GUIComponent.__init__(self)
10                 VariableText.__init__(self)
11                 self.setText(text)
12                 self.onClick = onClick
13         
14         def push(self):
15                 for x in self.onClick:
16                         x()
17                 return 0
18         
19         def disable(self):
20                 pass
21         
22         def enable(self):
23                 pass
24
25 # html:
26         def produceHTML(self):
27                 return "<input type=\"submit\" text=\"" + self.getText() + "\">\n"
28
29         GUI_WIDGET = eButton
30
31         def postWidgetCreate(self, instance):
32                 instance.setText(self.text)
33                 instance.selected.get().append(self.push)
34
35         def preWidgetRemove(self, instance):
36                 instance.selected.get().remove(self.push)