Mercurial > libervia-backend
comparison src/tools/xml_tools.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 |
---|---|
297 assert(isinstance(parent, ButtonWidget)) | 297 assert(isinstance(parent, ButtonWidget)) |
298 super(FieldBackElement, self).__init__(parent.xmlui, parent) | 298 super(FieldBackElement, self).__init__(parent.xmlui, parent) |
299 self.elem.setAttribute('name', name) | 299 self.elem.setAttribute('name', name) |
300 | 300 |
301 | 301 |
302 class InternalFieldElement(Element): | |
303 """ Used by InternalButtonWidget to indicate which field are manipulated by internal action """ | |
304 type = 'internal_field' | |
305 | |
306 def __init__(self, parent, name): | |
307 assert(isinstance(parent, InternalButtonWidget)) | |
308 super(InternalFieldElement, self).__init__(parent.xmlui, parent) | |
309 self.elem.setAttribute('name', name) | |
310 | |
311 | |
302 class OptionElement(Element): | 312 class OptionElement(Element): |
303 """" Used by ListWidget to specify options """ | 313 """" Used by ListWidget to specify options """ |
304 type = 'option' | 314 type = 'option' |
305 | 315 |
306 def __init__(self, parent, option, selected=False): | 316 def __init__(self, parent, option, selected=False): |
619 self.elem.setAttribute('value', value) | 629 self.elem.setAttribute('value', value) |
620 for field in fields_back: | 630 for field in fields_back: |
621 FieldBackElement(self, field) | 631 FieldBackElement(self, field) |
622 | 632 |
623 | 633 |
634 class InternalButtonWidget(Widget): | |
635 type = 'internal_button' | |
636 | |
637 def __init__(self, xmlui, action='copy', value=None, fields=None, name=None, parent=None): | |
638 """Add an button to process internal UI operations. | |
639 | |
640 The internal button is not associated to any callback id because it is | |
641 not using the bridge (no communication with the backend). | |
642 | |
643 @param action (string): a value from: | |
644 - 'copy': process the widgets given in 'fields' | |
645 two by two, by copying the values of one widget | |
646 to the other. | |
647 - 'move': same than copy but moves the values | |
648 if the source widget is not a List. | |
649 - more operation to be added when necessary... | |
650 @param value (string): label of the button | |
651 @param fields (list): a list of widget name (string) | |
652 @param name: name | |
653 @param parent: parent container | |
654 """ | |
655 if fields is None: | |
656 fields = [] | |
657 super(InternalButtonWidget, self).__init__(xmlui, name, parent) | |
658 self.elem.setAttribute('action', action) | |
659 if value: | |
660 self.elem.setAttribute('value', value) | |
661 for field in fields: | |
662 InternalFieldElement(self, field) | |
663 | |
664 | |
624 class ListWidget(InputWidget): | 665 class ListWidget(InputWidget): |
625 type = 'list' | 666 type = 'list' |
626 | 667 |
627 def __init__(self, xmlui, options, selected=None, style=None, name=None, parent=None): | 668 def __init__(self, xmlui, options, selected=None, style=None, name=None, parent=None): |
628 """ | 669 """ |