comparison sat/tools/xml_tools.py @ 2668:c274201cea94

core, frontends (xmlui): added "hidden" widget, to specify a value to be returned unmodified
author Goffi <goffi@goffi.org>
date Fri, 31 Aug 2018 15:57:11 +0200
parents a55a14c3cbf4
children 5c2ed8a5ae22
comparison
equal deleted inserted replaced
2667:8dd9db785ac8 2668:c274201cea94
76 widget_kwargs["read_only"] = read_only 76 widget_kwargs["read_only"] = read_only
77 elif field.fieldType == "text-multi": 77 elif field.fieldType == "text-multi":
78 widget_type = "textbox" 78 widget_type = "textbox"
79 widget_args[0] = u"\n".join(field.values) 79 widget_args[0] = u"\n".join(field.values)
80 widget_kwargs["read_only"] = read_only 80 widget_kwargs["read_only"] = read_only
81 elif field.fieldType == "hidden":
82 widget_type = "hidden"
81 elif field.fieldType == "text-private": 83 elif field.fieldType == "text-private":
82 widget_type = "password" 84 widget_type = "password"
83 widget_kwargs["read_only"] = read_only 85 widget_kwargs["read_only"] = read_only
84 elif field.fieldType == "boolean": 86 elif field.fieldType == "boolean":
85 widget_type = "bool" 87 widget_type = "bool"
146 pass 148 pass
147 else: 149 else:
148 widget_type, widget_args, widget_kwargs = widget_filter( 150 widget_type, widget_args, widget_kwargs = widget_filter(
149 form_ui, widget_type, widget_args, widget_kwargs 151 form_ui, widget_type, widget_args, widget_kwargs
150 ) 152 )
151 label = field.label or field.var 153 if widget_type != "hidden":
152 if label: 154 label = field.label or field.var
153 form_ui.addLabel(label) 155 if label:
154 else: 156 form_ui.addLabel(label)
155 form_ui.addEmpty() 157 else:
158 form_ui.addEmpty()
156 159
157 form_ui.addWidget(widget_type, *widget_args, **widget_kwargs) 160 form_ui.addWidget(widget_type, *widget_args, **widget_kwargs)
158 161
159 return form_ui 162 return form_ui
160 163
900 class LabelWidget(Widget): 903 class LabelWidget(Widget):
901 """One line blob of text 904 """One line blob of text
902 905
903 used most of time to display the desciption or name of the next widget 906 used most of time to display the desciption or name of the next widget
904 """ 907 """
905
906 type = "label" 908 type = "label"
907 909
908 def __init__(self, xmlui, label, name=None, parent=None): 910 def __init__(self, xmlui, label, name=None, parent=None):
909 super(LabelWidget, self).__init__(xmlui, name, parent) 911 super(LabelWidget, self).__init__(xmlui, name, parent)
910 self.elem.setAttribute("value", label) 912 self.elem.setAttribute("value", label)
913
914
915 class HiddenWidget(Widget):
916 """Not displayed widget, frontends will just copy the value(s)"""
917 type = "hidden"
918
919 def __init__(self, xmlui, value, name, parent=None):
920 super(HiddenWidget, self).__init__(xmlui, name, parent)
921 value_elt = self.xmlui.doc.createElement("value")
922 text = self.xmlui.doc.createTextNode(value)
923 value_elt.appendChild(text)
924 self.elem.appendChild(value_elt)
925
926 @property
927 def value(self):
928 return self.elem.firstChild.firstChild.wholeText
911 929
912 930
913 class JidWidget(Widget): 931 class JidWidget(Widget):
914 """Used to display a Jabber ID, some specific methods can be added""" 932 """Used to display a Jabber ID, some specific methods can be added"""
915 933