finish language-menu - the RT_VALIGN_CENTER doesn't work in eListboxPythonMultiConten...
[vuplus_dvbapp] / lib / python / Screens / Wizard.py
index 7687f44..07c5f9a 100644 (file)
@@ -39,7 +39,7 @@ class WelcomeWizard(Screen, HelpableScreen):
                        self.currContent = name
                        if (name == "step"):
                                self.lastStep = int(attrs.get('number'))
-                               self.wizard[self.lastStep] = {"text": "", "list": [], "config": {"screen": None, "args": None }, "code": ""}
+                               self.wizard[self.lastStep] = {"text": "", "list": [], "config": {"screen": None, "args": None, "type": "" }, "code": ""}
                        elif (name == "text"):
                                self.wizard[self.lastStep]["text"] = str(attrs.get('value'))
                        elif (name == "listentry"):
@@ -50,6 +50,7 @@ class WelcomeWizard(Screen, HelpableScreen):
                                if (attrs.has_key('args')):
                                        print "has args"
                                        self.wizard[self.lastStep]["config"]["args"] = str(attrs.get('args'))
+                               self.wizard[self.lastStep]["config"]["type"] = str(attrs.get('type'))
                def endElement(self, name):
                        self.currContent = ""
                        if name == 'code':
@@ -117,8 +118,12 @@ class WelcomeWizard(Screen, HelpableScreen):
                        #})
 
        def ok(self):
+               print "OK"
                if (self.wizard[self.currStep]["config"]["screen"] != None):
-                       self.configInstance.run()
+                       try: # don't die, if no run() is available
+                               self.configInstance.run()
+                       except:
+                               print "Failed to run configInstance"
                
                if (len(self.wizard[self.currStep]["list"]) > 0):
                        nextStep = self.wizard[self.currStep]["list"][self["list"].l.getCurrentSelectionIndex()][1]
@@ -136,6 +141,8 @@ class WelcomeWizard(Screen, HelpableScreen):
                else:
                        self.currStep += 1
                        self.updateValues()
+                       
+               print "Now: " + str(self.currStep)
 
        def keyNumberGlobal(self, number):
                if (self.wizard[self.currStep]["config"]["screen"] != None):
@@ -166,10 +173,15 @@ class WelcomeWizard(Screen, HelpableScreen):
                print "down"
                
        def updateValues(self):
+               print "Updating values in step " + str(self.currStep)
                self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps))
                self["stepslider"].setValue(self.currStep)
 
                self["text"].setText(self.wizard[self.currStep]["text"])
+
+               if self.wizard[self.currStep]["code"] != "":
+                       print self.wizard[self.currStep]["code"]
+                       exec(self.wizard[self.currStep]["code"])
                
                self["list"].instance.setZPosition(1)
                self.list = []
@@ -181,20 +193,22 @@ class WelcomeWizard(Screen, HelpableScreen):
 
                self["config"].instance.setZPosition(1)
                if (self.wizard[self.currStep]["config"]["screen"] != None):
-                       self["config"].instance.setZPosition(2)
-                       print self.wizard[self.currStep]["config"]["screen"]
-                       if self.wizard[self.currStep]["config"]["args"] == None:
-                               self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"])
+                       if self.wizard[self.currStep]["config"]["type"] == "standalone":
+                               print "Type is standalone"
+                               self.session.openWithCallback(self.ok, self.wizard[self.currStep]["config"]["screen"])
                        else:
-                               self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
-                       self["config"].l.setList(self.configInstance["config"].list)
-                       self.configInstance["config"] = self["config"]
+                               self["config"].instance.setZPosition(2)
+                               print self.wizard[self.currStep]["config"]["screen"]
+                               if self.wizard[self.currStep]["config"]["args"] == None:
+                                       self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"])
+                               else:
+                                       self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
+                               self["config"].l.setList(self.configInstance["config"].list)
+                               self.configInstance["config"] = self["config"]
                else:
                        self["config"].l.setList([])
 
-               if self.wizard[self.currStep]["code"] != "":
-                       print self.wizard[self.currStep]["code"]
-                       exec(self.wizard[self.currStep]["code"])
+
 
 def listActiveWizards():
        wizards = [ ]