load an url
[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 import urllib
7
8 class CurlyTx(Screen):
9     skin = """
10         <screen position="100,100" size="550,400" title="Test" >
11             <widget name="text" position="0,0" size="550,400" font="Regular;20" />
12         </screen>"""
13
14     def __init__(self, session, args = None):
15         self.skin = CurlyTx.skin
16         Screen.__init__(self, session)
17
18         self["text"] = ScrollLabel("foo")
19         #self.session.openWithCallback(self.mycallback, MessageBox, _("Test-Messagebox?"))
20
21         self["actions"] = NumberActionMap(["WizardActions", "InputActions"], {
22                 "ok": self.close,
23                 "back": self.close,
24                 "up": self.pageUp,
25                 "down": self.pageDown
26             }, -1)
27         self.loadUrl()
28
29     def pageUp(self):
30         self["text"].pageUp()
31
32     def pageDown(self):
33         self["text"].pageDown()
34
35
36     def mycallback(self, answer):
37         print "answer:", answer
38         if answer:
39             raise Exception("test-crash")
40         self.close()
41
42     def loadUrl(self):
43         #sample = file(test).read()
44         #import urllib
45         ##req = urllib2.Request(url)
46         r = urllib.urlopen("http://www.bogo/tagebuch/tagebuch.css")
47         self["text"].setText(r.read())
48         r.close()
49         # f.write(r.read())
50         # webFile.close()