def __init__(self): items = [] for step in steps.get_steps(): items.append(NavigatorEntry(step)) walker = urwid.SimpleListWalker(items) self._walker = walker self._active_entry = self._walker.get_focus()[0] urwid.connect_signal(walker, 'modified', self._on_focus_changed) linebox = urwid.LineBox(urwid.ListBox(walker)) linebox = urwid.AttrMap(linebox, 'default', 'button.active') super(Navigator, self).__init__(linebox)
def _load_step_views(self): for step in steps.get_steps(): try: # Import view's module if available mod = import_module('.' + step.view_module_name, self.__module__) except ImportError: logger.debug("no module view for step '%s'" % step.name) step.view_data = None else: # Retrieve view's class and instantiate it. view = getattr(mod, step.view_class_name + 'View')(self, step) step.view_data = view
def __run_steps(self): self._retcode = 1 for step in steps.get_steps(): assert (not step.is_disabled()) if not step.view_data: step.view_data = StepView(None, step) view = step.view_data if self._args.progress: self._progress_bar = ProgressBar(step.name) timer = GLib.timeout_add_seconds(1, self._on_timeout, step) view.run(self._args) if not step.is_done(): return self._retcode = 0
def set_focus(self, step): assert (not step.is_disabled()) self._walker.set_focus(steps.get_steps().index(step))
def get_focus(self): return steps.get_steps()[self._walker.get_focus()[1]]
def _select_next_step(self): start = steps.get_steps().index(self._current_step) for step in steps.get_steps()[start:]: if step.is_enabled() and not step.is_done(): self._select_step(step) return
def _select_first_step(self): self._select_step(steps.get_steps()[0])
def _quit(self): # Stop the running step, if any. for s in steps.get_steps(): s.cancel() logger.info(_("exiting..."))