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