1 from enigma import eConsoleAppContainer
2 from Screens.Screen import Screen
3 from Components.ActionMap import ActionMap
4 from Components.ScrollLabel import ScrollLabel
7 #TODO move this to skin.xml
9 <screen position="100,100" size="550,400" title="Command execution..." >
10 <widget name="text" position="0,0" size="550,400" font="Regular;15" />
13 def __init__(self, session, title = "Console", cmdlist = None, finishedCallback = None):
14 self.skin = Console.skin
15 Screen.__init__(self, session)
17 self.finishedCallback = finishedCallback
19 self["text"] = ScrollLabel("")
20 self["actions"] = ActionMap(["WizardActions", "DirectionActions"],
24 "up": self["text"].pageUp,
25 "down": self["text"].pageDown
28 self.cmdlist = cmdlist
31 self.onShown.append(self.updateTitle)
33 self.container = eConsoleAppContainer()
35 self.container.appClosed.get().append(self.runFinished)
36 self.container.dataAvail.get().append(self.dataAvail)
37 self.onLayoutFinish.append(self.startRun) # dont start before gui is finished
39 def updateTitle(self):
40 self.setTitle(self.newtitle)
43 self["text"].setText(_("Execution Progress:") + "\n\n")
44 print "Console: executing in run", self.run, " the command:", self.cmdlist[self.run]
45 self.container.execute(self.cmdlist[self.run])
47 def runFinished(self, retval):
49 if self.run != len(self.cmdlist):
50 self.container.execute(self.cmdlist[self.run])
52 str = self["text"].getText()
53 str += _("Execution finished!!");
54 self["text"].setText(str)
55 if self.finishedCallback is not None:
56 self.finishedCallback()
59 if self.run == len(self.cmdlist):
62 def dataAvail(self, str):
63 self["text"].setText(self["text"].getText() + str)