diff frontends/src/tools/xmlui.py @ 803:f100fd8d279f

core, frontends: implementation of AdvancedListContainer first draft + misc: /!\ Urwid SàText must be updated as the new TableContainer is used /!\ - fixed button value in paramsXML2XMLUI - new Urwid SàText TabContainer is used in Primitivus for PairsContainer and AdvancedListContainer - fixed in core's XMLUI AdvanceListContainer
author Goffi <goffi@goffi.org>
date Tue, 04 Feb 2014 18:19:29 +0100
parents 9007bb133009
children 5174657b3378
line wrap: on
line diff
--- a/frontends/src/tools/xmlui.py	Tue Feb 04 18:19:00 2014 +0100
+++ b/frontends/src/tools/xmlui.py	Tue Feb 04 18:19:29 2014 +0100
@@ -120,6 +120,10 @@
     pass
 
 
+class AdvancedListContainer(Container):
+    """ Widgets are disposed in rows with advaned features """
+    pass
+
 class XMLUI(object):
     """ Base class to construct SàT XML User Interface
     New frontends can inherite this class to easily implement XMLUI
@@ -178,7 +182,7 @@
         """
         for node in current_node.childNodes:
             if wanted and not node.nodeName in wanted:
-                raise InvalidXMLUI
+                raise InvalidXMLUI('Unexpected node: [%s]' % node.nodeName)
 
             if node.nodeName == "container":
                 type_ = node.getAttribute('type')
@@ -195,6 +199,13 @@
                 elif type_ == "pairs":
                     cont = self.widget_factory.createPairsContainer(parent)
                     self._parseChilds(cont, node, ('widget', 'container'))
+                elif type_ == "advanced_list":
+                    try:
+                        columns = int(node.getAttribute('columns'))
+                    except (TypeError, ValueError):
+                        raise DataError("Invalid columns")
+                    cont = self.widget_factory.createAdvancedListContainer(parent, columns)
+                    self._parseChilds(cont, node, ('row',))
                 else:
                     warning(_("Unknown container [%s], using default one") % type_)
                     cont = self.widget_factory.createVerticalContainer(parent)
@@ -207,7 +218,7 @@
                     else:
                         raise Exception(_("Internal Error, container has not _xmluiAppend method"))
 
-            elif node.nodeName == "tab":
+            elif node.nodeName == 'tab':
                 name = node.getAttribute('name')
                 label = node.getAttribute('label')
                 if not name or not isinstance(data, TabsContainer):
@@ -218,6 +229,10 @@
                 new_tab = tab_cont._xmluiAddTab(label or name)
                 self._parseChilds(new_tab, node, ('widget', 'container'))
 
+            elif node.nodeName == 'row':
+                parent._xmluiAddRow()
+                self._parseChilds(parent, node, ('widget', 'container'))
+
             elif node.nodeName == "widget":
                 id_ = node.getAttribute("id")
                 name = node.getAttribute("name")