def __init__(self, parent, obj): self.parent = parent self.obj = obj delete_ok, reason = can_delete(obj) if delete_ok: title = _("Confirm deletion of {}").format(obj.desc()) lines = [ _("Do you really want to delete {}?").format(obj.label), "", ] new_lines, delete_funcs = delete_consequences( self.parent.controller, obj) lines.extend(new_lines) self.delete_funcs = delete_funcs else: title = "Cannot delete {}".format(obj.desc()) lines = [ _("Cannot delete {} because {}").format(obj.label, reason) ] delete_btn = danger_btn(label=_("Delete"), on_press=self.confirm) if not delete_ok: delete_btn = WidgetDisable( Color.info_minor(delete_btn.original_widget)) widgets = [ Text("\n".join(lines)), Text(""), button_pile([ delete_btn, other_btn(label=_("Cancel"), on_press=self.cancel), ]), ] super().__init__(title, widgets, 0, 2)
def _cols(self): text = Text(self.caption, align="right") if self._enabled: input = Color.string_input(_Validator(self, self.widget)) else: input = self.widget cols = [(self._longest_caption, text), input] cols = Columns(cols, dividechars=2) if self._enabled: return cols else: return WidgetDisable(Color.info_minor(cols))
def make_body(self): body = super().make_body() if self.partition is not None: btn = delete_btn(_("Delete"), on_press=self.delete) if self.partition.flag == "boot": btn = WidgetDisable(Color.info_minor(btn.original_widget)) body.extend([ Text(""), button_pile([btn]), ]) pass return body
def _cols(self): text = Text(self.caption, align="right") if self._enabled: input = Color.string_input(_Validator(self, self.widget)) else: input = self.widget if self.help is not None: help = Help(self.parent_view, self.help) else: help = Text("") cols = [ (self._longest_caption, text), input, (3, help), ] cols = Columns(cols, dividechars=2) if self._enabled: return cols else: return WidgetDisable(Color.info_minor(cols))
def make_body(self): body = super().make_body() if self.partition is not None: if self.partition.flag == "boot": body[0:0] = [ Text(_(boot_partition_description)), Text(""), ] elif self.partition.flag == "bios_grub": body[0:0] = [ Text(_(bios_grub_partition_description)), Text(""), ] btn = delete_btn(_("Delete"), on_press=self.delete) if self.partition.flag in ["boot", "bios_grub"]: btn = WidgetDisable(Color.info_minor(btn.original_widget)) body.extend([ Text(""), button_pile([btn]), ]) return body
def disabled(w): return WidgetDisable(AttrMap(w, _disable_everything_map))
def disable(self): if self.enabled: self.original_widget = WidgetDisable( Color.info_minor(self.original.original_widget)) self.enabled = False