[node-patches] Change in ovirt-node[master]: ui.widgets: Enhancements

fabiand at fedoraproject.org fabiand at fedoraproject.org
Tue Dec 11 20:09:35 UTC 2012


Fabian Deutsch has uploaded a new change for review.

Change subject: ui.widgets: Enhancements
......................................................................

ui.widgets: Enhancements

Change-Id: I6af4ef9b4dcc72159d3f8d7f1f6ef34efc48d9b6
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/plugins/engine_page.py
M scripts/tui/src/ovirt/node/plugins/example.py
M scripts/tui/src/ovirt/node/plugins/kdump_page.py
M scripts/tui/src/ovirt/node/plugins/keyboard_page.py
M scripts/tui/src/ovirt/node/plugins/logging_page.py
M scripts/tui/src/ovirt/node/plugins/monitoring_page.py
M scripts/tui/src/ovirt/node/plugins/network_page.py
M scripts/tui/src/ovirt/node/plugins/ping.py
M scripts/tui/src/ovirt/node/plugins/remote_storage_page.py
M scripts/tui/src/ovirt/node/plugins/security_page.py
M scripts/tui/src/ovirt/node/plugins/snmp_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
15 files changed, 80 insertions(+), 59 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/00/9900/1

diff --git a/scripts/tui/src/ovirt/node/plugins/engine_page.py b/scripts/tui/src/ovirt/node/plugins/engine_page.py
index 39b1ee9..b019fc3 100644
--- a/scripts/tui/src/ovirt/node/plugins/engine_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/engine_page.py
@@ -64,8 +64,8 @@
         widgets = [
             ("header", ovirt.node.ui.Header("oVirt Engine Configuration")),
 
-            ("vdsm.address", ovirt.node.ui.Entry("Server Address")),
-            ("vdsm.port", ovirt.node.ui.Entry("Server Port")),
+            ("vdsm.address", ovirt.node.ui.Entry("Server Address:")),
+            ("vdsm.port", ovirt.node.ui.Entry("Server Port:")),
             ("vdsm.connect_and_validate", ovirt.node.ui.Options(
                     "Connect to oVirt Engine and Validate Certificate",
                     [("yes", "Yes"), ("no", "No")])),
@@ -74,9 +74,9 @@
                     "Optional password for adding Node through oVirt " +
                     "Engine UI")),
 
-            ("vdsm.password", ovirt.node.ui.PasswordEntry("Password")),
+            ("vdsm.password", ovirt.node.ui.PasswordEntry("Password:")),
             ("vdsm.password_confirmation", ovirt.node.ui.PasswordEntry(
-                    "Confirm Password")),
+                    "Confirm Password:")),
         ]
         # Save it "locally" as a dict, for better accessability
         self._widgets = dict(widgets)
diff --git a/scripts/tui/src/ovirt/node/plugins/example.py b/scripts/tui/src/ovirt/node/plugins/example.py
index ffe6f87..fe2812b 100644
--- a/scripts/tui/src/ovirt/node/plugins/example.py
+++ b/scripts/tui/src/ovirt/node/plugins/example.py
@@ -70,11 +70,11 @@
             ("foo.section",
                 ovirt.node.ui.Header("Subsection")),
             ("foo.hostname",
-                ovirt.node.ui.Entry(label="Hostname")),
+                ovirt.node.ui.Entry("Hostname:")),
             ("foo.port",
-                ovirt.node.ui.Entry(label="Port")),
+                ovirt.node.ui.Entry("Port:")),
             ("foo.password",
-                ovirt.node.ui.PasswordEntry(label="Password")),
+                ovirt.node.ui.PasswordEntry("Password:")),
         ]
         self._widgets = dict(widgets)
         page = ovirt.node.ui.Page(widgets)
