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
This commit is contained in:
parent
eaeb313e54
commit
a443a156f3
1 changed files with 75 additions and 29 deletions
|
|
@ -32,6 +32,7 @@ def dataForm2xml(form):
|
|||
|
||||
form_panel = XMLUI("form", "vertical")
|
||||
|
||||
|
||||
if form.instructions:
|
||||
form_panel.addText('\n'.join(form.instructions), 'instructions')
|
||||
|
||||
|
|
@ -91,7 +92,9 @@ class XMLUI:
|
|||
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 @@ class XMLUI:
|
|||
@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 @@ class XMLUI:
|
|||
|
||||
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 @@ class XMLUI:
|
|||
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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue