Revision aeb95900
b/image_creator/dialog_wizard.py | ||
---|---|---|
44 | 44 |
PAGE_WIDTH = 70 |
45 | 45 |
|
46 | 46 |
|
47 |
class WizardExit(Exception): |
|
48 |
pass |
|
49 |
|
|
50 |
|
|
47 | 51 |
class Wizard: |
48 | 52 |
def __init__(self, session): |
49 | 53 |
self.session = session |
... | ... | |
56 | 60 |
def run(self): |
57 | 61 |
idx = 0 |
58 | 62 |
while True: |
59 |
idx += self.pages[idx].run(self.session, idx, len(self.pages)) |
|
63 |
try: |
|
64 |
idx += self.pages[idx].run(self.session, idx, len(self.pages)) |
|
65 |
except WizardExit: |
|
66 |
return False |
|
60 | 67 |
|
61 | 68 |
if idx >= len(self.pages): |
62 | 69 |
break |
... | ... | |
69 | 76 |
class WizardPage: |
70 | 77 |
NEXT = 1 |
71 | 78 |
PREV = -1 |
72 |
EXIT = -255 |
|
73 | 79 |
|
74 | 80 |
def run(self, session, index, total): |
75 | 81 |
raise NotImplementedError |
... | ... | |
124 | 130 |
if ret == d.DIALOG_CANCEL: |
125 | 131 |
return self.PREV |
126 | 132 |
elif ret == d.DIALOG_EXTRA: |
127 |
return self.EXIT
|
|
133 |
raise WizardExit
|
|
128 | 134 |
elif ret == d.DIALOG_OK: |
129 | 135 |
return self.NEXT |
130 | 136 |
|
Also available in: Unified diff