def make_body(self): return Pile([ Text(_("Keyboard detection starting. You will be asked a series of questions about your keyboard. Press escape at any time to go back to the previous screen.")), Text(""), button_pile([ ok_btn(label=_("OK"), on_press=self.ok), ok_btn(label=_("Cancel"), on_press=self.cancel), ]), ])
def __init__(self, controller): self.controller = controller guided = ok_btn(_("Use An Entire Disk"), on_press=self.guided) manual = ok_btn(_("Manual"), on_press=self.manual) back = back_btn(_("Back"), on_press=self.cancel) lb = ListBox([ Padding.center_70(Text("")), Padding.center_70(Text(text)), Padding.center_70(Text("")), button_pile([guided, manual, back]), ]) super().__init__(lb)
def __init__(self, controller): self.controller = controller direct = ok_btn( _("Use An Entire Disk"), on_press=self.guided, user_arg="direct") lvm = ok_btn( _("Use An Entire Disk And Set Up LVM"), on_press=self.guided, user_arg="lvm") manual = ok_btn(_("Manual"), on_press=self.manual) back = back_btn(_("Back"), on_press=self.cancel) super().__init__(screen( rows=[button_pile([direct, lvm, manual, back]), Text("")], buttons=None, focus_buttons=False, excerpt=text))
def __init__(self, controller): self.controller = controller self.spinner = Spinner(controller.loop) self.reboot_btn = Toggleable( ok_btn(_("Reboot Now"), on_press=self.reboot)) self.exit_btn = cancel_btn(_("Exit To Shell"), on_press=self.quit) self.view_log_btn = other_btn(_("View full log"), on_press=self.view_log) self.event_listbox = ListBox() self.event_linebox = MyLineBox(self.event_listbox) self.event_buttons = button_pile([self.view_log_btn]) event_body = [ ('pack', Text("")), ('weight', 1, Padding.center_79(self.event_linebox, min_width=76)), ('pack', Text("")), ('pack', self.event_buttons), ('pack', Text("")), ] self.event_pile = Pile(event_body) self.log_listbox = ListBox() log_linebox = MyLineBox(self.log_listbox, _("Full installer output")) log_body = [ ('weight', 1, log_linebox), ('pack', button_pile([other_btn(_("Close"), on_press=self.close_log)])), ] self.log_pile = Pile(log_body) super().__init__(self.event_pile)
def __init__(self, controller): self.controller = controller self.ongoing = {} # context -> line containing a spinner self.reboot_btn = Toggleable(ok_btn( _("Reboot Now"), on_press=self.reboot)) self.view_error_btn = cancel_btn( _("View error report"), on_press=self.view_error) self.view_log_btn = other_btn( _("View full log"), on_press=self.view_log) self.continue_btn = other_btn( _("Continue"), on_press=self.continue_) self.event_listbox = ListBox() self.event_linebox = MyLineBox(self.event_listbox) self.event_buttons = button_pile([self.view_log_btn]) event_body = [ ('weight', 1, Padding.center_79(self.event_linebox, min_width=76)), ('pack', Text("")), ('pack', self.event_buttons), ('pack', Text("")), ] self.event_pile = Pile(event_body) self.log_listbox = ListBox() log_linebox = MyLineBox(self.log_listbox, _("Full installer output")) log_body = [ ('weight', 1, log_linebox), ('pack', button_pile([other_btn(_("Close"), on_press=self.close_log)])), ] self.log_pile = Pile(log_body) super().__init__(self.event_pile)
def make_main_screen(self, snap_list): self.snap_boxes = {} body = [] for snap in snap_list: box = self.snap_boxes[snap.name] = SnapCheckBox(self, snap) row = [ box, Text(snap.publisher), Text(snap.summary, wrap='clip'), ] body.append(Color.menu_button(TableRow(row))) table = NoTabCyclingTableListBox(body, colspecs={ 1: ColSpec(omittable=True), 2: ColSpec(pack=False, min_width=40), }) ok = ok_btn(label=_("Done"), on_press=self.done) self._main_screen = screen( table, [ok], focus_buttons=False, excerpt=_( "These are popular snaps in server environments. Select or " "deselect with SPACE, press ENTER to see more details of the " "package, publisher and versions available."))
def __init__(self, parent, result, key_material, fingerprints): self.parent = parent self.result = result self.key_material = key_material ok = ok_btn(label=_("Yes"), on_press=self.ok) cancel = cancel_btn(label=_("No"), on_press=self.cancel) if len(fingerprints) > 1: title = _("Confirm SSH keys") header = _("Keys with the following fingerprints were fetched. " "Do you want to use them?") else: title = _("Confirm SSH key") header = _("A key with the following fingerprint was fetched. " "Do you want to use it?") fingerprints = Pile( [Text(fingerprint) for fingerprint in fingerprints]) super().__init__(title, [ Text(header), Text(""), fingerprints, Text(""), button_pile([ok, cancel]), ], 2, 4)
def offer_retry(self): self._w = screen( [Text(_("Sorry, loading snaps from the store failed."))], [ other_btn(label=_("Try again"), on_press=self.load), ok_btn(label=_("Continue"), on_press=self.done), ])
def wait_load(self): spinner = Spinner(self.controller.app.aio_loop, style='dots') spinner.start() self._w = screen( [spinner], [ok_btn(label=_("Continue"), on_press=self.done)], excerpt=_("Loading server snaps from store, please wait...")) schedule_task(self._wait_load(spinner))
def __init__(self, controller): self.controller = controller super().__init__(Pile([ ListBox([Text('')]), # need to have a listbox or something else "stretchy" here or urwid complains. ('pack', button_pile([ok_btn("OK", on_press=self.confirm)])), ('pack', Text("")), ], focus_item=1))
def __init__(self, parent, setting): self.parent = parent self.setting = setting self.selector = Selector(toggle_options) self.selector.value = 'alt_shift_toggle' if self.parent.model.setting.toggle: try: self.selector.value = self.parent.model.setting.toggle except AttributeError: pass widgets = [ Text(_(toggle_text)), Text(""), Padding.center_79( Columns([ ('pack', Text(_("Shortcut: "))), Color.string_input(self.selector), ])), Text(""), button_pile([ ok_btn(label=_("OK"), on_press=self.ok), cancel_btn(label=_("Cancel"), on_press=self.cancel), ]), ] super().__init__(_("Select layout toggle"), widgets, stretchy_index=0, focus_index=4)
def __init__(self, controller): self.controller = controller direct = ok_btn( _("Use An Entire Disk"), on_press=self.guided, user_arg="direct") lvm = ok_btn( _("Use An Entire Disk And Set Up LVM"), on_press=self.guided, user_arg="lvm") manual = ok_btn(_("Manual"), on_press=self.manual) back = back_btn(_("Back"), on_press=self.cancel) lb = ListBox([ Padding.center_70(Text("")), Padding.center_70(Text(_(text))), Padding.center_70(Text("")), button_pile([direct, lvm, manual, back]), ]) super().__init__(lb)
def make_body(self): return Pile([ Text(_("Is the following key present on your keyboard?")), Text(""), Text(self.step.symbol, align="center"), Text(""), button_pile([ ok_btn(label=_("Yes"), on_press=self.yes), other_btn(label=_("No"), on_press=self.no), ]), ])
def load(self, sender=None): t = self.controller.get_snap_list_task() if t.done(): self.loaded() return spinner = Spinner(self.controller.app.aio_loop, style='dots') spinner.start() self._w = screen( [spinner], [ok_btn(label=_("Continue"), on_press=self.done)], excerpt=_("Loading server snaps from store, please wait...")) schedule_task(self._wait(t, spinner))
def make_body(self): model = self.keyboard_detector.keyboard_view.model layout, variant = model.lookup(self.step.result) var_desc = [] if variant is not None: var_desc = [Text(_(" Variant: ") + variant)] return Pile([ Text(self.preamble), Text(_(" Layout: ") + layout), ] + var_desc + [ Text(self.postamble), button_pile([ok_btn(label=_("OK"), on_press=self.ok)]), ])
def make_body(self): self.layout, self.variant = self._kview.lookup( self.step.layout, self.step.variant) layout_text = _("Layout") var_text = _("Variant") width = max(len(layout_text), len(var_text), 12) return Pile([ Text(_(self.preamble)), Text("%*s: %s" % (width, layout_text, self.layout.name)), Text("%*s: %s" % (width, var_text, self.variant.name)), Text(_(self.postamble)), button_pile([ok_btn(label=_("OK"), on_press=self.ok)]), ])
def show_complete(self, include_exit=False): p = self.event_buttons.original_widget p.contents.append( (ok_btn(_("Reboot Now"), on_press=self.reboot), p.options('pack'))) if include_exit: p.contents.append( (cancel_btn(_("Exit To Shell"), on_press=self.quit), p.options('pack'))) w = 0 for b, o in p.contents: w = max(len(b.base_widget.label), w) self.event_buttons.width = self.event_buttons.min_width = w + 4 self.event_pile.focus_position = 3 p.focus_position = 1
def show_complete(self, include_exit=False): buttons = [ ok_btn(_("Reboot Now"), on_press=self.reboot), ] if include_exit: buttons.append(cancel_btn(_("Exit To Shell"), on_press=self.quit)) buttons = button_pile(buttons) new_pile = Pile([ ('pack', Text("")), buttons, ('pack', Text("")), ]) self.pile.contents[-1] = (new_pile, self.pile.options('pack')) self.pile.focus_position = len(self.pile.contents) - 1
def make_body(self): model = self.keyboard_detector.keyboard_view.model layout, variant = model.lookup(self.step.result) var_desc = [] layout_text = _("Layout") var_text = _("Variant") width = max(len(layout_text), len(var_text), 12) if variant is not None: var_desc = [Text("%*s: %s" % (width, var_text, variant))] return Pile([ Text(_(self.preamble)), Text("%*s: %s" % (width, layout_text, layout)), ] + var_desc + [ Text(_(self.postamble)), button_pile([ok_btn(label=_("OK"), on_press=self.ok)]), ])
def make_main_screen(self, snap_list): self.name_len = max([len(snap.name) for snap in snap_list]) self.publisher_len = max([len(snap.publisher) for snap in snap_list]) self.snap_rows = {} body = [] for snap in snap_list: row = SnapListRow(self, snap, self.name_len, self.publisher_len) self.snap_rows[snap.name] = row body.append(row) ok = ok_btn(label=_("OK"), on_press=self.done) self._main_screen = screen( NoTabCyclingListBox(body), [ok], focus_buttons=False, excerpt=_( "These are popular snaps in server environments. Select or " "deselect with SPACE, press ENTER to see more details of the " "package, publisher and versions available."))
def make_main_screen(self, snap_list): self.snap_boxes = {} body = [] preinstalled = self.get_preinstalled_snaps() for snap in snap_list: if snap.name in preinstalled: log.debug("not offering preseeded snap %r", snap.name) continue box = self.snap_boxes[snap.name] = SnapCheckBox( self, snap, snap.name in self.to_install) publisher = snap.publisher if snap.verified: publisher = [publisher, ('verified', '\N{check mark}')] row = [ box, Text(publisher), Text(snap.summary, wrap='clip'), Text("\N{BLACK RIGHT-POINTING SMALL TRIANGLE}") ] body.append( AttrMap( TableRow(row), 'menu_button', { None: 'menu_button focus', 'verified': 'verified focus' }, )) table = NoTabCyclingTableListBox(body, colspecs={ 1: ColSpec(omittable=True), 2: ColSpec(pack=False, min_width=40), }) ok = ok_btn(label=_("Done"), on_press=self.done) cancel = cancel_btn(label=_("Back"), on_press=self.cancel) self._main_screen = screen( table, [ok, cancel], focus_buttons=False, excerpt=_( "These are popular snaps in server environments. Select or " "deselect with SPACE, press ENTER to see more details of the " "package, publisher and versions available."))
def load(self, sender=None): spinner = None called = False def callback(snap_list): nonlocal called called = True if spinner is not None: spinner.stop() if len(snap_list) == 0: self.offer_retry() else: self.make_main_screen(snap_list) self.show_main_screen() self.controller.get_snap_list(callback) if called: return spinner = Spinner(self.controller.loop, style='dots') spinner.start() self._w = screen( [spinner], [ok_btn(label=_("Continue"), on_press=self.done)], excerpt=_("Loading server snaps from store, please wait..."))
def _build_buttons(self): self.buttons = [ ok_btn(on_press=self.confirm), ] return Pile(self.buttons)
def make_body(self): return Pile([ Text(_("Keyboard auto detection failed, sorry")), Text(""), button_pile([ok_btn(label="OK", on_press=self.ok)]), ])
def _build_buttons(self): self.buttons = [ Color.button(ok_btn(on_press=self.confirm), focus_map='button focus'), ] return Pile(self.buttons)