def __init__(self, parent, cur_index): self.parent = parent group = [] for i, option in enumerate(self.parent._options): if option.enabled: btn = ClickableThing(option.label) connect_signal(btn, 'click', self.click, i) if i == cur_index: rhs = '\N{BLACK LEFT-POINTING SMALL TRIANGLE} ' else: rhs = '' else: btn = option.label rhs = '' row = Columns([ (1, Text("")), btn, (2, Text(rhs)), ]) if option.enabled: row = AttrWrap(row, 'menu_button', 'menu_button focus') else: row = AttrWrap(row, 'info_minor') btn = UrwidPadding(row, width=self.parent._padding.width) group.append(btn) list_box = ListBox(group) list_box.base_widget.focus_position = cur_index super().__init__(Color.body(LineBox(list_box)))
def _build_table(self): widget = self.widget if self.field.takes_default_style: widget = Color.string_input(widget) self.caption_text = Text(self.field.caption) self.under_text = Text(self.help) if self.field.caption_first: self.caption_text.align = 'right' first_row = [self.caption_text, _Validator(self, widget)] else: first_row = [ _Validator( self, UrwidPadding(widget, align='right', width=widget_width(widget))), self.caption_text, ] self._rows = [ Toggleable(TableRow(row)) for row in [ first_row, [Text(""), self.under_text], ] ] self._table = TablePile(self._rows, spacing=2, colspecs=form_colspecs)
def __init__(self, keyboard_detector, step): # step is an instance of pc105.Step self.keyboard_detector = keyboard_detector self.step = step lb = LineBox( Pile([('pack', Text("")), ('pack', UrwidPadding(self.make_body(), left=2, right=2)), ('pack', Text(""))]), _("Keyboard auto-detection")) super().__init__(lb)
def __init__(self, parent, controller): self.parent = parent self.controller = controller pile = Pile([ UrwidPadding(Text(confirmation_text), left=2, right=2), button_pile([ cancel_btn(_("No"), on_press=self.cancel), danger_btn(_("Continue"), on_press=self.ok)]), Text(""), ]) lb = LineBox(pile, title=_("Confirm destructive action")) super().__init__(lb)
def set_bound_form_field(self, bff): super().set_bound_form_field(bff) self.all_rows = [] for kind, device in bff.form.all_devices: if kind == LABEL: self.all_rows.append(TableRow([ Text(" " + device.label), Text(humanize_size(device.size), align='right') ])) self.no_selector_rows.append(self.all_rows[-1]) self.all_rows.append(TableRow([ (2, Color.info_minor(Text(" " + device.desc()))) ])) self.no_selector_rows.append(self.all_rows[-1]) else: if kind == DEVICE: label = device.label prefix = " " elif kind == PART: label = _(" partition {}").format(device._number) prefix = " " else: raise Exception("unexpected kind {}".format(kind)) box = CheckBox( label, on_state_change=self._state_change_device, user_data=device) self.device_to_checkbox[device] = box size = Text(humanize_size(device.size), align='right') self.all_rows.append(Color.menu_button(TableRow([box, size]))) self.no_selector_rows.append(self.all_rows[-1]) selector = Selector(['active', 'spare']) connect_signal( selector, 'select', self._select_active_spare, device) selector = Toggleable( UrwidPadding( Color.menu_button(selector), left=len(prefix))) selector.disable() self.device_to_selector[device] = selector self.all_rows.append(TableRow([(2, selector)])) # Do not append that one to no_selector_rows! self.all_rows.append(self._summarize(prefix, device)) self.no_selector_rows.append(self.all_rows[-1]) self.table.set_contents(self.all_rows) log.debug("%s", self.table._w.focus_position)
def __init__(self, opts, index=0): self._icon = ClickableThing(Text("")) self._padding = UrwidPadding( AttrWrap( Columns([ (1, Text('[')), self._icon, (3, Text('\N{BLACK DOWN-POINTING SMALL TRIANGLE} ]')), ], dividechars=1), 'menu_button', 'menu_button focus')) options = [] for opt in opts: options.append(Option(opt)) self.options = options self._set_index(index) super().__init__(_Launcher(self, self._padding))
def _build_table(self): widget = self.widget if self.field.takes_default_style: widget = Color.string_input(widget) if self.help is not NO_HELP: self.under_text = Text(self.help) else: self.under_text = Text("") if self.field.caption is NO_CAPTION: first_row = [(2, _Validator(self, widget))] second_row = [(2, self.under_text)] else: self.caption_text = Text(_(self.field.caption)) if self.field.caption_first: self.caption_text.align = 'right' first_row = [self.caption_text, _Validator(self, widget)] else: first_row = [ _Validator( self, UrwidPadding(widget, align='right', width=widget_width(widget))), self.caption_text, ] second_row = [Text(""), self.under_text] rows = [first_row] if self.help is not NO_HELP: rows.append(second_row) self._rows = [Toggleable(TableRow(row)) for row in rows] self._table = TablePile(self._rows, spacing=2, colspecs=form_colspecs)