Mercurial > libervia-backend
diff tools/xml_tools.py @ 104:5458ac1380cc
XMLUI: added tabs layout
xmltools: tabs layout are added, and a new addCategory method is used to add tabs
wix: tabs layout are managed with notebook
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 23 Jun 2010 14:55:04 +0800 |
parents | 6be927a465ed |
children | d2630fba8dfd |
line wrap: on
line diff
--- a/tools/xml_tools.py Wed Jun 23 00:23:26 2010 +0800 +++ b/tools/xml_tools.py Wed Jun 23 14:55:04 2010 +0800 @@ -32,6 +32,7 @@ form_panel = XMLUI("form", "vertical") + if form.instructions: form_panel.addText('\n'.join(form.instructions), 'instructions') @@ -91,7 +92,9 @@ self.doc = impl.createDocument(None, "sat_xmlui", None) top_element = self.doc.documentElement top_element.setAttribute("type", panel_type) - self.currentLayout = self.__createLayout(layout, top_element) + self.parentTabsLayout = None #used only we have 'tabs' layout + self.currentCategory = None #used only we have 'tabs' layout + self.changeLayout(layout) def __del__(self): self.doc.unlink() @@ -101,7 +104,7 @@ @param type: layout type (cf init doc) @parent: parent element or None """ - if not layout in ['vertical', 'horizontal', 'pairs']: + if not layout in ['vertical', 'horizontal', 'pairs', 'tabs']: error (_("Unknown layout type [%s]") % layout) assert (False) layout_elt = self.doc.createElement('layout') @@ -128,7 +131,9 @@ def changeLayout(self, layout): """Change the current layout""" - self.currentLayout = self.__createLayout(layout, self.doc.documentElement) + self.currentLayout = self.__createLayout(layout, self.currentCategory if self.currentCategory else self.doc.documentElement) + if layout == "tabs": + self.parentTabsLayout = self.currentLayout def addEmpty(self, name=None): @@ -190,6 +195,20 @@ opt.setAttribute('value', option) parent.appendChild(opt) + def addCategory(self, name, layout): + """Add a category to current layout (must be a tabs layout)""" + assert(layout != 'tabs') + if not self.parentTabsLayout: + error(_("Trying to add a category without parent tabs layout")) + assert(False) + if self.parentTabsLayout.getAttribute('type') != 'tabs': + error(_("parent layout of a category is not tabs")) + assert(False) + self.currentCategory = cat = self.doc.createElement('category') + cat.setAttribute('name', name) + self.changeLayout(layout) + self.parentTabsLayout.appendChild(cat) + def toXml(self): """return the XML representation of the panel""" return self.doc.toxml()