From dee616171ab0e53367626c30e5077fe3d74f4929 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 3 Jul 2018 22:25:26 +1200 Subject: [PATCH] improve disk info dialog a bunch --- subiquity/ui/views/filesystem/disk_info.py | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/subiquity/ui/views/filesystem/disk_info.py b/subiquity/ui/views/filesystem/disk_info.py index 0ed20933..58dc93f7 100644 --- a/subiquity/ui/views/filesystem/disk_info.py +++ b/subiquity/ui/views/filesystem/disk_info.py @@ -19,28 +19,35 @@ from urwid import Text from subiquitycore.ui.buttons import done_btn from subiquitycore.ui.utils import button_pile from subiquitycore.ui.stretchy import Stretchy +from subiquitycore.ui.table import ColSpec, TablePile, TableRow log = logging.getLogger('subiquity.ui.filesystem.disk_info') +labels_keys = [ + ('Path:', 'devname'), + ('Vendor:', 'vendor'), + ('Model:', 'model'), + ('SerialNo:', 'serial'), + ('Size:', 'size'), + ('Bus:', 'bus'), + ('Rotational:', 'rotational'), + ('Path:', 'devpath'), +] + + class DiskInfoStretchy(Stretchy): def __init__(self, parent, disk): log.debug('DiskInfoView: {}'.format(disk)) self.parent = parent dinfo = disk.info_for_display() - template = """\ -{devname}:\n - Vendor: {vendor} - Model: {model} - SerialNo: {serial} - Size: {humansize} ({size}B) - Bus: {bus} - Rotational: {rotational} - Path: {devpath}""" - result = template.format(**dinfo) + rows = [] + for label, key in labels_keys: + v = str(dinfo[key]) + rows.append(TableRow([Text(label, align='right'), Text(v)])) widgets = [ - Text(result), + TablePile(rows, colspecs={1: ColSpec(can_shrink=True)}), Text(""), button_pile([done_btn(_("Close"), on_press=self.close)]), ]