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