def _make_widget(self, form): # This will need to do something different for editing an # existing partition that is already formatted. options = [ ('ext4', True), ('xfs', True), ('btrfs', True), ('---', False), ('swap', True), ] if form.existing_fs_type is None: options = options + [ ('---', False), (_('Leave unformatted'), True, None), ] else: label = _('Leave formatted as {fstype}').format( fstype=form.existing_fs_type) options = [ (label, True, None), ('---', False), ] + options sel = Selector(opts=options) sel.value = None return sel
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 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): choices = [ (_("No"), True, None), (_("from Github"), True, "gh"), (_("from Launchpad"), True, "lp"), (_("from Ubuntu One account"), True, "sso"), ] self.selector = Selector(choices) connect_signal(self.selector, 'select', self._select) self.username = UsernameEditor() self.email = EmailEditor() connect_signal(self.username, 'change', self._change) self.cols = Columns([ self.selector, (1, Text("")), (2, Color.body(Text(""))), Color.body(Text("")) ]) super().__init__(self.cols)
def _make_widget(self, form): return Selector(self.choices)
def _make_widget(self, form): return Selector(opts=FilesystemModel.supported_filesystems)