diff --git a/scripts/tui/src/ovirt/node/plugins/kdump_page.py b/scripts/tui/src/ovirt/node/plugins/kdump_page.py
index 1cc8771..8d9c205 100644
--- a/scripts/tui/src/ovirt/node/plugins/kdump_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/kdump_page.py
@@ -74,10 +74,12 @@
         This is an ordered list of (path, widget) tuples.
         """
         widgets = [
-            ("kdump.header", ovirt.node.ui.Header("Configure Kdump")),
+            ("kdump._header", ovirt.node.ui.Header("Configure Kdump")),
             ("kdump.type", ovirt.node.ui.Options("Type", self._types)),
-            ("kdump.ssh_location", ovirt.node.ui.Entry("SSH Location")),
-            ("kdump.nfs_location", ovirt.node.ui.Entry("NFS Location")),
+            ("kdump.ssh_location", ovirt.node.ui.Entry("SSH Location:",
+                                                       align_vertical=True)),
+            ("kdump.nfs_location", ovirt.node.ui.Entry("NFS Location:",
+                                                       align_vertical=True)),
         ]
         # Save it "locally" as a dict, for better accessability
         self._widgets = dict(widgets)
diff --git a/scripts/tui/src/ovirt/node/plugins/keyboard_page.py b/scripts/tui/src/ovirt/node/plugins/keyboard_page.py
index 20cfc0a..643ed90 100644
--- a/scripts/tui/src/ovirt/node/plugins/keyboard_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/keyboard_page.py
@@ -58,8 +58,8 @@
         This is an ordered list of (path, widget) tuples.
         """
         widgets = [
-            ("layout.label",
-                ovirt.node.ui.Label("Keyboard Layout Selection")),
+            ("layout._header",
+                ovirt.node.ui.Header("Keyboard Layout Selection")),
             ("layout", ovirt.node.ui.Table("", self._get_layouts())),
 
         ]
diff --git a/scripts/tui/src/ovirt/node/plugins/logging_page.py b/scripts/tui/src/ovirt/node/plugins/logging_page.py
index 71e6b22..baa7407 100644
--- a/scripts/tui/src/ovirt/node/plugins/logging_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/logging_page.py
@@ -69,19 +69,19 @@
             ("header", ovirt.node.ui.Header("Logging")),
 
             ("max_log_size", ovirt.node.ui.Entry("Logrotate Max Log " +
-                                                 "Size (KB)")),
+                                                 "Size (KB):")),
 
             ("rsyslog.header", ovirt.node.ui.Label(
                                     "RSyslog is an enhanced multi-threaded " +
                                     "syslogd")),
-            ("rsyslog.address", ovirt.node.ui.Entry("Server Address")),
-            ("rsyslog.port", ovirt.node.ui.Entry("Server Port")),
+            ("rsyslog.address", ovirt.node.ui.Entry("Server Address:")),
+            ("rsyslog.port", ovirt.node.ui.Entry("Server Port:")),
 
             ("netconsole.header", ovirt.node.ui.Label(
                                     "Netconsole service allows a remote sys" +
                                     "log daemon to record printk() messages")),
-            ("netconsole.address", ovirt.node.ui.Entry("Server Address")),
-            ("netconsole.port", ovirt.node.ui.Entry("Server Port")),
+            ("netconsole.address", ovirt.node.ui.Entry("Server Address:")),
+            ("netconsole.port", ovirt.node.ui.Entry("Server Port:")),
         ]
         # Save it "locally" as a dict, for better accessability
         self._widgets = dict(widgets)
diff --git a/scripts/tui/src/ovirt/node/plugins/monitoring_page.py b/scripts/tui/src/ovirt/node/plugins/monitoring_page.py
index 00f427c..97b7dcf 100644
--- a/scripts/tui/src/ovirt/node/plugins/monitoring_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/monitoring_page.py
@@ -64,8 +64,8 @@
                             "performance bottlenecks and predict future " +
                             "system load.")),
 
-            ("collectd.address", ovirt.node.ui.Entry("Server Address")),
-            ("collectd.port", ovirt.node.ui.Entry("Server Port")),
+            ("collectd.address", ovirt.node.ui.Entry("Server Address:")),
+            ("collectd.port", ovirt.node.ui.Entry("Server Port:")),
         ]
         # Save it "locally" as a dict, for better accessability
         self._widgets = dict(widgets)
diff --git a/scripts/tui/src/ovirt/node/plugins/network_page.py b/scripts/tui/src/ovirt/node/plugins/network_page.py
index 8bdf852..1fe4321 100644
--- a/scripts/tui/src/ovirt/node/plugins/network_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/network_page.py
@@ -83,7 +83,7 @@
         """
         widgets = [
             ("hostname",
-                ovirt.node.ui.Entry("Hostname")),
+                ovirt.node.ui.Entry("Hostname:")),
             ("hostname._space", ovirt.node.ui.Divider()),
 
             ("nics", ovirt.node.ui.Table(
@@ -91,12 +91,12 @@
                         self._get_nics())),
             ("nics._space", ovirt.node.ui.Divider()),
 
-            ("dns[0]", ovirt.node.ui.Entry("DNS Server 1")),
-            ("dns[1]", ovirt.node.ui.Entry("DNS Server 2")),
+            ("dns[0]", ovirt.node.ui.Entry("DNS Server 1:")),
+            ("dns[1]", ovirt.node.ui.Entry("DNS Server 2:")),
             ("dns._space", ovirt.node.ui.Divider()),
 
-            ("ntp[0]", ovirt.node.ui.Entry("NTP Server 1")),
-            ("ntp[1]", ovirt.node.ui.Entry("NTP Server 2")),
+            ("ntp[0]", ovirt.node.ui.Entry("NTP Server 1:")),
+            ("ntp[1]", ovirt.node.ui.Entry("NTP Server 2:")),
             ("ntp._space", ovirt.node.ui.Divider()),
 
 #            ("action", ovirt.node.ui.Buttons(["Lock", "Log Off", "Restart",
diff --git a/scripts/tui/src/ovirt/node/plugins/ping.py b/scripts/tui/src/ovirt/node/plugins/ping.py
index f40e7eb..3d01cf6 100644
--- a/scripts/tui/src/ovirt/node/plugins/ping.py
+++ b/scripts/tui/src/ovirt/node/plugins/ping.py
@@ -71,8 +71,8 @@
         """
         widgets = [
             ("ping.header", ovirt.node.ui.Header("Ping a remote host")),
-            ("ping.address", ovirt.node.ui.Entry("Address")),
-            ("ping.count", ovirt.node.ui.Entry("Count")),
+            ("ping.address", ovirt.node.ui.Entry("Address:")),
+            ("ping.count", ovirt.node.ui.Entry("Count:")),
             ("ping.do_ping", ovirt.node.ui.Button("Ping")),
             ("ping.progress._space", ovirt.node.ui.Divider()),
             ("ping.progress", ovirt.node.ui.ProgressBar()),
diff --git a/scripts/tui/src/ovirt/node/plugins/remote_storage_page.py b/scripts/tui/src/ovirt/node/plugins/remote_storage_page.py
index 87fe0ef..9c23bcd 100644
--- a/scripts/tui/src/ovirt/node/plugins/remote_storage_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/remote_storage_page.py
@@ -60,7 +60,8 @@
             ("header", ovirt.node.ui.Header("Remote Storage")),
 
             ("iscsi.initiator_name", ovirt.node.ui.Entry("iSCSI Initiator " +
-                                                         "Name")),
+                                                         "Name:",
+                                                         align_vertical=True)),
         ]
         # Save it "locally" as a dict, for better accessability
         self._widgets = dict(widgets)
diff --git a/scripts/tui/src/ovirt/node/plugins/security_page.py b/scripts/tui/src/ovirt/node/plugins/security_page.py
index 7e7ba7e..6320048 100644
--- a/scripts/tui/src/ovirt/node/plugins/security_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/security_page.py
@@ -66,9 +66,9 @@
 
 
             ("passwd._label", ovirt.node.ui.Label("Local Access")),
