comparison src/tools/xml_tools.py @ 975:b37b1d183ac3

reverted changeset 5c7707c958d8 (revision 969)
author souliane <souliane@mailoo.org>
date Thu, 03 Apr 2014 14:38:48 +0200
parents 5c7707c958d8
children d2e612a45e76
comparison
equal deleted inserted replaced
974:54cd05f68c7c 975:b37b1d183ac3
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
312 class OptionElement(Element): 302 class OptionElement(Element):
313 """" Used by ListWidget to specify options """ 303 """" Used by ListWidget to specify options """
314 type = 'option' 304 type = 'option'
315 305
316 def __init__(self, parent, option, selected=False): 306 def __init__(self, parent, option, selected=False):
629 self.elem.setAttribute('value', value) 619 self.elem.setAttribute('value', value)
630 for field in fields_back: 620 for field in fields_back:
631 FieldBackElement(self, field) 621 FieldBackElement(self, field)
632 622
633 623
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
665 class ListWidget(InputWidget): 624 class ListWidget(InputWidget):
666 type = 'list' 625 type = 'list'
667 626
668 def __init__(self, xmlui, options, selected=None, style=None, name=None, parent=None): 627 def __init__(self, xmlui, options, selected=None, style=None, name=None, parent=None):
669 """ 628 """