Mercurial > libervia-backend
comparison src/tools/xml_tools.py @ 2429:941fdf81958c
core (XMLUI): form's XMLUI is use as first arguments for filters in dataForm2Widgets
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 11 Nov 2017 18:39:26 +0100 |
parents | c2d88fe05303 |
children | bfd1e9d737c4 |
comparison
equal
deleted
inserted
replaced
2428:c2d88fe05303 | 2429:941fdf81958c |
---|---|
111 @param prepend(iterable, None): widgets to prepend to main LabelContainer | 111 @param prepend(iterable, None): widgets to prepend to main LabelContainer |
112 if not None, must be an iterable of *args for addWidget. Those widgets will | 112 if not None, must be an iterable of *args for addWidget. Those widgets will |
113 be added first to the container. | 113 be added first to the container. |
114 @param filters(dict, None): if not None, a dictionary of callable: | 114 @param filters(dict, None): if not None, a dictionary of callable: |
115 key is the name of the widget to filter | 115 key is the name of the widget to filter |
116 the value is a callable, it will get widget's type, args and kwargs | 116 the value is a callable, it will get form's XMLUI, widget's type, args and kwargs |
117 and must return the same variable, which it can modify | 117 and must return widget's type, args and kwargs (which can be modified) |
118 This is especially useful to modify well known fields | 118 This is especially useful to modify well known fields |
119 @return: the completed XMLUI instance | 119 @return: the completed XMLUI instance |
120 """ | 120 """ |
121 if filters is None: | 121 if filters is None: |
122 filters = {} | 122 filters = {} |
134 try: | 134 try: |
135 widget_filter = filters[widget_kwargs['name']] | 135 widget_filter = filters[widget_kwargs['name']] |
136 except KeyError: | 136 except KeyError: |
137 pass | 137 pass |
138 else: | 138 else: |
139 widget_type, widget_args, widget_kwargs = widget_filter(widget_type, widget_args, widget_kwargs) | 139 widget_type, widget_args, widget_kwargs = widget_filter(form_ui, widget_type, widget_args, widget_kwargs) |
140 label = field.label or field.var | 140 label = field.label or field.var |
141 if label: | 141 if label: |
142 form_ui.addLabel(label) | 142 form_ui.addLabel(label) |
143 else: | 143 else: |
144 form_ui.addEmpty() | 144 form_ui.addEmpty() |