Mercurial > libervia-backend
comparison frontends/src/tools/xmlui.py @ 969:5c7707c958d8
tools, frontends (xmlui): add setter methods for widgets + new widget InternalButton to process UI operations
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 01 Apr 2014 21:30:21 +0200 |
parents | 75f3b3b430ff |
children | b37b1d183ac3 |
comparison
equal
deleted
inserted
replaced
968:75f3b3b430ff | 969:5c7707c958d8 |
---|---|
309 self.ctrl_list[name] = ({'type': type_, 'control': ctrl}) | 309 self.ctrl_list[name] = ({'type': type_, 'control': ctrl}) |
310 elif type_=="button": | 310 elif type_=="button": |
311 callback_id = node.getAttribute("callback") | 311 callback_id = node.getAttribute("callback") |
312 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress) | 312 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress) |
313 ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")]) | 313 ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")]) |
314 elif type_ == "internal_button": | |
315 action = node.getAttribute("action") | |
316 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onInternalButtonPress) | |
317 ctrl._xmlui_param_id = (action, [field.getAttribute('name') for field in node.getElementsByTagName("internal_field")]) | |
314 else: | 318 else: |
315 print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_) | 319 print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_) |
316 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_) | 320 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_) |
317 | 321 |
318 if self.type == 'param' and type_ != 'text': | 322 if self.type == 'param' and type_ != 'text': |
411 data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelectedValues()) | 415 data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelectedValues()) |
412 else: | 416 else: |
413 data[escaped] = ctrl['control']._xmluiGetValue() | 417 data[escaped] = ctrl['control']._xmluiGetValue() |
414 self._xmluiLaunchAction(callback_id, data) | 418 self._xmluiLaunchAction(callback_id, data) |
415 | 419 |
420 def onInternalButtonPress(self, button): | |
421 """ Called when an internal XMLUI button is clicked | |
422 Do the processing associated to the button | |
423 @param button: the button clicked | |
424 | |
425 """ | |
426 action, fields = button._xmlui_param_id | |
427 if action not in ('copy', 'move'): | |
428 raise NotImplementedError(_("FIXME: XMLUI internal action [%s] is not implemented") % action) | |
429 source = None | |
430 for field in fields: | |
431 widget = self.ctrl_list[field]['control'] | |
432 if not source: | |
433 source = widget | |
434 continue | |
435 if isinstance(widget, ListWidget): | |
436 if isinstance(source, ListWidget): | |
437 values = source._xmluiGetSelectedValues() | |
438 else: | |
439 values = [source._xmluiGetValue()] | |
440 if action == 'move': | |
441 source._xmluiSetValue('') | |
442 widget._xmluiAddValues(values, select=True) | |
443 else: | |
444 if isinstance(source, ListWidget): | |
445 value = u', '.join(source._xmluiGetSelectedValues()) | |
446 else: | |
447 value = source._xmluiGetValue() | |
448 if action == 'move': | |
449 source._xmluiSetValue('') | |
450 widget._xmluiSetValue(value) | |
451 source = None | |
452 | |
416 def onFormSubmitted(self, ignore=None): | 453 def onFormSubmitted(self, ignore=None): |
417 """ An XMLUI form has been submited | 454 """ An XMLUI form has been submited |
418 call the submit action associated with this form | 455 call the submit action associated with this form |
419 | 456 |
420 """ | 457 """ |