[lib/dialogwizard] on traite les exceptions
Ignore-this: 9a90bd32263c02b9e7f2909b2f69e301 darcs-hash:20090929132138-bd074-50fd73412bff90c7295edd03353a5752eb3b3db7.gz
This commit is contained in:
parent
de68b18b75
commit
277b1c4bd5
2 changed files with 20 additions and 9 deletions
|
@ -6,13 +6,17 @@
|
|||
# Author: Antoine Durand-Gasselin <adg@crans.org>
|
||||
#
|
||||
|
||||
from wizard import Step, PreviousStep, EndScenario
|
||||
from wizard import Step, PreviousStep, EndScenario, TryAgain
|
||||
from itertools import izip
|
||||
import dialog, time
|
||||
|
||||
def really_quit(dico):
|
||||
raise EndScenario("game over!", data = dico)
|
||||
|
||||
def error_handler(exc):
|
||||
dialog.Dialog().msgbox('Erreur:', exc.__repr__())
|
||||
raise TryAgain()
|
||||
|
||||
class DialogStepGenerator():
|
||||
u"""This class defines a step, that will prompt the user for various
|
||||
fields."""
|
||||
|
@ -34,7 +38,7 @@ class DialogStepGenerator():
|
|||
for field in sform:
|
||||
item = default.get(field['var'], dico.get(field['var'], ''))
|
||||
field['item'] = item
|
||||
rc, res = self.d.form(enonce, fields = sform, title=title, **kw)
|
||||
rc, res = self.d.form(enonce % dico, fields = sform, title=title % dico, **kw)
|
||||
self._check_rc(rc)
|
||||
for field, val in izip (sform, res):
|
||||
dico[field['var']] = val
|
||||
|
@ -51,7 +55,7 @@ class DialogStepGenerator():
|
|||
if c.get('show_cond', lambda x : True)(dico):
|
||||
schoix.append((c['label'], c['item']))
|
||||
print schoix
|
||||
rc, res = self.d.menu(enonce, choices = schoix, title = title, **kw)
|
||||
rc, res = self.d.menu(enonce % dico, choices = schoix, title = title % dico, **kw)
|
||||
self._check_rc(rc)
|
||||
dico[var] = res
|
||||
return dico
|
||||
|
@ -59,13 +63,13 @@ class DialogStepGenerator():
|
|||
|
||||
def input_step(self, title, enonce, var, **kw):
|
||||
def fn(dico, default):
|
||||
rc, res = self.d.inputbox(enonce, title = title, init = dico.get(var, ''), **kw)
|
||||
rc, res = self.d.inputbox(enonce % dico, title = title % dico, init = dico.get(var, ''), **kw)
|
||||
self._check_rc(rc)
|
||||
dico[var] = res
|
||||
return dico
|
||||
return Step(fn)
|
||||
|
||||
def checklist_step(self, title, enonce, liste):
|
||||
def checklist_step(self, title, enonce, liste, **kw):
|
||||
def fn(dico, default):
|
||||
sliste = []
|
||||
for c in liste:
|
||||
|
@ -78,7 +82,7 @@ class DialogStepGenerator():
|
|||
if dico.get(c['var'], False): checked = 'on'
|
||||
else: checked = 'off'
|
||||
sliste.append((c['var'], c['item'], checked))
|
||||
rc, res = self.d.checklist(enonce, title = title, choices = sliste, **kw)
|
||||
rc, res = self.d.checklist(enonce % dico, title = title % dico, choices = sliste, **kw)
|
||||
self._check_rc(rc)
|
||||
for tag, item, status in liste:
|
||||
if tag in res:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue