tools, frontends (xmlui): add setter methods for widgets + new widget InternalButton to process UI operations
This commit is contained in:
parent
608e2ba9fa
commit
6608eafb9f
4 changed files with 119 additions and 0 deletions
|
|
@ -299,6 +299,16 @@ class FieldBackElement(Element):
|
|||
self.elem.setAttribute('name', name)
|
||||
|
||||
|
||||
class InternalFieldElement(Element):
|
||||
""" Used by InternalButtonWidget to indicate which field are manipulated by internal action """
|
||||
type = 'internal_field'
|
||||
|
||||
def __init__(self, parent, name):
|
||||
assert(isinstance(parent, InternalButtonWidget))
|
||||
super(InternalFieldElement, self).__init__(parent.xmlui, parent)
|
||||
self.elem.setAttribute('name', name)
|
||||
|
||||
|
||||
class OptionElement(Element):
|
||||
"""" Used by ListWidget to specify options """
|
||||
type = 'option'
|
||||
|
|
@ -621,6 +631,37 @@ class ButtonWidget(Widget):
|
|||
FieldBackElement(self, field)
|
||||
|
||||
|
||||
class InternalButtonWidget(Widget):
|
||||
type = 'internal_button'
|
||||
|
||||
def __init__(self, xmlui, action='copy', value=None, fields=None, name=None, parent=None):
|
||||
"""Add an button to process internal UI operations.
|
||||
|
||||
The internal button is not associated to any callback id because it is
|
||||
not using the bridge (no communication with the backend).
|
||||
|
||||
@param action (string): a value from:
|
||||
- 'copy': process the widgets given in 'fields'
|
||||
two by two, by copying the values of one widget
|
||||
to the other.
|
||||
- 'move': same than copy but moves the values
|
||||
if the source widget is not a List.
|
||||
- more operation to be added when necessary...
|
||||
@param value (string): label of the button
|
||||
@param fields (list): a list of widget name (string)
|
||||
@param name: name
|
||||
@param parent: parent container
|
||||
"""
|
||||
if fields is None:
|
||||
fields = []
|
||||
super(InternalButtonWidget, self).__init__(xmlui, name, parent)
|
||||
self.elem.setAttribute('action', action)
|
||||
if value:
|
||||
self.elem.setAttribute('value', value)
|
||||
for field in fields:
|
||||
InternalFieldElement(self, field)
|
||||
|
||||
|
||||
class ListWidget(InputWidget):
|
||||
type = 'list'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue