improve disk info dialog a bunch
This commit is contained in:
parent
6bc361b237
commit
dee616171a
|
@ -19,28 +19,35 @@ from urwid import Text
|
||||||
from subiquitycore.ui.buttons import done_btn
|
from subiquitycore.ui.buttons import done_btn
|
||||||
from subiquitycore.ui.utils import button_pile
|
from subiquitycore.ui.utils import button_pile
|
||||||
from subiquitycore.ui.stretchy import Stretchy
|
from subiquitycore.ui.stretchy import Stretchy
|
||||||
|
from subiquitycore.ui.table import ColSpec, TablePile, TableRow
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger('subiquity.ui.filesystem.disk_info')
|
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):
|
class DiskInfoStretchy(Stretchy):
|
||||||
def __init__(self, parent, disk):
|
def __init__(self, parent, disk):
|
||||||
log.debug('DiskInfoView: {}'.format(disk))
|
log.debug('DiskInfoView: {}'.format(disk))
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
dinfo = disk.info_for_display()
|
dinfo = disk.info_for_display()
|
||||||
template = """\
|
rows = []
|
||||||
{devname}:\n
|
for label, key in labels_keys:
|
||||||
Vendor: {vendor}
|
v = str(dinfo[key])
|
||||||
Model: {model}
|
rows.append(TableRow([Text(label, align='right'), Text(v)]))
|
||||||
SerialNo: {serial}
|
|
||||||
Size: {humansize} ({size}B)
|
|
||||||
Bus: {bus}
|
|
||||||
Rotational: {rotational}
|
|
||||||
Path: {devpath}"""
|
|
||||||
result = template.format(**dinfo)
|
|
||||||
widgets = [
|
widgets = [
|
||||||
Text(result),
|
TablePile(rows, colspecs={1: ColSpec(can_shrink=True)}),
|
||||||
Text(""),
|
Text(""),
|
||||||
button_pile([done_btn(_("Close"), on_press=self.close)]),
|
button_pile([done_btn(_("Close"), on_press=self.close)]),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue