Mercurial > libervia-backend
annotate frontends/src/wix/xmlui.py @ 795:6625558371db
test: added tests for the plugin "room game" + rename other test files
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 10 Jan 2014 18:20:30 +0100 |
parents | bfabeedbf32e |
children | 46aa5ada61bf |
rev | line source |
---|---|
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
4 # wix: a SAT frontend |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org) |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
10 # (at your option) any later version. |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
15 # GNU Affero General Public License for more details. |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 |
771 | 22 from sat.core.i18n import _ |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 import wx |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 import pdb |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 from xml.dom import minidom |
91 | 26 from logging import debug, info, warning, error |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
27 from sat.tools.jid import JID |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 |
762
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
29 SAT_FORM_PREFIX = "SAT_FORM_" |
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
30 |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
103 | 32 class XMLUI(wx.Frame): |
33 """Create an user interface from a SàT xml""" | |
91 | 34 |
555
1d58758689e9
primitivus, wix: fixed bad defaults values for XMLUI class
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
35 def __init__(self, host, xml_data='', title="Form", options = None, misc = None): |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
36 if options is None: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
37 options = [] |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
38 style = wx.DEFAULT_FRAME_STYLE & ~wx.CLOSE_BOX if 'NO_CANCEL' in options else wx.DEFAULT_FRAME_STYLE #FIXME: Q&D tmp hack |
103 | 39 super(XMLUI, self).__init__(None, title=title, style=style) |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 self.host = host |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
42 self.options = options |
555
1d58758689e9
primitivus, wix: fixed bad defaults values for XMLUI class
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
43 self.misc = misc or {} |
107 | 44 self.ctrl_list = {} # usefull to access ctrl |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 self.sizer = wx.BoxSizer(wx.VERTICAL) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 self.SetSizer(self.sizer) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 self.SetAutoLayout(True) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
49 |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 #events |
91 | 51 if not 'NO_CANCEL' in self.options: |
52 self.Bind(wx.EVT_CLOSE, self.onClose, self) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
53 |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 self.MakeModal() |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 |
103 | 56 self.constructUI(xml_data) |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 self.Show() |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 |
104 | 60 def __parseElems(self, node, parent): |
61 """Parse elements inside a <layout> tags, and add them to the parent sizer""" | |
62 for elem in node.childNodes: | |
103 | 63 if elem.nodeName != "elem": |
64 message=_("Unmanaged tag") | |
65 error(message) | |
66 raise Exception(message) | |
67 _proportion = 0 | |
106 | 68 id = elem.getAttribute("id") |
103 | 69 name = elem.getAttribute("name") |
70 type = elem.getAttribute("type") | |
71 value = elem.getAttribute("value") if elem.hasAttribute('value') else u'' | |
72 if type=="empty": | |
73 ctrl = wx.Window(parent, -1) | |
74 elif type=="text": | |
75 try: | |
76 value = elem.childNodes[0].wholeText | |
149 | 77 except IndexError: |
103 | 78 warning (_("text node has no child !")) |
79 ctrl = wx.StaticText(parent, -1, value) | |
80 elif type=="label": | |
81 ctrl = wx.StaticText(parent, -1, value+": ") | |
82 elif type=="string": | |
83 ctrl = wx.TextCtrl(parent, -1, value) | |
107 | 84 self.ctrl_list[name] = ({'type':type, 'control':ctrl}) |
103 | 85 _proportion = 1 |
86 elif type=="password": | |
87 ctrl = wx.TextCtrl(parent, -1, value, style=wx.TE_PASSWORD) | |
107 | 88 self.ctrl_list[name] = ({'type':type, 'control':ctrl}) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
89 _proportion = 1 |
107 | 90 elif type=="textbox": |
91 ctrl = wx.TextCtrl(parent, -1, value, style=wx.TE_MULTILINE) | |
92 self.ctrl_list[name] = ({'type':type, 'control':ctrl}) | |
103 | 93 _proportion = 1 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
94 elif type=="bool": |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
95 ctrl = wx.CheckBox(panel, -1, "", style = wx.CHK_2STATE) |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
96 ctrl.SetValue(value=="true") |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
97 self.ctrl_list[name] = ({'type':type, 'control':ctrl}) |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
98 _proportion = 1 |
103 | 99 elif type=="list": |
107 | 100 style=wx.LB_MULTIPLE if elem.getAttribute("multi")=='yes' else wx.LB_SINGLE |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
101 _options = [(option.getAttribute("label"), option.getAttribute("value")) for option in elem.getElementsByTagName("option")] |
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
102 attr_map = {label: value for label, value in _options} |
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
103 ctrl = wx.ListBox(parent, -1, choices=[option[0] for option in _options], style=style) |
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
104 self.ctrl_list[name] = ({'type':type, 'control':ctrl, 'attr_map': attr_map}) |
103 | 105 _proportion = 1 |
105 | 106 elif type=="button": |
106 | 107 callback_id = elem.getAttribute("callback_id") |
108 ctrl = wx.Button(parent, -1, value) | |
107 | 109 ctrl.param_id = (callback_id,[field.getAttribute('name') for field in elem.getElementsByTagName("field_back")]) |
106 | 110 parent.Bind(wx.EVT_BUTTON, self.onButtonClicked, ctrl) |
103 | 111 else: |
112 error(_("FIXME FIXME FIXME: type [%s] is not implemented") % type) #FIXME ! | |
113 raise NotImplementedError | |
104 | 114 parent.sizer.Add(ctrl, _proportion, flag=wx.EXPAND) |
103 | 115 |
104 | 116 def __parseChilds(self, parent, current_param, elem, wanted = ['layout']): |
117 """Recursively parse childNodes of an elemen | |
118 @param parent: parent wx.Window | |
119 @param current_param: current wx.Window (often wx.Panel) or None if we must create one | |
120 @param elem: element from which childs will be parsed | |
121 @param wanted: list of tag names that can be present in the childs to be SàT XMLUI compliant""" | |
122 for node in elem.childNodes: | |
123 if wanted and not node.nodeName in wanted: | |
124 raise Exception("Invalid XMLUI") #TODO: make a custom exception | |
125 if node.nodeName == "layout": | |
105 | 126 _proportion = 0 |
104 | 127 type = node.getAttribute('type') |
128 if type == "tabs": | |
129 current = wx.Notebook(parent, -1, style=wx.NB_LEFT if self.type=='param' else 0) | |
130 self.__parseChilds(current, None, node, ['category']) | |
105 | 131 _proportion = 1 |
104 | 132 else: |
133 if current_param == None: | |
134 current = wx.Panel(parent, -1) | |
135 else: | |
136 current = current_param | |
137 if type == "vertical": | |
138 current.sizer = wx.BoxSizer(wx.VERTICAL) | |
139 elif type == "pairs": | |
140 current.sizer = wx.FlexGridSizer(cols=2) | |
141 current.sizer.AddGrowableCol(1) #The growable column need most of time to be the right one in pairs | |
142 else: | |
143 warning(_("Unknown layout, using default one")) | |
144 current.sizer = wx.BoxSizer(wx.VERTICAL) | |
145 current.SetSizer(current.sizer) | |
146 self.__parseElems(node, current) | |
147 if parent: | |
105 | 148 parent.sizer.Add(current, _proportion, flag=wx.EXPAND) |
104 | 149 elif node.nodeName == "category": |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
150 name = node.getAttribute('name') |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
151 label = node.getAttribute('label') |
104 | 152 if not node.nodeName in wanted or not name or not isinstance(parent,wx.Notebook): |
153 raise Exception("Invalid XMLUI") #TODO: make a custom exception | |
154 notebook = parent | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
155 tab_panel = wx.Panel(notebook, -1) |
104 | 156 tab_panel.sizer = wx.BoxSizer(wx.VERTICAL) |
157 tab_panel.SetSizer(tab_panel.sizer) | |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
158 notebook.AddPage(tab_panel, label or name) |
104 | 159 self.__parseChilds(tab_panel, None, node, ['layout']) |
160 | |
161 else: | |
162 message=_("Unknown tag") | |
163 error(message) | |
164 raise Exception(message) #TODO: raise a custom exception here | |
103 | 165 |
166 | |
167 def constructUI(self, xml_data): | |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 panel=wx.Panel(self) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 panel.sizer = wx.BoxSizer(wx.VERTICAL) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
170 |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 cat_dom = minidom.parseString(xml_data.encode('utf-8')) |
103 | 172 top= cat_dom.documentElement |
173 self.type = top.getAttribute("type") | |
107 | 174 self.title = top .getAttribute("title") |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
175 self.session_id = top.getAttribute("session_id") or None |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
176 self.submit_id = top.getAttribute("submit") or None |
107 | 177 if self.title: |
178 self.SetTitle(self.title) | |
103 | 179 if top.nodeName != "sat_xmlui" or not self.type in ['form', 'param', 'window']: |
104 | 180 raise Exception("Invalid XMLUI") #TODO: make a custom exception |
103 | 181 |
104 | 182 self.__parseChilds(panel, None, cat_dom.documentElement) |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
183 |
103 | 184 if self.type == 'form': |
185 dialogButtons = wx.StdDialogButtonSizer() | |
186 submitButton = wx.Button(panel,wx.ID_OK, label=_("Submit")) | |
187 dialogButtons.AddButton(submitButton) | |
188 panel.Bind(wx.EVT_BUTTON, self.onFormSubmitted, submitButton) | |
189 if not 'NO_CANCEL' in self.options: | |
190 cancelButton = wx.Button(panel,wx.ID_CANCEL) | |
191 dialogButtons.AddButton(cancelButton) | |
192 panel.Bind(wx.EVT_BUTTON, self.onFormCancelled, cancelButton) | |
193 dialogButtons.Realize() | |
194 panel.sizer.Add(dialogButtons, flag=wx.ALIGN_CENTER_HORIZONTAL) | |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
195 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 panel.SetSizer(panel.sizer) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
197 panel.SetAutoLayout(True) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 panel.sizer.Fit(self) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 self.sizer.Add(panel, 1, flag=wx.EXPAND) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 cat_dom.unlink() |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
201 |
106 | 202 ###events |
203 | |
204 def onButtonClicked(self, event): | |
205 """Called when a button is pushed""" | |
107 | 206 callback_id, fields = event.GetEventObject().param_id |
207 for field in fields: | |
208 ctrl = self.ctrl_list[field] | |
209 if isinstance(ctrl['control'], wx.ListBox): | |
210 data[field] = '\t'.join([ctrl['control'].GetString(idx) for idx in ctrl['control'].GetSelections()]) | |
211 else: | |
212 data[field] = ctrl['control'].GetValue() | |
213 | |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
214 self.host.launchAction(callback_id, None, profile_key = self.host.profile) |
106 | 215 event.Skip() |
216 | |
36 | 217 def onFormSubmitted(self, event): |
218 """Called when submit button is clicked""" | |
70 | 219 debug(_("Submitting form")) |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
220 selected_values = [] |
107 | 221 for ctrl_name in self.ctrl_list: |
762
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
222 escaped = u"%s%s" % (SAT_FORM_PREFIX, ctrl_name) |
107 | 223 ctrl = self.ctrl_list[ctrl_name] |
91 | 224 if isinstance(ctrl['control'], wx.ListBox): |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
225 label = ctrl['control'].GetStringSelection() |
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
226 value = ctrl['attr_map'][label] |
762
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
227 selected_values.append((escaped, value)) |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
228 elif isinstance(ctrl['control'], wx.CheckBox): |
762
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
229 selected_values.append((escaped, "true" if ctrl['control'].GetValue() else "false")) |
91 | 230 else: |
762
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
231 selected_values.append((escaped, ctrl['control'].GetValue())) |
91 | 232 if self.misc.has_key('action_back'): #FIXME FIXME FIXME: WTF ! Must be cleaned |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
233 id = self.misc['action_back']("SUBMIT",self.misc['target'], selected_values) |
91 | 234 self.host.current_action_ids.add(id) |
235 elif self.misc.has_key('callback'): | |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
236 self.misc['callback'](selected_values) |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
237 |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
238 elif self.submit_id is not None: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
239 data = dict(selected_values) |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
240 if self.session_id is not None: |
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
241 data["session_id"] = self.session_id |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
242 self.host.launchAction(self.submit_id, data, profile_key=self.host.profile) |
91 | 243 else: |
244 warning (_("The form data is not sent back, the type is not managed properly")) | |
37
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
245 self.MakeModal(False) |
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
246 self.Destroy() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
247 |
36 | 248 def onFormCancelled(self, event): |
249 """Called when cancel button is clicked""" | |
70 | 250 debug(_("Cancelling form")) |
37
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
251 self.MakeModal(False) |
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
252 self.Close() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
253 |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
254 def onClose(self, event): |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
255 """Close event: we have to send the form.""" |
70 | 256 debug(_("close")) |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
257 self.MakeModal(False) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
258 event.Skip() |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
259 |