[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:
Antoine Durand-Gasselin 2009-08-25 16:42:04 +02:00
parent 63bdff02a0
commit 0d44a363eb
2 changed files with 11 additions and 9 deletions

View file

@ -847,7 +847,7 @@ class Dialog:
self._perform_no_options('--clear') self._perform_no_options('--clear')
def form(self, text, height=0, width=0, form_height=20, fields=[], auto_place=True, **kwargs): def form(self, text, height=0, width=0, form_height=20, fields=[], auto_place=True, **kwargs):
"""Display a form dialog box. """Display a form dialog box.
text -- text to display in the box text -- text to display in the box
height -- height of the box height -- height of the box
width -- width of the box width -- width of the box
@ -874,7 +874,7 @@ class Dialog:
for t in fields: for t in fields:
if len(t[0]) > max_label_len: if len(t[0]) > max_label_len:
max_label_len = len(t[0]); max_label_len = len(t[0]);
line = 1 line = 1
for t in fields: for t in fields:
label = t[0] label = t[0]

View file

@ -21,12 +21,15 @@ class DialogStepGenerator():
self.d = dialog.Dialog() self.d = dialog.Dialog()
self.d.add_persistent_args(["--backtitle", backtitle]) 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): def fn(dico, default):
fields = [ ( field[1], default.get(field[0], dico.get(field[0], ''))) + field[2:] for field in form ] 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) rc, res = self.d.form(enonce, fields = fields, title=title, **kw)
if rc == 2: really_quit(dico) self._check_rc(rc)
if rc == 1: raise PreviousStep
for field, val in izip (form, res): for field, val in izip (form, res):
dico[field[0]] = val dico[field[0]] = val
return dico return dico
@ -34,9 +37,8 @@ class DialogStepGenerator():
def select_step(self, title, enonce, var, choix): def select_step(self, title, enonce, var, choix):
def fn(dico, default): def fn(dico, default):
rc, res = self.d.menu(enonce, choices = choix, title = title) rc, res = self.d.inputbox(enonce, title = title, init = dico.get(var, ''), **kw)
if rc == 2: really_quit(dico) self._check_rc(rc)
if rc == 1: raise PreviousStep
dico[var] = res dico[var] = res
return dico return dico
return Step(fn) return Step(fn)