annotate frontends/wix/xmlui.py @ 103:6be927a465ed

XMLUI refactoring, step 1
author Goffi <goffi@goffi.org>
date Wed, 23 Jun 2010 00:23:26 +0800
parents frontends/wix/form.py@2503de7fb4c7
children 5458ac1380cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
4 """
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
5 wix: a SAT frontend
57
a5b5fb5fc9fd updated README and copyright note
Goffi <goffi@goffi.org>
parents: 37
diff changeset
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org)
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
7
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
11 (at your option) any later version.
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
12
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
16 GNU General Public License for more details.
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
17
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
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
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
22
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
23
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
24 import wx
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
25 import pdb
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from xml.dom import minidom
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
27 from logging import debug, info, warning, error
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from tools.jid import JID
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
29
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
30
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
31 class XMLUI(wx.Frame):
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
32 """Create an user interface from a SàT xml"""
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
33
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
34 def __init__(self, host, xml_data='', title="Form", options=[], misc={}):
92
2503de7fb4c7 Tarot game: chien/écart stage
Goffi <goffi@goffi.org>
parents: 91
diff changeset
35 style = wx.DEFAULT_FRAME_STYLE & ~wx.CLOSE_BOX if 'NO_CANCEL' in options else wx.DEFAULT_FRAME_STYLE #FIXME: gof: Q&D tmp hack
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
36 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
37
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
38 self.host = host
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
39 self.options = options
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
40 self.misc = misc
36
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 35
diff changeset
41 self.ctl_list = [] # usefull to access ctrl
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
42
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
43 self.sizer = wx.BoxSizer(wx.VERTICAL)
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
44 self.SetSizer(self.sizer)
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
45 self.SetAutoLayout(True)
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
46
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
47 #events
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
48 if not 'NO_CANCEL' in self.options:
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
49 self.Bind(wx.EVT_CLOSE, self.onClose, self)
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
50
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
51 self.MakeModal()
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
52
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
53 self.constructUI(xml_data)
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
54
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
55 self.Show()
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
56
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
57 def __parse_elems(self, childs, parent, sizer):
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
58 """Parse elements inside a <layout> tags, and add them to the sizer"""
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
59 for elem in childs:
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
60 if elem.nodeName != "elem":
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
61 message=_("Unmanaged tag")
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
62 error(message)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
63 raise Exception(message)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
64 _proportion = 0
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
65 name = elem.getAttribute("name")
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
66 type = elem.getAttribute("type")
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
67 value = elem.getAttribute("value") if elem.hasAttribute('value') else u''
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
68 if type=="empty":
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
69 ctrl = wx.Window(parent, -1)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
70 elif type=="text":
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
71 try:
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
72 value = elem.childNodes[0].wholeText
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
73 except KeyError:
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
74 warning (_("text node has no child !"))
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
75 ctrl = wx.StaticText(parent, -1, value)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
76 elif type=="label":
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
77 ctrl = wx.StaticText(parent, -1, value+": ")
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
78 elif type=="string":
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
79 ctrl = wx.TextCtrl(parent, -1, value)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
80 self.ctl_list.append({'name':name, 'type':type, 'control':ctrl})
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
81 _proportion = 1
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
82 elif type=="password":
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
83 ctrl = wx.TextCtrl(parent, -1, value, style=wx.TE_PASSWORD)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
84 self.ctl_list.append({'name':name, 'type':type, 'control':ctrl})
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
85 _proportion = 1
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
86 elif type=="list":
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
87 ctrl = wx.ListBox(parent, -1, choices=[option.getAttribute("value") for option in elem.getElementsByTagName("option")], style=wx.LB_SINGLE)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
88 self.ctl_list.append({'name':name, 'type':type, 'control':ctrl})
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
89 _proportion = 1
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
90 else:
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
91 error(_("FIXME FIXME FIXME: type [%s] is not implemented") % type) #FIXME !
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
92 raise NotImplementedError
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
93 sizer.Add(ctrl, _proportion, flag=wx.EXPAND)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
94
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
95
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
96
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
97 def constructUI(self, xml_data):
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
98 panel=wx.Panel(self)
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
99 panel.sizer = wx.BoxSizer(wx.VERTICAL)
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
100
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
101 cat_dom = minidom.parseString(xml_data.encode('utf-8'))
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
102 top= cat_dom.documentElement
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
103 self.type = top.getAttribute("type")
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
104 if top.nodeName != "sat_xmlui" or not self.type in ['form', 'param', 'window']:
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
105 message = _("XML UI received is invalid")
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
106 error(message)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
107 raise Exception(message)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
108
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
109 for node in cat_dom.documentElement.childNodes:
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
110 if node.nodeName == "layout":
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
111 layout_panel = wx.Panel(panel, -1)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
112 if node.getAttribute('type') == "vertical":
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
113 current_sizer = wx.BoxSizer(wx.VERTICAL)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
114 elif node.getAttribute('type') == "pairs":
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
115 current_sizer = wx.FlexGridSizer(cols=2)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
116 current_sizer.AddGrowableCol(1) #The growable column need most of time to be the right one in pairs
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
117 else:
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
118 warning(_("Unknown layout, using default one"))
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
119 current_sizer = wx.BoxSizer(wx.VERTICAL)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
120 layout_panel.SetSizer(current_sizer)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
121 self.__parse_elems(node.childNodes, layout_panel, current_sizer)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
122 panel.sizer.Add(layout_panel, flag=wx.EXPAND)
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
123 else:
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
124 message=_("Unknown tag")
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
125 error(message)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
126 raise Exception(message) #TODO: raise a custom exception here
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
127
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
128 if self.type == 'form':
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
129 dialogButtons = wx.StdDialogButtonSizer()
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
130 submitButton = wx.Button(panel,wx.ID_OK, label=_("Submit"))
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
131 dialogButtons.AddButton(submitButton)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
132 panel.Bind(wx.EVT_BUTTON, self.onFormSubmitted, submitButton)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
133 if not 'NO_CANCEL' in self.options:
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
134 cancelButton = wx.Button(panel,wx.ID_CANCEL)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
135 dialogButtons.AddButton(cancelButton)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
136 panel.Bind(wx.EVT_BUTTON, self.onFormCancelled, cancelButton)
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
137 dialogButtons.Realize()
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 92
diff changeset
138 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
139
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
140 panel.SetSizer(panel.sizer)
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
141 panel.SetAutoLayout(True)
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
142 panel.sizer.Fit(self)
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
143 self.sizer.Add(panel, 1, flag=wx.EXPAND)
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
144 cat_dom.unlink()
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
145
36
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 35
diff changeset
146 def onFormSubmitted(self, event):
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 35
diff changeset
147 """Called when submit button is clicked"""
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
148 debug(_("Submitting form"))
36
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 35
diff changeset
149 data = []
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 35
diff changeset
150 for ctrl in self.ctl_list:
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
151 if isinstance(ctrl['control'], wx.ListBox):
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
152 data.append((ctrl['name'], ctrl['control'].GetStringSelection()))
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
153 else:
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
154 data.append((ctrl["name"], ctrl["control"].GetValue()))
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
155 if self.misc.has_key('action_back'): #FIXME FIXME FIXME: WTF ! Must be cleaned
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
156 id = self.misc['action_back']("SUBMIT",self.misc['target'], data)
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
157 self.host.current_action_ids.add(id)
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
158 elif self.misc.has_key('callback'):
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
159 self.misc['callback'](data)
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
160 else:
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 70
diff changeset
161 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
162 self.MakeModal(False)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
163 self.Destroy()
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
164
36
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 35
diff changeset
165 def onFormCancelled(self, event):
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 35
diff changeset
166 """Called when cancel button is clicked"""
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
167 debug(_("Cancelling form"))
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
168 self.MakeModal(False)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 36
diff changeset
169 self.Close()
36
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 35
diff changeset
170
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
171 def onClose(self, event):
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
172 """Close event: we have to send the form."""
70
Goffi <goffi@goffi.org>
parents: 57
diff changeset
173 debug(_("close"))
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
174 self.MakeModal(False)
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
175 event.Skip()
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff changeset
176