-            ("passwd.admin.password", ovirt.node.ui.PasswordEntry("Password")),
+            ("passwd.admin.password", ovirt.node.ui.PasswordEntry("Password:")),
             ("passwd.admin.password_confirmation", ovirt.node.ui.PasswordEntry(
-                "Confirm Password")),
+                "Confirm Password:")),
         ]
         # Save it "locally" as a dict, for better accessability
         self._widgets = dict(widgets)
diff --git a/scripts/tui/src/ovirt/node/plugins/snmp_page.py b/scripts/tui/src/ovirt/node/plugins/snmp_page.py
index 29d15d4..421fa5f 100644
--- a/scripts/tui/src/ovirt/node/plugins/snmp_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/snmp_page.py
@@ -64,10 +64,10 @@
             ("ssh._divider", ovirt.node.ui.Divider()),
 
 
-            ("snmp.password._label", ovirt.node.ui.Label("SNMP Password")),
-            ("snmp.password", ovirt.node.ui.PasswordEntry("Password")),
+            ("snmp.password._header", ovirt.node.ui.Header("SNMP Password")),
+            ("snmp.password", ovirt.node.ui.PasswordEntry("Password:")),
             ("snmp.password_confirmation", ovirt.node.ui.PasswordEntry(
-                "Confirm Password")),
+                "Confirm Password:")),
         ]
         # Save it "locally" as a dict, for better accessability
         self._widgets = dict(widgets)
