CS: message sending is now working
- xmltools/xmlui: buttons can now send fields of the ui when used - xmltools/xmlui: new textbox element, to write a large text (used for messages in CS plugin) - xmltools/xmlui: list have now an attribute multi for selecting several options - xmltools/xmlui: window title can now be specified in the xml (attribute title) - CS_plugin: message sending interface & management
This commit is contained in:
parent
6eddbcf368
commit
8c1ee1d907
1 changed files with 136 additions and 32 deletions
|
|
@ -103,17 +103,19 @@ def paramsXml2xmlUI(xml):
|
|||
class XMLUI:
|
||||
"""This class is used to create a user interface (form/window/parameters/etc) using SàT XML"""
|
||||
|
||||
def __init__(self, panel_type, layout="vertical"):
|
||||
def __init__(self, panel_type, layout="vertical", title=None):
|
||||
"""Init SàT XML Panel
|
||||
@param panel_type: one of
|
||||
- window (new window)
|
||||
- form (formulaire, depend of the frontend, usually a panel with cancel/submit buttons)
|
||||
- param (parameters, presentatio depend of the frontend)
|
||||
@param layout: disposition of elements, one of:
|
||||
- VERTICAL: elements are disposed up to bottom
|
||||
- HORIZONTAL: elements are disposed left to right
|
||||
- PAIRS: elements come on two aligned columns
|
||||
- vertical: elements are disposed up to bottom
|
||||
- horizontal: elements are disposed left to right
|
||||
- pairs: elements come on two aligned columns
|
||||
(usually one for a label, the next for the element)
|
||||
- tabs: elemens are in categories with tabs (notebook)
|
||||
@param title: title or default if None
|
||||
"""
|
||||
if not panel_type in ['window', 'form', 'param']:
|
||||
error(_("Unknown panel type [%s]") % panel_type)
|
||||
|
|
@ -124,6 +126,8 @@ class XMLUI:
|
|||
self.doc = impl.createDocument(None, "sat_xmlui", None)
|
||||
top_element = self.doc.documentElement
|
||||
top_element.setAttribute("type", panel_type)
|
||||
if title:
|
||||
top_element.setAttribute("title", title)
|
||||
self.parentTabsLayout = None #used only we have 'tabs' layout
|
||||
self.currentCategory = None #used only we have 'tabs' layout
|
||||
self.changeLayout(layout)
|
||||
|
|
@ -195,23 +199,38 @@ class XMLUI:
|
|||
if value:
|
||||
elem.setAttribute('value', value)
|
||||
|
||||
def addList(self, options, name=None, value=None):
|
||||
def addTextBox(self, name=None, value=None):
|
||||
"""Add a string box"""
|
||||
elem = self.__createElem('textbox', name, self.currentLayout)
|
||||
if value:
|
||||
elem.setAttribute('value', value)
|
||||
|
||||
def addList(self, options, name=None, value=None, style=set()):
|
||||
"""Add a list of choices"""
|
||||
styles = set(style)
|
||||
assert (options)
|
||||
assert (styles.issubset(['multi']))
|
||||
elem = self.__createElem('list', name, self.currentLayout)
|
||||
self.addOptions(options, elem)
|
||||
if value:
|
||||
elem.setAttribute('value', value)
|
||||
for style in styles:
|
||||
elem.setAttribute(style, 'yes')
|
||||
|
||||
def addButton(self, callback_id, name, value):
|
||||
def addButton(self, callback_id, name, value, fields_back=[]):
|
||||
"""Add a button
|
||||
@param callback: callback which will be called if button is pressed
|
||||
@param name: name
|
||||
@param value: label of the button"""
|
||||
@param value: label of the button
|
||||
@fields_back: list of names of field to give back when pushing the button"""
|
||||
elem = self.__createElem('button', name, self.currentLayout)
|
||||
elem.setAttribute('callback_id', callback_id)
|
||||
if value:
|
||||
elem.setAttribute('value', value)
|
||||
elem.setAttribute('value', value)
|
||||
for field in fields_back:
|
||||
fback_el = self.doc.createElement('field_back')
|
||||
fback_el.setAttribute('name', field)
|
||||
elem.appendChild(fback_el)
|
||||
|
||||
|
||||
|
||||
def addElement(self, type, name = None, content = None, value = None, options = None, callback_id = None):
|
||||
|
|
@ -227,6 +246,8 @@ class XMLUI:
|
|||
self.addString(name, value)
|
||||
elif type == 'password':
|
||||
self.addPassword(name, value)
|
||||
elif type == 'textbox':
|
||||
self.addTextBox(name, value)
|
||||
elif type == 'list':
|
||||
self.addList(options, name, value)
|
||||
elif type == 'button':
|
||||
|
|
|
|||
Loading…
Reference in a new issue