default configuration; use configuration in main menu
[enigma2-curlytx.git] / src / CurlyTx.py
1 from Screens.Screen import Screen
2 from Screens.MessageBox import MessageBox
3 from Components.Label import Label
4 from Components.ScrollLabel import ScrollLabel
5 from Components.ActionMap import NumberActionMap
6 from twisted.web import client
7
8 from . import config
9 from Components.config import config
10
11 class CurlyTx(Screen):
12     skin = """
13         <screen position="100,100" size="550,400" title="CurlyTx" >
14             <widget name="text" position="0,0" size="550,400" font="Console;20" />
15         </screen>"""
16
17     def __init__(self, session, args = None):
18         self.skin = CurlyTx.skin
19         Screen.__init__(self, session)
20
21         self["text"] = ScrollLabel("foo")
22
23         self["actions"] = NumberActionMap(["WizardActions", "InputActions"], {
24                 "ok": self.close,
25                 "back": self.close,
26                 "up": self.pageUp,
27                 "down": self.pageDown
28             }, -1)
29
30         self.loadUrl("http://monitoring.home.cweiske.de/wetter/plain.txt")
31
32     def pageUp(self):
33         self["text"].pageUp()
34
35     def pageDown(self):
36         self["text"].pageDown()
37
38
39     def mycallback(self, answer):
40         print "answer:", answer
41         if answer:
42             raise Exception("test-crash")
43         self.close()
44
45     def loadUrl(self, url):
46         self["text"].setText("Loading ...\n" + url);
47
48         client.getPage(url).addCallback(self.urlLoaded).addErrback(self.urlFailed, url)
49
50     def urlLoaded(self, html):
51         self["text"].setText(html)
52
53     def urlFailed(self, error, url):
54         self["text"].setText(
55             "Error fetching URL:\n " + error.getErrorMessage()
56             + "\n\nURL: " + url
57             )