Mercurial > libervia-backend
comparison frontends/src/tools/xmlui.py @ 804:5174657b3378
XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
- JidWidget is a text container a Jabber ID, this can be used by frontends for special treatment (e.g.: possibility to click on it)
- DividerWidget is a separator, like a blank or dashed line
- popup type is similar to normal window, but designed for a smaller popping window
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 04 Feb 2014 18:19:32 +0100 |
parents | f100fd8d279f |
children | 7c05c39156a2 |
comparison
equal
deleted
inserted
replaced
803:f100fd8d279f | 804:5174657b3378 |
---|---|
52 class TextWidget(Widget): | 52 class TextWidget(Widget): |
53 """ Non interactive text """ | 53 """ Non interactive text """ |
54 pass | 54 pass |
55 | 55 |
56 | 56 |
57 class LabelWidget(Widget): | |
58 """ Non interactive text """ | |
59 pass | |
60 | |
61 | |
62 class JidWidget(Widget): | |
63 """ Jabber ID """ | |
64 pass | |
65 | |
66 | |
67 class DividerWidget(Widget): | |
68 """ Separator """ | |
69 pass | |
70 | |
71 | |
57 class StringWidget(Widget): | 72 class StringWidget(Widget): |
58 """ Input widget with require a string | 73 """ Input widget with require a string |
59 often called Edit in toolkits | 74 often called Edit in toolkits |
60 | 75 |
61 """ | 76 """ |
121 | 136 |
122 | 137 |
123 class AdvancedListContainer(Container): | 138 class AdvancedListContainer(Container): |
124 """ Widgets are disposed in rows with advaned features """ | 139 """ Widgets are disposed in rows with advaned features """ |
125 pass | 140 pass |
141 | |
126 | 142 |
127 class XMLUI(object): | 143 class XMLUI(object): |
128 """ Base class to construct SàT XML User Interface | 144 """ Base class to construct SàT XML User Interface |
129 New frontends can inherite this class to easily implement XMLUI | 145 New frontends can inherite this class to easily implement XMLUI |
130 @property widget_factory: factory to create frontend-specific widgets | 146 @property widget_factory: factory to create frontend-specific widgets |
245 value = node.childNodes[0].wholeText | 261 value = node.childNodes[0].wholeText |
246 except IndexError: | 262 except IndexError: |
247 warning (_("text node has no child !")) | 263 warning (_("text node has no child !")) |
248 ctrl = self.widget_factory.createTextWidget(parent, value) | 264 ctrl = self.widget_factory.createTextWidget(parent, value) |
249 elif type_=="label": | 265 elif type_=="label": |
250 ctrl = self.widget_factory.createTextWidget(parent, value+": ") | 266 ctrl = self.widget_factory.createLabelWidget(parent, value) |
267 elif type_=="jid": | |
268 ctrl = self.widget_factory.createJidWidget(parent, value) | |
269 elif type_=="divider": | |
270 style = node.getAttribute("style") or 'line' | |
271 ctrl = self.widget_factory.createDividerWidget(parent, style) | |
251 elif type_=="string": | 272 elif type_=="string": |
252 ctrl = self.widget_factory.createStringWidget(parent, value) | 273 ctrl = self.widget_factory.createStringWidget(parent, value) |
253 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) | 274 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) |
254 elif type_=="password": | 275 elif type_=="password": |
255 ctrl = self.widget_factory.createPasswordWidget(parent, value) | 276 ctrl = self.widget_factory.createPasswordWidget(parent, value) |
298 top=cat_dom.documentElement | 319 top=cat_dom.documentElement |
299 self.type = top.getAttribute("type") | 320 self.type = top.getAttribute("type") |
300 self.title = self.title or top.getAttribute("title") or u"" | 321 self.title = self.title or top.getAttribute("title") or u"" |
301 self.session_id = top.getAttribute("session_id") or None | 322 self.session_id = top.getAttribute("session_id") or None |
302 self.submit_id = top.getAttribute("submit") or None | 323 self.submit_id = top.getAttribute("submit") or None |
303 if top.nodeName != "sat_xmlui" or not self.type in ['form', 'param', 'window']: | 324 if top.nodeName != "sat_xmlui" or not self.type in ['form', 'param', 'window', 'popup']: |
304 raise InvalidXMLUI | 325 raise InvalidXMLUI |
305 | 326 |
306 if self.type == 'param': | 327 if self.type == 'param': |
307 self.param_changed = set() | 328 self.param_changed = set() |
308 | 329 |