Esempio n. 1
0
 def __init__(self, model, controller, method):
     self.model = model
     self.controller = controller
     self.method = method
     cancel = cancel_btn(_("Cancel"), on_press=self.cancel)
     rows = []
     for disk in self.model.all_disks():
         if disk.size >= dehumanize_size("6G"):
             disk_btn = ClickableIcon(disk.label)
             connect_signal(
                 disk_btn, 'click', self.choose_disk, disk)
             attr = Color.done_button
         else:
             disk_btn = Text("  "+disk.label)
             attr = Color.info_minor
         rows.append(attr(TableRow([
             Text('['),
             disk_btn,
             Text(humanize_size(disk.size), align='right'),
             Text('\N{BLACK RIGHT-POINTING SMALL TRIANGLE}'),
             Text(']'),
             ])))
     super().__init__(screen(
         TableListBox(rows, spacing=1, colspecs={
             1: ColSpec(can_shrink=True, min_width=20, rpad=2),
             2: ColSpec(min_width=9),
             }),
         button_pile([cancel]),
         focus_buttons=False,
         excerpt=(
             excerpts[method]
             + "\n\n"
             + _("Choose the disk to install to:"))))
Esempio n. 2
0
 def cells_for_report(self, report):
     date = report.pr.get("Date", "???")
     icon = ClickableIcon(date)
     connect_signal(icon, 'click', self.open_report, report)
     return [
         Text("["),
         icon,
         Text(_(report.kind.value)),
         Text(_(self.state_for_report(report))),
         Text("]"),
         ]
Esempio n. 3
0
 def __init__(self, model, controller, method):
     self.model = model
     self.controller = controller
     self.method = method
     cancel = cancel_btn(_("Cancel"), on_press=self.cancel)
     rows = []
     for disk in self.model.all_disks():
         for obj, cells in summarize_device(disk):
             wrap = Color.info_minor
             if obj is disk:
                 start, end = '[', ']'
                 arrow = '\N{BLACK RIGHT-POINTING SMALL TRIANGLE}'
                 if disk.size >= dehumanize_size("6G"):
                     arrow = ClickableIcon(arrow)
                     connect_signal(arrow, 'click', self.choose_disk, disk)
                     wrap = _wrap_button_row
             else:
                 start, arrow, end = '', '', ''
             if isinstance(arrow, str):
                 arrow = Text(arrow)
             rows.append(
                 wrap(TableRow([Text(start)] + cells +
                               [arrow, Text(end)])))
         rows.append(TableRow([Text("")]))
     super().__init__(
         screen(TableListBox(rows[:-1],
                             spacing=2,
                             colspecs={
                                 0: ColSpec(rpad=1),
                                 2: ColSpec(can_shrink=True),
                                 4: ColSpec(min_width=9),
                                 5: ColSpec(rpad=1),
                             },
                             align='center'),
                button_pile([cancel]),
                focus_buttons=False,
                excerpt=(excerpts[method] + "\n\n" +
                         _("Choose the disk to install to:"))))
Esempio n. 4
0
 def __init__(self, parent, cur_index):
     self.parent = parent
     group = []
     for i, option in enumerate(self.parent._options):
         if option.enabled:
             btn = ClickableIcon(" " + option.label)
             connect_signal(btn, 'click', self.click, i)
             if i == cur_index:
                 rhs = '\N{BLACK LEFT-POINTING SMALL TRIANGLE} '
             else:
                 rhs = '  '
             btn = Columns([
                 btn,
                 (2, Text(rhs)),
             ])
             btn = AttrWrap(btn, 'menu_button', 'menu_button focus')
         else:
             btn = Text(" " + option.label)
             btn = AttrWrap(btn, 'info_minor')
         btn = UrwidPadding(btn, 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)))
Esempio n. 5
0
def menu_item(text, on_press=None):
    icon = ClickableIcon(" " + text + " ")
    if on_press is not None:
        connect_signal(icon, 'click', on_press)
    return Color.frame_button(icon)