fix snrdb calculation for dm600 tuner
[enigma2.git] / lib / python / Screens / Wizard.py
1 from Screen import Screen
2
3 from Screens.HelpMenu import HelpableScreen
4 from Screens.MessageBox import MessageBox
5 from Components.config import config, KEY_LEFT, KEY_RIGHT, KEY_HOME, KEY_END, KEY_0, KEY_DELETE, KEY_BACKSPACE, KEY_OK, KEY_TOGGLEOW, KEY_ASCII, KEY_TIMEOUT, KEY_NUMBERS
6
7 from Components.Label import Label
8 from Components.Slider import Slider
9 from Components.ActionMap import NumberActionMap
10 from Components.MenuList import MenuList
11 from Components.ConfigList import ConfigList
12 from Components.Sources.List import List
13
14 from enigma import eTimer
15
16 from xml.sax import make_parser
17 from xml.sax.handler import ContentHandler
18
19 class WizardSummary(Screen):
20         skin = """
21         <screen position="0,0" size="132,64">
22                 <widget name="text" position="6,4" size="120,42" font="Regular;14" transparent="1" />
23                 <widget source="parent.list" render="Label" position="6,25" size="120,21" font="Regular;16">
24                         <convert type="StringListSelection" />
25                 </widget>
26         </screen>"""
27         
28         def __init__(self, session, parent):
29                 Screen.__init__(self, session, parent)
30                 
31                 #names = parent.skinName
32                 #if not isinstance(names, list):
33                         #names = [names]
34 #                       
35                 #self.skinName = [x + "_summary" for x in names ]
36                 #self.skinName.append("Wizard")
37                 #print "*************+++++++++++++++++****************++++++++++******************* WizardSummary", self.skinName
38                         #
39                 self["text"] = Label("")
40                 self.onShow.append(self.setCallback)
41                 
42         def setCallback(self):
43                 self.parent.setLCDTextCallback(self.setText)
44                 
45         def setText(self, text):
46                 self["text"].setText(text)
47
48 class Wizard(Screen):
49         def createSummary(self):
50                         print "WizardCreateSummary"
51                         return WizardSummary
52
53         class parseWizard(ContentHandler):
54                 def __init__(self, wizard):
55                         self.isPointsElement, self.isReboundsElement = 0, 0
56                         self.wizard = wizard
57                         self.currContent = ""
58                         self.lastStep = 0       
59
60                 def startElement(self, name, attrs):
61                         #print "startElement", name
62                         self.currContent = name
63                         if (name == "step"):
64                                 self.lastStep += 1
65                                 if attrs.has_key('id'):
66                                         id = str(attrs.get('id'))
67                                 else:
68                                         id = ""
69                                 #print "id:", id
70                                 if attrs.has_key('nextstep'):
71                                         nextstep = str(attrs.get('nextstep'))
72                                 else:
73                                         nextstep = None
74                                 if attrs.has_key('timeout'):
75                                         timeout = int(attrs.get('timeout'))
76                                 else:
77                                         timeout = None
78                                 if attrs.has_key('timeoutaction'):
79                                         timeoutaction = str(attrs.get('timeoutaction'))
80                                 else:
81                                         timeoutaction = 'nextpage'
82
83                                 if attrs.has_key('timeoutstep'):
84                                         timeoutstep = str(attrs.get('timeoutstep'))
85                                 else:
86                                         timeoutstep = ''
87                                 self.wizard[self.lastStep] = {"id": id, "condition": "", "text": "", "timeout": timeout, "timeoutaction": timeoutaction, "timeoutstep": timeoutstep, "list": [], "config": {"screen": None, "args": None, "type": "" }, "code": "", "codeafter": "", "code_async": "", "codeafter_async": "", "nextstep": nextstep}
88                                 if attrs.has_key('laststep'):
89                                         self.wizard[self.lastStep]["laststep"] = str(attrs.get('laststep'))
90                         elif (name == "text"):
91                                 self.wizard[self.lastStep]["text"] = str(attrs.get('value')).replace("\\n", "\n")
92                         elif (name == "displaytext"):
93                                 self.wizard[self.lastStep]["displaytext"] = str(attrs.get('value')).replace("\\n", "\n")
94                         elif (name == "list"):
95                                 if (attrs.has_key('type')):
96                                         if attrs["type"] == "dynamic":
97                                                 self.wizard[self.lastStep]["dynamiclist"] = attrs.get("source")
98                                         #self.wizard[self.lastStep]["list"].append(("Hallo", "test"))
99                                 if (attrs.has_key("evaluation")):
100                                         #print "evaluation"
101                                         self.wizard[self.lastStep]["listevaluation"] = attrs.get("evaluation")
102                                 if (attrs.has_key("onselect")):
103                                         self.wizard[self.lastStep]["onselect"] = attrs.get("onselect")                  
104                         elif (name == "listentry"):
105                                 self.wizard[self.lastStep]["list"].append((str(attrs.get('caption')), str(attrs.get('step'))))
106                         elif (name == "config"):
107                                 type = str(attrs.get('type'))
108                                 self.wizard[self.lastStep]["config"]["type"] = type
109                                 if type == "ConfigList" or type == "standalone":
110                                         try:
111                                                 exec "from Screens." + str(attrs.get('module')) + " import *"
112                                         except:
113                                                 exec "from " + str(attrs.get('module')) + " import *"
114                                 
115                                         self.wizard[self.lastStep]["config"]["screen"] = eval(str(attrs.get('screen')))
116                                         if (attrs.has_key('args')):
117                                                 #print "has args"
118                                                 self.wizard[self.lastStep]["config"]["args"] = str(attrs.get('args'))
119                                 elif type == "dynamic":
120                                         self.wizard[self.lastStep]["config"]["source"] = str(attrs.get('source'))
121                                         if (attrs.has_key('evaluation')):
122                                                 self.wizard[self.lastStep]["config"]["evaluation"] = str(attrs.get('evaluation'))
123                         elif (name == "code"):
124                                 self.async_code = attrs.has_key('async') and str(attrs.get('async')) == "yes"
125                                 if attrs.has_key('pos') and str(attrs.get('pos')) == "after":
126                                         self.codeafter = True
127                                 else:
128                                         self.codeafter = False
129                         elif (name == "condition"):
130                                 pass
131                         
132                 def endElement(self, name):
133                         self.currContent = ""
134                         if name == 'code':
135                                 if self.async_code:
136                                         if self.codeafter:
137                                                 self.wizard[self.lastStep]["codeafter_async"] = self.wizard[self.lastStep]["codeafter_async"].strip()
138                                         else:
139                                                 self.wizard[self.lastStep]["code_async"] = self.wizard[self.lastStep]["code_async"].strip()
140                                 else:
141                                         if self.codeafter:
142                                                 self.wizard[self.lastStep]["codeafter"] = self.wizard[self.lastStep]["codeafter"].strip()
143                                         else:
144                                                 self.wizard[self.lastStep]["code"] = self.wizard[self.lastStep]["code"].strip()
145                         elif name == 'condition':
146                                 self.wizard[self.lastStep]["condition"] = self.wizard[self.lastStep]["condition"].strip()
147                         elif name == 'step':
148                                 #print "Step number", self.lastStep, ":", self.wizard[self.lastStep]
149                                 pass
150                                                                 
151                 def characters(self, ch):
152                         if self.currContent == "code":
153                                 if self.async_code:
154                                         if self.codeafter:
155                                                 self.wizard[self.lastStep]["codeafter_async"] = self.wizard[self.lastStep]["codeafter_async"] + ch
156                                         else:
157                                                 self.wizard[self.lastStep]["code_async"] = self.wizard[self.lastStep]["code_async"] + ch
158                                 else:
159                                         if self.codeafter:
160                                                 self.wizard[self.lastStep]["codeafter"] = self.wizard[self.lastStep]["codeafter"] + ch
161                                         else:
162                                                 self.wizard[self.lastStep]["code"] = self.wizard[self.lastStep]["code"] + ch
163                         elif self.currContent == "condition":
164                                  self.wizard[self.lastStep]["condition"] = self.wizard[self.lastStep]["condition"] + ch
165         
166         def __init__(self, session, showSteps = True, showStepSlider = True, showList = True, showConfig = True):
167                 Screen.__init__(self, session)
168                 
169                 self.isLastWizard = False # can be used to skip a "goodbye"-screen in a wizard
170
171                 self.stepHistory = []
172
173                 self.wizard = {}
174                 parser = make_parser()
175                 if not isinstance(self.xmlfile, list):
176                         self.xmlfile = [self.xmlfile]
177                 print "Reading ", self.xmlfile
178                 wizardHandler = self.parseWizard(self.wizard)
179                 parser.setContentHandler(wizardHandler)
180                 for xmlfile in self.xmlfile:
181                         if xmlfile[0] != '/':
182                                 parser.parse('/usr/share/enigma2/' + xmlfile)
183                         else:
184                                 parser.parse(xmlfile)
185
186                 self.showSteps = showSteps
187                 self.showStepSlider = showStepSlider
188                 self.showList = showList
189                 self.showConfig = showConfig
190
191                 self.numSteps = len(self.wizard)
192                 self.currStep = self.getStepWithID("start") + 1
193                 
194                 self.timeoutTimer = eTimer()
195                 self.timeoutTimer.callback.append(self.timeoutCounterFired)
196
197                 self["text"] = Label()
198
199                 if showConfig:
200                         self["config"] = ConfigList([], session = session)
201
202                 if self.showSteps:
203                         self["step"] = Label()
204                 
205                 if self.showStepSlider:
206                         self["stepslider"] = Slider(1, self.numSteps)
207                 
208                 if self.showList:
209                         self.list = []
210                         self["list"] = List(self.list, enableWrapAround = True)
211                         self["list"].onSelectionChanged.append(self.selChanged)
212                         #self["list"] = MenuList(self.list, enableWrapAround = True)
213
214                 self.onShown.append(self.updateValues)
215
216                 self.configInstance = None
217                 
218                 self.lcdCallbacks = []
219                 
220                 self.disableKeys = False
221                 
222                 self["actions"] = NumberActionMap(["WizardActions", "NumberActions", "ColorActions", "SetupActions", "InputAsciiActions"],
223                 {
224                         "gotAsciiCode": self.keyGotAscii,
225                         "ok": self.ok,
226                         "back": self.back,
227                         "left": self.left,
228                         "right": self.right,
229                         "up": self.up,
230                         "down": self.down,
231                         "red": self.red,
232                         "green": self.green,
233                         "yellow": self.yellow,
234                         "blue":self.blue,
235                         "deleteBackward": self.deleteBackward,
236                         "deleteForward": self.deleteForward,
237                         "1": self.keyNumberGlobal,
238                         "2": self.keyNumberGlobal,
239                         "3": self.keyNumberGlobal,
240                         "4": self.keyNumberGlobal,
241                         "5": self.keyNumberGlobal,
242                         "6": self.keyNumberGlobal,
243                         "7": self.keyNumberGlobal,
244                         "8": self.keyNumberGlobal,
245                         "9": self.keyNumberGlobal,
246                         "0": self.keyNumberGlobal
247                 }, -1)
248                 
249         def red(self):
250                 print "red"
251                 pass
252
253         def green(self):
254                 print "green"
255                 pass
256         
257         def yellow(self):
258                 print "yellow"
259                 pass
260         
261         def blue(self):
262                 print "blue"
263                 pass
264         
265         def deleteForward(self):
266                 self.resetCounter()
267                 if (self.wizard[self.currStep]["config"]["screen"] != None):
268                         self.configInstance.keyDelete()
269                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
270                         self["config"].handleKey(KEY_DELETE)
271                 print "deleteForward"
272
273         def deleteBackward(self):
274                 self.resetCounter()
275                 if (self.wizard[self.currStep]["config"]["screen"] != None):
276                         self.configInstance.keyBackspace()
277                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
278                         self["config"].handleKey(KEY_BACKSPACE)
279                 print "deleteBackward"
280         
281         def setLCDTextCallback(self, callback):
282                 self.lcdCallbacks.append(callback)
283
284         def back(self):
285                 if self.disableKeys:
286                         return
287                 print "getting back..."
288                 print "stepHistory:", self.stepHistory
289                 if len(self.stepHistory) > 1:
290                         self.currStep = self.stepHistory[-2]
291                         self.stepHistory = self.stepHistory[:-2]
292                 else:
293                         self.session.openWithCallback(self.exitWizardQuestion, MessageBox, (_("Are you sure you want to exit this wizard?") ) )
294                 if self.currStep < 1:
295                         self.currStep = 1
296                 print "currStep:", self.currStep
297                 print "new stepHistory:", self.stepHistory
298                 self.updateValues()
299                 print "after updateValues stepHistory:", self.stepHistory
300                 
301         def exitWizardQuestion(self, ret = False):
302                 if (ret):
303                         self.markDone()
304                         self.close()
305                 
306         def markDone(self):
307                 pass
308         
309         def getStepWithID(self, id):
310                 print "getStepWithID:", id
311                 count = 0
312                 for x in self.wizard.keys():
313                         if self.wizard[x]["id"] == id:
314                                 print "result:", count
315                                 return count
316                         count += 1
317                 print "result: nothing"
318                 return 0
319
320         def finished(self, gotoStep = None, *args, **kwargs):
321                 print "finished"
322                 currStep = self.currStep
323
324                 if self.updateValues not in self.onShown:
325                         self.onShown.append(self.updateValues)
326                         
327                 if self.showConfig:
328                         if self.wizard[currStep]["config"]["type"] == "dynamic":
329                                 eval("self." + self.wizard[currStep]["config"]["evaluation"])()
330
331                 if self.showList:
332                         if (len(self.wizard[currStep]["evaluatedlist"]) > 0):
333                                 print "current:", self["list"].current
334                                 nextStep = self["list"].current[1]
335                                 if (self.wizard[currStep].has_key("listevaluation")):
336                                         exec("self." + self.wizard[self.currStep]["listevaluation"] + "('" + nextStep + "')")
337                                 else:
338                                         self.currStep = self.getStepWithID(nextStep)
339
340                 print_now = True
341                 if ((currStep == self.numSteps and self.wizard[currStep]["nextstep"] is None) or self.wizard[currStep]["id"] == "end"): # wizard finished
342                         print "wizard finished"
343                         self.markDone()
344                         self.close()
345                 else:
346                         self.codeafter = True
347                         self.runCode(self.wizard[currStep]["codeafter"])
348                         self.prevStep = currStep
349                         self.gotoStep = gotoStep
350                         if not self.runCode(self.wizard[currStep]["codeafter_async"]):
351                                 self.afterAsyncCode()
352                         else:
353                                 if self.updateValues in self.onShown:
354                                         self.onShown.remove(self.updateValues)
355
356                 if print_now:
357                         print "Now: " + str(self.currStep)
358
359         def ok(self):
360                 print "OK"
361                 if self.disableKeys:
362                         return
363                 currStep = self.currStep
364                 
365                 if self.showConfig:
366                         if (self.wizard[currStep]["config"]["screen"] != None):
367                                 # TODO: don't die, if no run() is available
368                                 # there was a try/except here, but i can't see a reason
369                                 # for this. If there is one, please do a more specific check
370                                 # and/or a comment in which situation there is no run()
371                                 if callable(getattr(self.configInstance, "runAsync", None)):
372                                         if self.updateValues in self.onShown:
373                                                 self.onShown.remove(self.updateValues)
374                                         self.configInstance.runAsync(self.finished)
375                                         return
376                                 else:
377                                         self.configInstance.run()
378                 self.finished()
379
380         def keyNumberGlobal(self, number):
381                 if (self.wizard[self.currStep]["config"]["screen"] != None):
382                         self.configInstance.keyNumberGlobal(number)
383
384         def keyGotAscii(self):
385                 if (self.wizard[self.currStep]["config"]["screen"] != None):
386                         self["config"].handleKey(KEY_ASCII)
387                 
388         def left(self):
389                 self.resetCounter()
390                 if (self.wizard[self.currStep]["config"]["screen"] != None):
391                         self.configInstance.keyLeft()
392                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
393                         self["config"].handleKey(KEY_LEFT)
394                 print "left"
395         
396         def right(self):
397                 self.resetCounter()
398                 if (self.wizard[self.currStep]["config"]["screen"] != None):
399                         self.configInstance.keyRight()
400                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
401                         self["config"].handleKey(KEY_RIGHT)     
402                 print "right"
403
404         def up(self):
405                 self.resetCounter()
406                 if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None  or self.wizard[self.currStep]["config"]["type"] == "dynamic"):
407                         self["config"].instance.moveSelection(self["config"].instance.moveUp)
408                 elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
409                         self["list"].selectPrevious()
410                         if self.wizard[self.currStep].has_key("onselect"):
411                                 print "current:", self["list"].current
412                                 self.selection = self["list"].current[-1]
413                                 #self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
414                                 exec("self." + self.wizard[self.currStep]["onselect"] + "()")
415                 print "up"
416                 
417         def down(self):
418                 self.resetCounter()
419                 if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None  or self.wizard[self.currStep]["config"]["type"] == "dynamic"):
420                         self["config"].instance.moveSelection(self["config"].instance.moveDown)
421                 elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
422                         #self["list"].instance.moveSelection(self["list"].instance.moveDown)
423                         self["list"].selectNext()
424                         if self.wizard[self.currStep].has_key("onselect"):
425                                 print "current:", self["list"].current
426                                 #self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
427                                 #exec("self." + self.wizard[self.currStep]["onselect"] + "()")
428                                 self.selection = self["list"].current[-1]
429                                 #self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
430                                 exec("self." + self.wizard[self.currStep]["onselect"] + "()")
431                 print "down"
432                 
433         def selChanged(self):
434                 self.resetCounter()
435                 
436                 if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None):
437                         self["config"].instance.moveSelection(self["config"].instance.moveUp)
438                 elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
439                         if self.wizard[self.currStep].has_key("onselect"):
440                                 self.selection = self["list"].current[-1]
441                                 print "self.selection:", self.selection
442                                 exec("self." + self.wizard[self.currStep]["onselect"] + "()")
443                 
444         def resetCounter(self):
445                 self.timeoutCounter = self.wizard[self.currStep]["timeout"]
446                 
447         def runCode(self, code):
448                 if code != "":
449                         print "code", code
450                         exec(code)
451                         return True
452                 return False
453
454         def getTranslation(self, text):
455                 return _(text)
456                         
457         def updateText(self, firstset = False):
458                 text = self.getTranslation(self.wizard[self.currStep]["text"])
459                 if text.find("[timeout]") != -1:
460                         text = text.replace("[timeout]", str(self.timeoutCounter))
461                         self["text"].setText(text)
462                 else:
463                         if firstset:
464                                 self["text"].setText(text)
465                 
466         def updateValues(self):
467                 print "Updating values in step " + str(self.currStep)
468                 # calling a step which doesn't exist can only happen if the condition in the last step is not fulfilled
469                 # if a non-existing step is called, end the wizard 
470                 if self.currStep > len(self.wizard):
471                         self.markDone()
472                         self.close()
473                         return
474
475                 self.timeoutTimer.stop()
476                 
477                 if self.configInstance is not None:
478                         # remove callbacks
479                         self.configInstance["config"].onSelectionChanged = []
480                         del self.configInstance["config"]
481                         self.configInstance.doClose()
482                         self.configInstance = None
483
484                 self.condition = True
485                 exec (self.wizard[self.currStep]["condition"])
486                 if not self.condition:
487                         print "keys*******************:", self.wizard[self.currStep].keys()
488                         if self.wizard[self.currStep].has_key("laststep"): # exit wizard, if condition of laststep doesn't hold
489                                 self.markDone()
490                                 self.close()
491                                 return
492                         else:
493                                 self.currStep += 1
494                                 self.updateValues()
495                 else:
496                         if self.wizard[self.currStep].has_key("displaytext"):
497                                 displaytext = self.wizard[self.currStep]["displaytext"]
498                                 print "set LCD text"
499                                 for x in self.lcdCallbacks:
500                                         x(displaytext)
501                         if len(self.stepHistory) == 0 or self.stepHistory[-1] != self.currStep:
502                                 self.stepHistory.append(self.currStep)
503                         print "wizard step:", self.wizard[self.currStep]
504                         
505                         if self.showSteps:
506                                 self["step"].setText(self.getTranslation("Step ") + str(self.currStep) + "/" + str(self.numSteps))
507                         if self.showStepSlider:
508                                 self["stepslider"].setValue(self.currStep)
509                 
510                         if self.wizard[self.currStep]["timeout"] is not None:
511                                 self.resetCounter() 
512                                 self.timeoutTimer.start(1000)
513                         
514                         print "wizard text", self.getTranslation(self.wizard[self.currStep]["text"])
515                         self.updateText(firstset = True)
516                         if self.wizard[self.currStep].has_key("displaytext"):
517                                 displaytext = self.wizard[self.currStep]["displaytext"]
518                                 print "set LCD text"
519                                 for x in self.lcdCallbacks:
520                                         x(displaytext)
521                                 
522                         self.codeafter=False
523                         self.runCode(self.wizard[self.currStep]["code"])
524                         if self.runCode(self.wizard[self.currStep]["code_async"]):
525                                 if self.updateValues in self.onShown:
526                                         self.onShown.remove(self.updateValues)
527                         else:
528                                 self.afterAsyncCode()
529
530         def afterAsyncCode(self):
531                 if not self.updateValues in self.onShown:
532                         self.onShown.append(self.updateValues)
533
534                 if self.codeafter:
535                         if self.wizard[self.prevStep]["nextstep"] is not None:
536                                 self.currStep = self.getStepWithID(self.wizard[self.prevStep]["nextstep"])
537                         if self.gotoStep is not None:
538                                 self.currStep = self.getStepWithID(self.gotoStep)
539                         self.currStep += 1
540                         self.updateValues()
541                         print "Now: " + str(self.currStep)
542                 else:
543                         if self.showList:
544                                 print "showing list,", self.currStep
545                                 for renderer in self.renderer:
546                                         rootrenderer = renderer
547                                         while renderer.source is not None:
548                                                 print "self.list:", self["list"]
549                                                 if renderer.source is self["list"]:
550                                                         print "setZPosition"
551                                                         rootrenderer.instance.setZPosition(1)
552                                                 renderer = renderer.source
553
554                                 #self["list"].instance.setZPosition(1)
555                                 self.list = []
556                                 if (self.wizard[self.currStep].has_key("dynamiclist")):
557                                         print "dynamic list, calling",  self.wizard[self.currStep]["dynamiclist"]
558                                         newlist = eval("self." + self.wizard[self.currStep]["dynamiclist"] + "()")
559                                         #self.wizard[self.currStep]["evaluatedlist"] = []
560                                         for entry in newlist:
561                                                 #self.wizard[self.currStep]["evaluatedlist"].append(entry)
562                                                 self.list.append(entry)
563                                         #del self.wizard[self.currStep]["dynamiclist"]
564                                 if (len(self.wizard[self.currStep]["list"]) > 0):
565                                         #self["list"].instance.setZPosition(2)
566                                         for x in self.wizard[self.currStep]["list"]:
567                                                 self.list.append((self.getTranslation(x[0]), x[1]))
568                                 self.wizard[self.currStep]["evaluatedlist"] = self.list
569                                 self["list"].list = self.list
570                                 self["list"].index = 0
571                         else:
572                                 self["list"].hide()
573         
574                         if self.showConfig:
575                                 print "showing config"
576                                 self["config"].instance.setZPosition(1)
577                                 if self.wizard[self.currStep]["config"]["type"] == "dynamic":
578                                                 print "config type is dynamic"
579                                                 self["config"].instance.setZPosition(2)
580                                                 self["config"].l.setList(eval("self." + self.wizard[self.currStep]["config"]["source"])())
581                                 elif (self.wizard[self.currStep]["config"]["screen"] != None):
582                                         if self.wizard[self.currStep]["config"]["type"] == "standalone":
583                                                 print "Type is standalone"
584                                                 self.session.openWithCallback(self.ok, self.wizard[self.currStep]["config"]["screen"])
585                                         else:
586                                                 self["config"].instance.setZPosition(2)
587                                                 print "wizard screen", self.wizard[self.currStep]["config"]["screen"]
588                                                 if self.wizard[self.currStep]["config"]["args"] == None:
589                                                         self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"])
590                                                 else:
591                                                         self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
592                                                 self["config"].l.setList(self.configInstance["config"].list)
593                                                 callbacks = self.configInstance["config"].onSelectionChanged
594                                                 self.configInstance["config"].destroy()
595                                                 print "clearConfigList", self.configInstance["config"], self["config"]
596                                                 self.configInstance["config"] = self["config"]
597                                                 self.configInstance["config"].onSelectionChanged = callbacks
598                                                 print "clearConfigList", self.configInstance["config"], self["config"]
599                                 else:
600                                         self["config"].l.setList([])
601                         else:
602                                 if self.has_key("config"):
603                                         self["config"].hide()
604
605         def timeoutCounterFired(self):
606                 self.timeoutCounter -= 1
607                 print "timeoutCounter:", self.timeoutCounter
608                 if self.timeoutCounter == 0:
609                         if self.wizard[self.currStep]["timeoutaction"] == "selectnext":
610                                 print "selection next item"
611                                 self.down()
612                         else:
613                                 if self.wizard[self.currStep]["timeoutaction"] == "changestep":
614                                         self.finished(gotoStep = self.wizard[self.currStep]["timeoutstep"])
615                 self.updateText()
616
617 class WizardManager:
618         def __init__(self):
619                 self.wizards = []
620         
621         def registerWizard(self, wizard, precondition, priority = 0):
622                 self.wizards.append((wizard, precondition, priority))
623         
624         def getWizards(self):
625                 # x[1] is precondition
626                 for wizard in self.wizards:
627                         wizard[0].isLastWizard = False
628                 if len(self.wizards) > 0:
629                         self.wizards[-1][0].isLastWizard = True
630                 return [(x[2], x[0]) for x in self.wizards if x[1] == 1]
631
632 wizardManager = WizardManager()