comparison src/tools/xml_tools.py @ 2361:5defafc8ede6

core, frontends (xmlui): new LabelContainer: LabelContainer is like a PairContainer where first widget can only be LabelWidget or EmptyWidget. This case is the most common, and allow to generate better code when label can be associated to widget (e.g. in HTML).
author Goffi <goffi@goffi.org>
date Sun, 24 Sep 2017 16:36:11 +0200
parents 70f23bc7859b
children 918e38622a48
comparison
equal deleted inserted replaced
2360:72cbb6478f97 2361:5defafc8ede6
109 @return: the completed XMLUI instance 109 @return: the completed XMLUI instance
110 """ 110 """
111 if form.instructions: 111 if form.instructions:
112 form_ui.addText('\n'.join(form.instructions), 'instructions') 112 form_ui.addText('\n'.join(form.instructions), 'instructions')
113 113
114 form_ui.changeContainer("pairs") 114 form_ui.changeContainer("label")
115 115
116 for field in form.fieldList: 116 for field in form.fieldList:
117 widget_type, widget_args, widget_kwargs = _dataFormField2XMLUIData(field, read_only) 117 widget_type, widget_args, widget_kwargs = _dataFormField2XMLUIData(field, read_only)
118 label = field.label or field.var 118 label = field.label or field.var
119 if label: 119 if label:
301 for category in top.getElementsByTagName("category"): 301 for category in top.getElementsByTagName("category"):
302 category_name = category.getAttribute('name') 302 category_name = category.getAttribute('name')
303 label = category.getAttribute('label') 303 label = category.getAttribute('label')
304 if not category_name: 304 if not category_name:
305 raise exceptions.DataError(_('INTERNAL ERROR: params categories must have a name')) 305 raise exceptions.DataError(_('INTERNAL ERROR: params categories must have a name'))
306 tabs_cont.addTab(category_name, label=label, container=PairsContainer) 306 tabs_cont.addTab(category_name, label=label, container=LabelContainer)
307 for param in category.getElementsByTagName("param"): 307 for param in category.getElementsByTagName("param"):
308 widget_kwargs = {} 308 widget_kwargs = {}
309 309
310 param_name = param.getAttribute('name') 310 param_name = param.getAttribute('name')
311 param_label = param.getAttribute('label') 311 param_label = param.getAttribute('label')
592 type = "horizontal" 592 type = "horizontal"
593 593
594 594
595 class PairsContainer(Container): 595 class PairsContainer(Container):
596 type = "pairs" 596 type = "pairs"
597
598
599 class LabelContainer(Container):
600 type = "label"
597 601
598 602
599 class TabsContainer(Container): 603 class TabsContainer(Container):
600 type = "tabs" 604 type = "tabs"
601 605
1040 @param container: disposition of elements, one of: 1044 @param container: disposition of elements, one of:
1041 - vertical: elements are disposed up to bottom 1045 - vertical: elements are disposed up to bottom
1042 - horizontal: elements are disposed left to right 1046 - horizontal: elements are disposed left to right
1043 - pairs: elements come on two aligned columns 1047 - pairs: elements come on two aligned columns
1044 (usually one for a label, the next for the element) 1048 (usually one for a label, the next for the element)
1049 - label: associations of one LabelWidget or EmptyWidget with an other widget
1050 similar to pairs but specialized in LabelWidget, and not necessarily arranged in 2 columns
1045 - tabs: elemens are in categories with tabs (notebook) 1051 - tabs: elemens are in categories with tabs (notebook)
1046 @param dialog_opt: only used if panel_type == C.XMLUI_DIALOG. Dictionnary (string/string) where key can be: 1052 @param dialog_opt: only used if panel_type == C.XMLUI_DIALOG. Dictionnary (string/string) where key can be:
1047 - C.XMLUI_DATA_TYPE: type of dialog, value can be: 1053 - C.XMLUI_DATA_TYPE: type of dialog, value can be:
1048 - C.XMLUI_DIALOG_MESSAGE (default): an information/error message. Action of user is necessary to close the dialog. Usually the frontend display a classic popup 1054 - C.XMLUI_DIALOG_MESSAGE (default): an information/error message. Action of user is necessary to close the dialog. Usually the frontend display a classic popup
1049 - C.XMLUI_DIALOG_NOTE: like a C.XMLUI_DIALOG_MESSAGE, but action of user is not necessary to close, at frontend choice (it can be closed after a timeout). Usually the frontend display as a timed out notification 1055 - C.XMLUI_DIALOG_NOTE: like a C.XMLUI_DIALOG_MESSAGE, but action of user is not necessary to close, at frontend choice (it can be closed after a timeout). Usually the frontend display as a timed out notification