diff --git a/scripts/tui/src/ovirt/node/tui.py b/scripts/tui/src/ovirt/node/tui.py
index 8198b7b..51f6793 100644
--- a/scripts/tui/src/ovirt/node/tui.py
+++ b/scripts/tui/src/ovirt/node/tui.py
@@ -55,23 +55,23 @@
 
     palette = [('header', 'white', 'dark blue'),
                ('table', 'dark gray', ''),
-               ('table.header', 'bold', ''),
+               ('table.header', 'dark gray, bold', ''),
                ('table.entry', 'dark gray', ''),
                ('table.entry:focus', 'white', 'light blue', 'standout'),
                ('main.menu', 'black', ''),
                ('main.menu.frame', 'light gray', ''),
                ('plugin.widget.entry', 'dark gray', ''),
                ('plugin.widget.entry.disabled', 'dark gray', 'light gray'),
-               ('plugin.widget.entry.label', 'bold', ''),
+               ('plugin.widget.entry.label', 'dark gray, bold', ''),
                ('plugin.widget.entry.frame', 'light gray', ''),
                ('plugin.widget.entry.frame.invalid', 'dark red', ''),
                ('plugin.widget.notice', 'light red', ''),
-               ('plugin.widget.header', 'light blue', 'light gray'),
+               ('plugin.widget.header', 'black, bold', ''),
                ('plugin.widget.divider', 'dark gray', ''),
                ('plugin.widget.button', 'dark blue', ''),
                ('plugin.widget.button.disabled', 'light gray', ''),
-               ('plugin.widget.label', '', ''),
-               ('plugin.widget.label.keyword', 'bold', ''),
+               ('plugin.widget.label', 'dark gray', ''),
+               ('plugin.widget.label.keyword', 'dark gray, bold', ''),
                ('plugin.widget.progressbar.box', 'light gray', ''),
                ('plugin.widget.progressbar.uncomplete', '', ''),
                ('plugin.widget.progressbar.complete', '', 'light gray'),
diff --git a/scripts/tui/src/ovirt/node/ui/__init__.py b/scripts/tui/src/ovirt/node/ui/__init__.py
index 903af12..20c650c 100644
--- a/scripts/tui/src/ovirt/node/ui/__init__.py
+++ b/scripts/tui/src/ovirt/node/ui/__init__.py
@@ -196,9 +196,9 @@
     TODO multiline
     """
 
-    def __init__(self, label, value=None, enabled=True):
+    def __init__(self, label, enabled=True, align_vertical=False):
         self.label = label
-        self._text = value
+        self.align_vertical = align_vertical
         super(Entry, self).__init__(enabled)
 
 
diff --git a/scripts/tui/src/ovirt/node/ui/builder.py b/scripts/tui/src/ovirt/node/ui/builder.py
index 971ce0c..a2948d5 100644
--- a/scripts/tui/src/ovirt/node/ui/builder.py
+++ b/scripts/tui/src/ovirt/node/ui/builder.py
@@ -119,12 +119,13 @@
 
 
 def build_entry(path, item, tui, plugin):
-    widget = None
+    widget_class = None
     if type(item) is ovirt.node.ui.Entry:
-        widget = ovirt.node.ui.widgets.Entry(item.label)
+        widget_class = ovirt.node.ui.widgets.Entry
     else:
-        widget = ovirt.node.ui.widgets.PasswordEntry(item.label)
+        widget_class = ovirt.node.ui.widgets.PasswordEntry
 
+    widget = widget_class(item.label, align_vertical=item.align_vertical)
     widget.enable(item.enabled)
 
     def on_item_enabled_change_cb(w, v):
diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index bb6d4fa..979b7fc 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -246,21 +246,14 @@
 
     selectable = lambda self: True
 
-    def enable(self, is_enabled):
-        self.selectable = lambda: is_enabled
-        attr_map = {None: "plugin.widget.entry"}
-        if not is_enabled:
-            attr_map = {None: "plugin.widget.entry.disabled"}
-        self._edit_attrmap.set_attr_map(attr_map)
+    def __init__(self, label, mask=None, align_vertical=False):
+        with_linebox = True
+        self._align_vertical = align_vertical
 
-    def valid(self, is_valid):
-        attr_map = {None: "plugin.widget.entry.frame"}
-        if not is_valid:
-            attr_map = {None: "plugin.widget.entry.frame.invalid"}
-        self._linebox_attrmap.set_attr_map(attr_map)
+        if with_linebox:
+            label = "\n" + label
 
-    def __init__(self, label, mask=None):
-        self._label = urwid.Text("\n" + label + ":")
+        self._label = urwid.Text(label)
         self._label_attrmap = urwid.AttrMap(self._label,
                                             "plugin.widget.entry.label")
         self._edit = urwid.Edit(mask=mask)
@@ -268,8 +261,18 @@
         self._linebox = urwid.LineBox(self._edit_attrmap)
         self._linebox_attrmap = urwid.AttrMap(self._linebox,
                                               "plugin.widget.entry.frame")
-        self._columns = urwid.Columns([self._label_attrmap,
-                                       self._linebox_attrmap])
+
+        input_widget = self._edit_attrmap
+        if with_linebox:
+            input_widget = self._linebox_attrmap
+
+        alignment_widget = urwid.Columns
+        if self._align_vertical:
+            alignment_widget = urwid.Pile
+        self._columns = alignment_widget([
+                                            self._label_attrmap,
+                                            input_widget
+                                        ])
 
         self._notice = urwid.Text("")
         self._notice_attrmap = urwid.AttrMap(self._notice,
@@ -283,13 +286,27 @@
 
         super(Entry, self).__init__(self._pile)
 
+    def enable(self, is_enabled):
+        self.selectable = lambda: is_enabled
+        attr_map = {None: "plugin.widget.entry"}
+        if not is_enabled:
+            attr_map = {None: "plugin.widget.entry.disabled"}
+        self._edit_attrmap.set_attr_map(attr_map)
+
+    def valid(self, is_valid):
+        attr_map = {None: "plugin.widget.entry.frame"}
+        if not is_valid:
+            attr_map = {None: "plugin.widget.entry.frame.invalid"}
+        self._linebox_attrmap.set_attr_map(attr_map)
+
     def set_text(self, txt):
         self._edit.set_edit_text(txt)
 
 
 class PasswordEntry(Entry):
-    def __init__(self, label):
-        super(PasswordEntry, self).__init__(label, mask="*")
+    def __init__(self, label, align_vertical=False):
+        super(PasswordEntry, self).__init__(label, mask="*",
+                                            align_vertical=align_vertical)
 
 
 class Button(urwid.WidgetWrap):


--
To view, visit http://gerrit.ovirt.org/9900
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6af4ef9b4dcc72159d3f8d7f1f6ef34efc48d9b6
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