[node-patches] Change in ovirt-node[master]: widgets: Add label to Table
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Tue Dec 11 20:09:37 UTC 2012
Fabian Deutsch has uploaded a new change for review.
Change subject: widgets: Add label to Table
......................................................................
widgets: Add label to Table
Change-Id: Iae89346a58495c1b20daca3f340d7ef0358771f6
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/plugins/__init__.py
M scripts/tui/src/ovirt/node/plugins/keyboard_page.py
M scripts/tui/src/ovirt/node/plugins/network_page.py
M scripts/tui/src/ovirt/node/tui.py
M scripts/tui/src/ovirt/node/ui/__init__.py
M scripts/tui/src/ovirt/node/ui/builder.py
M scripts/tui/src/ovirt/node/ui/widgets.py
7 files changed, 27 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/19/9919/1
diff --git a/scripts/tui/src/ovirt/node/plugins/__init__.py b/scripts/tui/src/ovirt/node/plugins/__init__.py
index 2db455c..271f752 100644
--- a/scripts/tui/src/ovirt/node/plugins/__init__.py
+++ b/scripts/tui/src/ovirt/node/plugins/__init__.py
@@ -129,7 +129,6 @@
msg = e.message
# True and None are allowed values
if msg not in [True, None]:
-# field = dict(self.ui_content().children)[path].name
raise ovirt.node.exceptions.InvalidData(msg)
return True
diff --git a/scripts/tui/src/ovirt/node/plugins/keyboard_page.py b/scripts/tui/src/ovirt/node/plugins/keyboard_page.py
index 643ed90..85b3008 100644
--- a/scripts/tui/src/ovirt/node/plugins/keyboard_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/keyboard_page.py
@@ -60,7 +60,8 @@
widgets = [
("layout._header",
ovirt.node.ui.Header("Keyboard Layout Selection")),
- ("layout", ovirt.node.ui.Table("", self._get_layouts())),
+ ("layout", ovirt.node.ui.Table("Available Keyboard Layouts",
+ "", self._get_layouts())),
]
# Save it "locally" as a dict, for better accessability
diff --git a/scripts/tui/src/ovirt/node/plugins/network_page.py b/scripts/tui/src/ovirt/node/plugins/network_page.py
index 214faf7..df1dbf2 100644
--- a/scripts/tui/src/ovirt/node/plugins/network_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/network_page.py
@@ -84,7 +84,7 @@
ovirt.node.ui.Entry("Hostname:")),
("hostname._space", ovirt.node.ui.Divider()),
- ("nics", ovirt.node.ui.Table(
+ ("nics", ovirt.node.ui.Table("Available System NICs",
"Device Status Model MAC Address",
self._get_nics())),
("nics._space", ovirt.node.ui.Divider()),
diff --git a/scripts/tui/src/ovirt/node/tui.py b/scripts/tui/src/ovirt/node/tui.py
index 2d99818..e695376 100644
--- a/scripts/tui/src/ovirt/node/tui.py
+++ b/scripts/tui/src/ovirt/node/tui.py
@@ -60,6 +60,7 @@
('screen', None),
('header', 'white', 'dark blue'),
('table', 'dark gray'),
+ ('table.label', 'dark gray, bold'),
('table.header', 'dark gray, bold'),
('table.entry', 'dark gray'),
('table.entry:focus', 'white', 'light blue'),
@@ -125,9 +126,15 @@
pending_changes = self._current_plugin.pending_changes()
if pending_changes:
LOGGER.warning("Pending changes: %s" % pending_changes)
+ msg = ""
+ widgets = dict(self._current_plugin.ui_content().children)
+ LOGGER.debug("Available widgets: %s" % widgets)
+ for path, value in pending_changes.items():
+ field = widgets[path].name
+ msg += "- %s\n" % (field.strip(":"))
self.display_dialog(urwid.Filler(urwid.Text(
- "Pending changes:\n%s" % pending_changes)),
- "There are pending changes")
+ "The following fields were changed:\n%s" % msg)),
+ "Pending changes")
return
timer = timeit.Timer()
diff --git a/scripts/tui/src/ovirt/node/ui/__init__.py b/scripts/tui/src/ovirt/node/ui/__init__.py
index ac61af3..e0441ee 100644
--- a/scripts/tui/src/ovirt/node/ui/__init__.py
+++ b/scripts/tui/src/ovirt/node/ui/__init__.py
@@ -282,7 +282,7 @@
return self._current
-class Table(Element):
+class Table(InputElement):
"""Represents a simple Table with one column
Args:
@@ -291,10 +291,12 @@
height: The height of the Table
"""
- def __init__(self, header, items, height=5):
+ def __init__(self, label, header, items, height=5, enabled=True):
+ self.label = label
self.header = header
self.items = items
self.height = height
+ super(Table, self).__init__(label, enabled)
@Element.signal_change
def select(self, selected=None):
diff --git a/scripts/tui/src/ovirt/node/ui/builder.py b/scripts/tui/src/ovirt/node/ui/builder.py
index 9519972..8758c91 100644
--- a/scripts/tui/src/ovirt/node/ui/builder.py
+++ b/scripts/tui/src/ovirt/node/ui/builder.py
@@ -245,8 +245,9 @@
for key, label in item.items:
c = _build_tableitem(tui, path, plugin, key, label)
children.append(c)
- widget = ovirt.node.ui.widgets.TableWidget(item.header, children,
- item.height)
+ widget = ovirt.node.ui.widgets.TableWidget(item.label, item.header,
+ children,
+ item.height, item.enabled())
def on_change_cb(w, d=None):
plugin._on_ui_change({path: w._key})
item.select(w._key)
diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index fb57a05..991e1f3 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -77,11 +77,14 @@
signals = ['changed']
_table_attr = "table"
+ _label_attr = "table.label"
_header_attr = "table.header"
- def __init__(self, header, items, height):
- self.__label = urwid.Text(header)
- self.__label_attrmap = urwid.AttrMap(self.__label, self._header_attr)
+ def __init__(self, label, header, items, height, enabled):
+ self.__label = urwid.Text(label)
+ self.__label_attrmap = urwid.AttrMap(self.__label, self._label_attr)
+ self.__header = urwid.Text(header)
+ self.__header_attrmap = urwid.AttrMap(self.__header, self._header_attr)
self.__items = items
self.__walker = urwid.SimpleListWalker(self.__items)
self.__list = urwid.ListBox(self.__walker)
@@ -95,7 +98,8 @@
self.__box = urwid.BoxAdapter(self.__list, height)
self.__box_attrmap = urwid.AttrMap(self.__box, self._table_attr)
- self.__pile = urwid.Pile([self.__label_attrmap, self.__box])
+ self.__pile = urwid.Pile([self.__label_attrmap,
+ self.__header_attrmap, self.__box])
super(TableWidget, self).__init__(self.__pile)
--
To view, visit http://gerrit.ovirt.org/9919
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iae89346a58495c1b20daca3f340d7ef0358771f6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>
More information about the node-patches
mailing list