beautify the ok, cancel and initialize buttons
[enigma2.git] / lib / python / Plugins / update.py
1 from enigma import *
2 from Screens.Screen import Screen
3 from Screens.MessageBox import MessageBox
4 from Components.ActionMap import ActionMap
5 from Components.Label import Label
6
7 import os
8
9 class Example(Screen):
10         skin = """
11                 <screen position="100,100" size="550,400" title="IPKG upgrade..." >
12                         <widget name="text" position="0,0" size="550,400" font="Regular;15" />
13                 </screen>"""
14                 
15         def __init__(self, session):
16                 self.skin = Example.skin
17                 Screen.__init__(self, session)
18
19                 self["text"] = Label(_("Please press OK!"))
20                                 
21                 self["actions"] = ActionMap(["WizardActions"], 
22                 {
23                         "ok": self.ok,
24                         "back": self.close
25                 }, -1)
26                 
27         def ok(self):
28                 self.session.openWithCallback(self.doUpdate, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!"))
29                 
30         def doUpdate(self, val = False):
31                 if val:
32                         lines = os.popen("ipkg update && ipkg upgrade", "r").readlines()
33                         string = ""
34                         for x in lines:
35                                 string += x
36                         self["text"].setText(_("Updating finished. Here is the result:") + "\n\n" + string)
37                 else:
38                         self.close()            
39                 
40                 
41 def main(session):
42         session.open(Example)
43         
44
45 def getPicturePath():
46                 return "/usr/lib/enigma2/python/Plugins/update.png"
47
48 def getPluginName():
49                 return "Softwareupdate"