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