[node-patches] Change in ovirt-node[master]: Add ovirt-node.ui.Row element for h. alignment

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


Fabian Deutsch has uploaded a new change for review.

Change subject: Add ovirt-node.ui.Row element for h. alignment
......................................................................

Add ovirt-node.ui.Row element for h. alignment

Change-Id: I3a6b4650fe18ca30c40cbd4539362d588f767577
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
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
3 files changed, 40 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/87/9887/1

diff --git a/scripts/tui/src/ovirt/node/ui/__init__.py b/scripts/tui/src/ovirt/node/ui/__init__.py
index 5141734..08783ce 100644
--- a/scripts/tui/src/ovirt/node/ui/__init__.py
+++ b/scripts/tui/src/ovirt/node/ui/__init__.py
@@ -26,6 +26,11 @@
 LOGGER = logging.getLogger(__name__)
 
 
+def deprecated(func):
+    LOGGER.warning("Deprecated %s" % func)
+    return lambda *args, **kwargs: func(*args, **kwargs)
+
+
 # http://stackoverflow.com/questions/739654/understanding-python-decorators
 class Element(object):
     """An abstract UI Element.
@@ -115,8 +120,19 @@
 class ContainerElement(Element):
     """An abstract container Element containing other Elements
     """
-    widgets = []
-    pass
+    children = []
+
+    def __init__(self, children):
+        self.children = children
+
+    @property
+    @deprecated
+    def widgets(self):
+        return self.children
+
+    @widgets.setter
+    def widgets(self, v):
+        self.children = v
 
 
 class Page(ContainerElement):
@@ -124,16 +140,19 @@
     """
     has_save_button = True
 
-    def __init__(self, widgets):
-        self.widgets = widgets
-
 
 class Dialog(Page):
     """An abstract dialog, similar to a page
     """
-    def __init__(self, title, widgets):
+    def __init__(self, title, children):
         self.title = title
-        super(Dialog, self).__init__(widgets)
+        super(Dialog, self).__init__(children)
+
+
+class Row(ContainerElement):
+    """Align elements horizontally in one row
+    """
+    pass
 
 
 class Label(Element):
@@ -210,7 +229,6 @@
 
 
 class Options(Element):
-
     def __init__(self, label, options):
         self.label = label
         self.options = options
diff --git a/scripts/tui/src/ovirt/node/ui/builder.py b/scripts/tui/src/ovirt/node/ui/builder.py
index 6b35c61..9aa3740 100644
--- a/scripts/tui/src/ovirt/node/ui/builder.py
+++ b/scripts/tui/src/ovirt/node/ui/builder.py
@@ -91,6 +91,7 @@
         ovirt.node.ui.SaveButton: build_button,
         ovirt.node.ui.Divider: build_divider,
         ovirt.node.ui.Options: build_options,
+        ovirt.node.ui.Row: build_row,
     }
 
     # Check if builder is available for UI Element
@@ -217,3 +218,12 @@
     urwid.connect_signal(widget, "change", on_widget_change_cb)
 
     return widget
+
+
+def build_row(path, container_item, tui, plugin):
+    widgets = []
+    for path, element in container_item.children:
+        child = widget_for_item(tui, plugin, path, element)
+        widgets.append(child)
+
+    return urwid.Columns(widgets)
diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index c1e85f9..f001c24 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -361,3 +361,7 @@
 #        self._listbox = urwid.ListBox(self._listwalker)
         self._pile = urwid.Pile(widgets)
         super(PageWidget, self).__init__(self._pile)
+
+
+class RowWidget(urwid.Columns):
+    pass


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

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