Mercurial > libervia-web
comparison browser_side/xmlui.py @ 229:e632f77c4219
bridge: asyncGetParamA takes a security_limit argument
browser_side: added support for user param of type "list"
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 08 Oct 2013 13:48:00 +0200 |
parents | 4e6467efd6bf |
children | fe83837d3491 |
comparison
equal
deleted
inserted
replaced
228:6efd189e8d78 | 229:e632f77c4219 |
---|---|
117 elif node_type=="list": | 117 elif node_type=="list": |
118 ctrl = ListBox() | 118 ctrl = ListBox() |
119 ctrl.setMultipleSelect(elem.getAttribute("multi")=='yes') | 119 ctrl.setMultipleSelect(elem.getAttribute("multi")=='yes') |
120 for option in elem.getElementsByTagName("option"): | 120 for option in elem.getElementsByTagName("option"): |
121 ctrl.addItem(option.getAttribute("value")) | 121 ctrl.addItem(option.getAttribute("value")) |
122 ctrl.selectItem(value) | |
122 self.ctrl_list[name] = ({'node_type':node_type, 'control':ctrl}) | 123 self.ctrl_list[name] = ({'node_type':node_type, 'control':ctrl}) |
123 elif node_type=="button": | 124 elif node_type=="button": |
124 callback_id = elem.getAttribute("callback_id") | 125 callback_id = elem.getAttribute("callback_id") |
125 ctrl = Button(value, self.onButtonPress) | 126 ctrl = Button(value, self.onButtonPress) |
126 ctrl.param_id = (callback_id,[field.getAttribute('name') for field in elem.getElementsByTagName("field_back")]) | 127 ctrl.param_id = (callback_id,[field.getAttribute('name') for field in elem.getElementsByTagName("field_back")]) |
127 else: | 128 else: |
128 print("FIXME FIXME FIXME: type [%s] is not implemented" % node_type) #FIXME ! | 129 print("FIXME FIXME FIXME: type [%s] is not implemented" % node_type) #FIXME ! |
129 raise NotImplementedError | 130 raise NotImplementedError |
130 if self.node_type == 'param': | 131 if self.node_type == 'param': |
131 if isinstance(ctrl,TextBoxBase): | 132 if isinstance(ctrl, TextBoxBase): |
132 ctrl.addChangeListener(self.onParamChange) | 133 ctrl.addChangeListener(self.onParamChange) |
133 elif isinstance(ctrl, CheckBox): | 134 elif isinstance(ctrl, CheckBox): |
134 ctrl.addClickListener(self.onParamChange) | 135 ctrl.addClickListener(self.onParamChange) |
136 elif isinstance(ctrl, ListBox): | |
137 ctrl.addChangeListener(self.onParamChange) | |
135 ctrl._param_category = self._current_category | 138 ctrl._param_category = self._current_category |
136 ctrl._param_name = name | 139 ctrl._param_name = name |
137 parent.append(ctrl) | 140 parent.append(ctrl) |
138 | 141 |
139 def __parseChilds(self, current, elem, wanted = ['layout'], data = None): | 142 def __parseChilds(self, current, elem, wanted = ['layout'], data = None): |
215 callback_id, fields = button.param_id | 218 callback_id, fields = button.param_id |
216 data = {"callback_id":callback_id} | 219 data = {"callback_id":callback_id} |
217 for field in fields: | 220 for field in fields: |
218 ctrl = self.ctrl_list[field] | 221 ctrl = self.ctrl_list[field] |
219 if isinstance(ctrl['control'],ListBox): | 222 if isinstance(ctrl['control'],ListBox): |
220 data[field] = '\t'.join(ctrl['control'].getSelectedValues()) | 223 data[field] = '\t'.join(ctrl['control'].getSelectedItemText()) |
221 elif isinstance(ctrl['control'],CheckBox): | 224 elif isinstance(ctrl['control'],CheckBox): |
222 data[field] = "true" if ctrl['control'].isChecked() else "false" | 225 data[field] = "true" if ctrl['control'].isChecked() else "false" |
223 else: | 226 else: |
224 data[field] = ctrl['control'].getText() | 227 data[field] = ctrl['control'].getText() |
225 | 228 |
238 print "FIXME FIXME FIXME: Form submitting not managed yet" | 241 print "FIXME FIXME FIXME: Form submitting not managed yet" |
239 data = [] | 242 data = [] |
240 for ctrl_name in self.ctrl_list: | 243 for ctrl_name in self.ctrl_list: |
241 ctrl = self.ctrl_list[ctrl_name] | 244 ctrl = self.ctrl_list[ctrl_name] |
242 if isinstance(ctrl['control'], ListBox): | 245 if isinstance(ctrl['control'], ListBox): |
243 data.append((ctrl_name, ctrl['control'].getValue())) | 246 data.append((ctrl_name, '\t'.join(ctrl['control'].getSelectedItemText()))) |
244 elif isinstance(ctrl['control'], CheckBox): | 247 elif isinstance(ctrl['control'], CheckBox): |
245 data.append((ctrl_name, "true" if ctrl['control'].isChecked() else "false")) | 248 data.append((ctrl_name, "true" if ctrl['control'].isChecked() else "false")) |
246 else: | 249 else: |
247 data.append((ctrl_name, ctrl['control'].getText())) | 250 data.append((ctrl_name, ctrl['control'].getText())) |
248 if 'action_back' in self.misc: #FIXME FIXME FIXME: WTF ! Must be cleaned | 251 if 'action_back' in self.misc: #FIXME FIXME FIXME: WTF ! Must be cleaned |
260 def onSaveParams(self, button): | 263 def onSaveParams(self, button): |
261 print "onSaveParams" | 264 print "onSaveParams" |
262 for ctrl in self.param_changed: | 265 for ctrl in self.param_changed: |
263 if isinstance(ctrl, CheckBox): | 266 if isinstance(ctrl, CheckBox): |
264 value = "true" if ctrl.isChecked() else "false" | 267 value = "true" if ctrl.isChecked() else "false" |
268 elif isinstance(ctrl, ListBox): | |
269 value = '\t'.join(ctrl.getSelectedItemText()) | |
265 else: | 270 else: |
266 value = ctrl.getText() | 271 value = ctrl.getText() |
267 self.host.bridge.call('setParam', None, ctrl._param_name, value, ctrl._param_category) | 272 self.host.bridge.call('setParam', None, ctrl._param_name, value, ctrl._param_category) |
268 self.close() | 273 self.close() |