comparison src/tools/xml_tools.py @ 865:3ee2ec7ec010

core (xmlui), frontends: handling of "text" type in params xml + bug fixes
author Goffi <goffi@goffi.org>
date Tue, 25 Feb 2014 23:01:26 +0100
parents 97ee7594c788
children 65bf1bc70f6b
comparison
equal deleted inserted replaced
864:241f6baa6687 865:3ee2ec7ec010
197 for param in category.getElementsByTagName("param"): 197 for param in category.getElementsByTagName("param"):
198 widget_kwargs = {} 198 widget_kwargs = {}
199 199
200 param_name = param.getAttribute('name') 200 param_name = param.getAttribute('name')
201 param_label = param.getAttribute('label') 201 param_label = param.getAttribute('label')
202 if not param_name: 202 type_ = param.getAttribute('type')
203 if not param_name and type_ != 'text':
203 raise exceptions.DataError(_('INTERNAL ERROR: params must have a name')) 204 raise exceptions.DataError(_('INTERNAL ERROR: params must have a name'))
204 205
205 type_ = param.getAttribute('type')
206 value = param.getAttribute('value') or None 206 value = param.getAttribute('value') or None
207 callback_id = param.getAttribute('callback_id') or None 207 callback_id = param.getAttribute('callback_id') or None
208 208
209 if type_ == 'list': 209 if type_ == 'list':
210 options = _getParamListOptions(param) 210 options = _getParamListOptions(param)
211 widget_kwargs['options'] = options 211 widget_kwargs['options'] = options
212 212
213 if type_ == "button": 213 if type_ in ("button", "text"):
214 param_ui.addEmpty() 214 param_ui.addEmpty()
215 value = param_label 215 value = param_label
216 else: 216 else:
217 param_ui.addLabel(param_label or param_name) 217 param_ui.addLabel(param_label or param_name)
218 218
511 511
512 512
513 class TextWidget(Widget): 513 class TextWidget(Widget):
514 type = 'text' 514 type = 'text'
515 515
516 def __init__(self, xmlui, text, name=None, parent=None): 516 def __init__(self, xmlui, value, name=None, parent=None):
517 super(TextWidget, self).__init__(xmlui, name, parent) 517 super(TextWidget, self).__init__(xmlui, name, parent)
518 text = self.xmlui.doc.createTextNode(text) 518 text = self.xmlui.doc.createTextNode(value)
519 self.elem.appendChild(text) 519 self.elem.appendChild(text)
520 520
521 521
522 class LabelWidget(Widget): 522 class LabelWidget(Widget):
523 type='label' 523 type='label'