[lib/dialogwizard] on peut mettre des champs plus élaborés
Ignore-this: 197a121bac23ae72a086535cc612311c darcs-hash:20090906134550-bd074-801938dc1daca12012adb24aeb4bff939ab75728.gz
This commit is contained in:
parent
feaf2215e6
commit
d79f7ec2f0
3 changed files with 80 additions and 97 deletions
|
@ -25,19 +25,33 @@ class DialogStepGenerator():
|
|||
if rc == 2: really_quit(dico)
|
||||
if rc == 1: raise PreviousStep
|
||||
|
||||
def _skim_choices(self, choices, dico):
|
||||
return [ f for f in choices if f.get('show_cond', lambda x : True)(dico) ]
|
||||
|
||||
def form_step(self, title, enonce, form, **kw):
|
||||
def fn(dico, default):
|
||||
fields = [ ( field[1], default.get(field[0], dico.get(field[0], ''))) + field[2:] for field in form ]
|
||||
rc, res = self.d.form(enonce, fields = fields, title=title, **kw)
|
||||
sform = self._skim_choices(form, dico)
|
||||
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)
|
||||
self._check_rc(rc)
|
||||
for field, val in izip (form, res):
|
||||
dico[field[0]] = val
|
||||
for field, val in izip (sform, res):
|
||||
dico[field['var']] = val
|
||||
return dico
|
||||
return Step(fn)
|
||||
|
||||
def select_step(self, title, enonce, var, choix, **kw):
|
||||
def fn(dico, default):
|
||||
rc, res = self.d.menu(enonce, choices = choix, title = title, **kw)
|
||||
schoix = []
|
||||
for c in choix:
|
||||
try:
|
||||
schoix.append((c[0], c[1]))
|
||||
except Exception,e:
|
||||
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)
|
||||
self._check_rc(rc)
|
||||
dico[var] = res
|
||||
return dico
|
||||
|
@ -53,8 +67,14 @@ class DialogStepGenerator():
|
|||
|
||||
def checklist_step(self, title, enonce, liste):
|
||||
def fn(dico, default):
|
||||
choix = [var, txt, dico.get(var, 'off') for var, txt in liste]
|
||||
rc, res = self.d.checklist(enonce, title = title, choices = choix, **kw)
|
||||
sliste = []
|
||||
for c in liste:
|
||||
try:
|
||||
sliste.append((c[0], c[1], dico.get(c[0], 'off')))
|
||||
except Exception,e:
|
||||
if c.get('show_cond', lambda x : True)(dico):
|
||||
sliste.append((c['var'], c['item'], dico.get(c['var'], 'off')))
|
||||
rc, res = self.d.checklist(enonce, title = title, 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