[dialogwizard/dialogwizard] on prefere utiliser une methode generique pour verifier que l'appel a dialog s'est bien effectue
Ignore-this: 4323b4c019e56d8381587b82e183908d darcs-hash:20090825144204-bd074-c765bda3efeedadc05914be0937530b27025cb33.gz
This commit is contained in:
parent
63bdff02a0
commit
0d44a363eb
2 changed files with 11 additions and 9 deletions
|
@ -847,7 +847,7 @@ class Dialog:
|
|||
self._perform_no_options('--clear')
|
||||
def form(self, text, height=0, width=0, form_height=20, fields=[], auto_place=True, **kwargs):
|
||||
"""Display a form dialog box.
|
||||
|
||||
|
||||
text -- text to display in the box
|
||||
height -- height of the box
|
||||
width -- width of the box
|
||||
|
@ -874,7 +874,7 @@ class Dialog:
|
|||
for t in fields:
|
||||
if len(t[0]) > max_label_len:
|
||||
max_label_len = len(t[0]);
|
||||
|
||||
|
||||
line = 1
|
||||
for t in fields:
|
||||
label = t[0]
|
||||
|
|
|
@ -21,12 +21,15 @@ class DialogStepGenerator():
|
|||
self.d = dialog.Dialog()
|
||||
self.d.add_persistent_args(["--backtitle", backtitle])
|
||||
|
||||
def form_step(self, title, enonce, form):
|
||||
def _check_rc(self, rc):
|
||||
if rc == 2: really_quit(dico)
|
||||
if rc == 1: raise PreviousStep
|
||||
|
||||
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)
|
||||
if rc == 2: really_quit(dico)
|
||||
if rc == 1: raise PreviousStep
|
||||
rc, res = self.d.form(enonce, fields = fields, title=title, **kw)
|
||||
self._check_rc(rc)
|
||||
for field, val in izip (form, res):
|
||||
dico[field[0]] = val
|
||||
return dico
|
||||
|
@ -34,9 +37,8 @@ class DialogStepGenerator():
|
|||
|
||||
def select_step(self, title, enonce, var, choix):
|
||||
def fn(dico, default):
|
||||
rc, res = self.d.menu(enonce, choices = choix, title = title)
|
||||
if rc == 2: really_quit(dico)
|
||||
if rc == 1: raise PreviousStep
|
||||
rc, res = self.d.inputbox(enonce, title = title, init = dico.get(var, ''), **kw)
|
||||
self._check_rc(rc)
|
||||
dico[var] = res
|
||||
return dico
|
||||
return Step(fn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue