comparison frontends/src/tools/xmlui.py @ 2366:c7a7e650ac2f

frontends (xmlui): a dict of named widgets is kept, so they can be easily be retrieved
author Goffi <goffi@goffi.org>
date Sun, 01 Oct 2017 12:21:23 +0200
parents 5defafc8ede6
children 825608d4eaf8
comparison
equal deleted inserted replaced
2365:318f0434d830 2366:c7a7e650ac2f
322 """ 322 """
323 widget_factory = None 323 widget_factory = None
324 324
325 def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, profile=C.PROF_KEY_NONE): 325 def __init__(self, host, parsed_dom, title=None, flags=None, callback=None, profile=C.PROF_KEY_NONE):
326 super(XMLUIPanel, self).__init__(host, parsed_dom, title=title, flags=flags, callback=callback, profile=profile) 326 super(XMLUIPanel, self).__init__(host, parsed_dom, title=title, flags=flags, callback=callback, profile=profile)
327 self.ctrl_list = {} # usefull to access ctrl 327 self.ctrl_list = {} # input widget, used mainly for forms
328 self.widgets = {} # allow to access any named widgets
328 self._main_cont = None 329 self._main_cont = None
329 self.constructUI(parsed_dom) 330 self.constructUI(parsed_dom)
330 331
331 def escape(self, name): 332 def escape(self, name):
332 """Return escaped name for forms""" 333 """Return escaped name for forms"""
478 ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")]) 479 ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")])
479 else: 480 else:
480 log.error(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_) 481 log.error(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_)
481 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_) 482 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_)
482 483
484 if name:
485 self.widgets[name] = ctrl
486
483 if self.type == 'param' and type_ not in ('text', 'button'): 487 if self.type == 'param' and type_ not in ('text', 'button'):
484 try: 488 try:
485 ctrl._xmluiOnChange(self.onParamChange) 489 ctrl._xmluiOnChange(self.onParamChange)
486 ctrl._param_category = self._current_category 490 ctrl._param_category = self._current_category
487 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError 491 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError