galician
[iramuteq] / dialog.py
1 #!/bin/env python
2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2009 Pierre Ratinaud
5 #License: GNU/GPL
6 import  wx
7 import  wx.lib.colourselect as csel
8 import wx.lib.sized_controls as sc
9 import wx.lib.filebrowsebutton as filebrowse
10 import locale
11 from functions import DoConf
12 import os
13 import sys
14 from KeyFrame import AlcOptFrame
15 #---------------------------------------------------------------------------
16 provider = wx.SimpleHelpProvider()
17 wx.HelpProvider_Set(provider)
18
19 #---------------------------------------------------------------------------
20
21
22 encodages = [[u'cp1252',u'Western Europe'], [u'utf-8',u'all languages'], [u'MacRoman',u'Western Europe'], [u'ascii', u'English'], [u'big5', u'Traditional Chinese'], [u'big5hkscs', u'Traditional Chinese'], [u'cp037', u'English'], [u'cp424', u'Hebrew'], [u'cp437', u'English'], [u'cp500', u'Western Europe'], [u'cp737', u'Greek'], [u'cp775', u'Baltic languages'], [u'cp850', u'Western Europe'], [u'cp852', u'Central and Eastern Europe'], [u'cp855', u'Bulg, Byelorus, Mace, Rus, Serb'], [u'cp856', u'Hebrew'], [u'cp857', u'Turkish'], [u'cp860', u'Portuguese'], [u'cp861', u'Icelandic'], [u'cp862', u'Hebrew'], [u'cp863', u'Canadian'], [u'cp864', u'Arabic'], [u'cp865', u'Danish, Norwegian'], [u'cp866', u'Russian'], [u'cp869', u'Greek'], [u'cp874', u'Thai'], [u'cp875', u'Greek'], [u'cp932', u'Japanese'], [u'cp949', u'Korean'], [u'cp950', u'Traditional Chinese'], [u'cp1006', u'Urdu'], [u'cp1026', u'Turkish'], [u'cp1140', u'Western Europe'], [u'cp1250', u'Central and Eastern Europe'], [u'cp1251', u'Bulg, Byelorus, Mace, Rus, Serb'], [u'cp1253', u'Greek'], [u'cp1254', u'Turkish'], [u'cp1255', u'Hebrew'], [u'cp1256', u'Arabic'], [u'cp1257', u'Baltic languages'], [u'cp1258', u'Vietnamese'], [u'euc_jp', u'Japanese'], [u'euc_jis_2004', u'Japanese'], [u'euc_jisx0213', u'Japanese'], [u'euc_kr', u'Korean'], [u'gb2312', u'Simplified Chinese'], [u'gbk', u'Unified Chinese'], [u'gb18030', u'Unified Chinese'], [u'hz', u'Simplified Chinese'], [u'iso2022_jp', u'Japanese'], [u'iso2022_jp_1', u'Japanese'], [u'iso2022_jp_2', u'Jp, K, S C, WE, G'], [u'iso2022_jp_2004', u'Japanese'], [u'iso2022_jp_3', u'Japanese'], [u'iso2022_jp_ext', u'Japanese'], [u'iso2022_kr', u'Korean'], [u'latin_1', u'West Europe'], [u'iso8859_2', u'Central and Eastern Europe'], [u'iso8859_3', u'Esperanto, Maltese'], [u'iso8859_4', u'Baltic languages'], [u'iso8859_5', u'Bulg, Byelorus, Mace, Rus, Serb'], [u'iso8859_6', u'Arabic'], [u'iso8859_7', u'Greek'], [u'iso8859_8', u'Hebrew'], [u'iso8859_9', u'Turkish'], [u'iso8859_10', u'Nordic languages'], [u'iso8859_13', u'Baltic languages'], [u'iso8859_14', u'Celtic languages'], [u'iso8859_15', u'Western Europe'], [u'iso8859_16', u'South-Eastern Europe'], [u'johab', u'Korean'], [u'koi8_r', u'Russian'], [u'koi8_u', u'Ukrainian'], [u'mac_cyrillic', u'Bulg, Byelorus, Mace, Rus, Serb'], [u'mac_greek', u'Greek'], [u'mac_iceland', u'Icelandic'], [u'mac_latin2', u'Central and Eastern Europe'], [u'mac_turkish', u'Turkish'], [u'ptcp154', u'Kazakh'], [u'shift_jis', u'Japanese'], [u'shift_jis_2004', u'Japanese'], [u'shift_jisx0213', u'Japanese'], [u'utf_32', u'all languages'], [u'utf_32_be', u'all languages'], [u'utf_32_le', u'all languages'], [u'utf_16', u'all languages'], [u'utf_16_be', u'all languages (BMP only)'], [u'utf_16_le', u'all languages (BMP only)'], [u'utf_7', u'all languages'], [u'utf_8_sig', u'all languages']]
23
24 class FileOptionDialog(wx.Dialog):
25     def __init__(
26             self, parent, ID, title, sep=False, sheet = False, size=wx.DefaultSize, pos=wx.DefaultPosition,
27             style=wx.DEFAULT_DIALOG_STYLE
28             ):
29
30         pre = wx.PreDialog()
31         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
32         pre.Create(parent, ID, title, pos, size, style)
33
34         self.PostCreate(pre)
35
36         sizer = wx.BoxSizer(wx.VERTICAL)
37         grid_sizer = wx.FlexGridSizer(0, 2, 2, 2)
38 ##############################
39
40         label = wx.StaticText(self, -1, _(u"First line is header").decode('utf8'))
41         label.SetHelpText(_(u"First line is header").decode('utf8'))
42         grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
43         on = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
44         self.radio_box_1 = wx.RadioBox(self, -1, u"", choices=on, majorDimension=0, style=wx.RA_SPECIFY_ROWS)
45         self.radio_box_1.SetHelpText(_(u"First line is header").decode('utf8'))
46         grid_sizer.Add(self.radio_box_1, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
47
48 ##############################
49
50         label = wx.StaticText(self, -1, _(u"First column is an id").decode('utf8'))
51         label.SetHelpText(_(u"First column is an id").decode('utf8'))
52         grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
53         on = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
54         self.radio_box_2 = wx.RadioBox(self, -1, u"", choices=on, majorDimension=0, style=wx.RA_SPECIFY_ROWS)
55         self.radio_box_2.SetHelpText(_(u"First column is an id").decode('utf8'))
56         grid_sizer.Add(self.radio_box_2, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
57
58 ##############################
59         if sep:
60             label = wx.StaticText(self, -1, _(u"Column separator").decode('utf8'))
61             label.SetHelpText(_(u"Column separator").decode('utf8'))
62             grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
63             self.colsep = [";", "tabulation", ","]
64             self.choice3 = wx.Choice(self, -1, (100, 50), choices=self.colsep)
65             self.choice3.SetHelpText(_(u"Column separator").decode('utf8'))
66             grid_sizer.Add(self.choice3, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
67     
68     ##############################
69     
70             label = wx.StaticText(self, -1, _(u"Text separator").decode('utf8'))
71             label.SetHelpText(_(u"Text separator").decode('utf8'))
72             grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
73             self.txtsep = ["\"", "'"]
74             self.choice4 = wx.Choice(self, -1, (100, 50), choices=self.txtsep)
75             self.choice4.SetHelpText(_(u"Text separator").decode('utf8'))
76             grid_sizer.Add(self.choice4, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
77             self.choice3.SetSelection(0)
78             self.choice4.SetSelection(0)
79             self.text = wx.StaticText(self, -1, _(u"Character set").decode('utf8'))
80             grid_sizer.Add(self.text, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
81             self.le = [enc[0].lower() for enc in encodages] 
82             self.list_encodages = wx.Choice(self, -1, (25, 30), choices=[' - '.join(encodage) for encodage in encodages])
83             if locale.getpreferredencoding().lower() == 'mac-roman' :
84                 enc = self.le.index('macroman')
85             else :
86                 try :
87                     enc = self.le.index(sys.getdefaultencoding().lower())
88                 except ValueError:
89                     enc = self.le.index('utf-8')
90             self.list_encodages.SetSelection(enc)
91             grid_sizer.Add(self.list_encodages, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
92         elif sheet :
93             label = wx.StaticText(self, -1, u"Feuille ")
94             grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
95             self.spin1 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=500)
96             grid_sizer.Add(self.spin1, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
97         
98         sizer.Add(grid_sizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
99
100
101         line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
102         sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)
103
104         btnsizer = wx.StdDialogButtonSizer()
105         
106         if wx.Platform != "__WXMSW__":
107             btn = wx.ContextHelpButton(self)
108             btnsizer.AddButton(btn)
109         
110         btn = wx.Button(self, wx.ID_OK)
111         btn.SetDefault()
112         btnsizer.AddButton(btn)
113
114         btn = wx.Button(self, wx.ID_CANCEL)
115         btnsizer.AddButton(btn)
116         btnsizer.Realize()
117
118         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5)
119
120         self.SetSizer(sizer)
121         sizer.Fit(self)
122
123
124 class ClusterNbDialog(wx.Dialog):
125     def __init__(
126             self, LIST_CLASSE, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition,
127             style=wx.DEFAULT_DIALOG_STYLE
128             ):
129
130         pre = wx.PreDialog()
131         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
132         pre.Create(parent, ID, title, pos, size, style)
133
134         self.PostCreate(pre)
135
136         # Now continue with the normal construction of the dialog
137         # contents
138         sizer = wx.BoxSizer(wx.VERTICAL)
139
140         label = wx.StaticText(self, -1, u"Résultats de la classification")
141         label.SetHelpText("This is the help text for the label")
142         sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
143
144         box = wx.BoxSizer(wx.HORIZONTAL)
145
146         label = wx.StaticText(self, -1, u"Choisissez le nombre de classes")
147         label.SetHelpText("This is the help text for the label")
148         box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
149         LIST_CLASSE_OK = []
150         if type(LIST_CLASSE) != float :
151             for i in LIST_CLASSE :
152                 LIST_CLASSE_OK.append(str(i))
153         else :
154             LIST_CLASSE_OK.append(str(LIST_CLASSE))
155         self.list_box_1 = wx.ListBox(self, -1, choices=LIST_CLASSE_OK, style=wx.LB_SINGLE | wx.LB_HSCROLL)
156         self.list_box_1.SetHelpText("Here's some help text for field #1")
157         box.Add(self.list_box_1, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
158
159         sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
160
161
162 ###############################
163         line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
164         sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)
165
166         btnsizer = wx.StdDialogButtonSizer()
167         
168         if wx.Platform != "__WXMSW__":
169             btn = wx.ContextHelpButton(self)
170             btnsizer.AddButton(btn)
171         
172         btn = wx.Button(self, wx.ID_OK)
173         btn.SetDefault()
174         btnsizer.AddButton(btn)
175
176         btn = wx.Button(self, wx.ID_CANCEL)
177         btnsizer.AddButton(btn)
178         btnsizer.Realize()
179
180         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
181
182         self.SetSizer(sizer)
183         sizer.Fit(self)
184
185 class CHDDialog(wx.Dialog):
186     def __init__(
187             self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition,
188             style=wx.DEFAULT_DIALOG_STYLE | wx.CANCEL
189             ):
190         pre = wx.PreDialog()
191         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
192         pre.Create(parent, ID, title, pos, size, style)
193
194         self.PostCreate(pre)
195        
196         self.colsep = parent.colsep
197         self.Box = 1
198         self.content = parent.content[:]
199         self.header = parent.header[:]
200         LABELLIST = []
201         for i in self.header:
202             if len(i) > 60 :
203                 LABELLIST.append(i[0:60])
204             else:
205                 LABELLIST.append(i)
206         self.LABELLISTTOT = LABELLIST
207         self.LISTVARSUP = []
208 #----------------------------------------------------------------------------------------------------
209         self.text1 = wx.StaticText(self, -1, u"Variables Actives (au moins 3)")
210         self.text2 = wx.StaticText(self, -1, u"Variables Supplémentaires (au moins 1)")
211         self.list_box_1 = wx.ListBox(self, -1, choices=LABELLIST, style=wx.LB_EXTENDED | wx.LB_HSCROLL)
212         self.list_box_2 = wx.ListBox(self, -1, choices=LABELLIST, style=wx.LB_EXTENDED | wx.LB_HSCROLL)
213         self.button_cancel = wx.Button(self, wx.ID_CANCEL)
214         self.button_back = wx.Button(self, wx.ID_BACKWARD)
215         self.button_forw = wx.Button(self, wx.ID_FORWARD)
216         self.button_ok = wx.Button(self, wx.ID_OK)
217         self.button_pref = wx.Button(self, wx.ID_PROPERTIES)
218         self.button_selectall = wx.Button(self, wx.NewId(), u"Sélectionner tout")
219         self.__set_properties()
220         self.__do_layout()
221
222         self.Bind(wx.EVT_BUTTON, self.OnPrec, self.button_back)
223         self.Bind(wx.EVT_BUTTON, self.OnSuivant, self.button_forw)
224         self.Bind(wx.EVT_BUTTON, self.OnValider, self.button_ok)
225         self.Bind(wx.EVT_BUTTON, self.OnSelectAll, self.button_selectall)
226         # end wxGlade
227         self.parent = parent
228         self.TEMPDIR = parent.TEMPDIR
229         self.num = 0
230
231     def __set_properties(self):
232         # begin wxGlade: ConfChi2.__set_properties
233         self.SetTitle(u"Sélection des variables")
234         self.list_box_2.Enable(False)
235         self.button_ok.Enable(False)        
236         self.button_back.Enable(False)
237         # end wxGlade
238
239     def __do_layout(self):
240         # begin wxGlade: ConfChi2.__do_layout
241         sizer_1 = wx.BoxSizer(wx.VERTICAL)
242         sizer_2 = wx.BoxSizer(wx.VERTICAL)
243         sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
244         sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
245         sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
246         sizer_6 = wx.BoxSizer(wx.HORIZONTAL)
247         sizer_7 = wx.BoxSizer(wx.HORIZONTAL)
248         sizer_5.Add(self.text1, 1, wx.CENTER | wx.ALL, 0)
249         sizer_5.Add(self.text2, 1, wx.CENTER | wx.ALL, 0)
250         sizer_3.Add(self.list_box_1, 0, wx.EXPAND, 0)
251         sizer_3.Add(self.list_box_2, 0, wx.EXPAND, 0)
252         sizer_6.Add(self.button_selectall, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 0) 
253         sizer_7.Add(self.button_cancel, 0, wx.ALL, 0)
254         sizer_7.Add(self.button_pref, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
255         sizer_7.Add(self.button_ok, 0, wx.wx.ALIGN_CENTER_HORIZONTAL, 0)
256         sizer_4.Add(self.button_back, 0, wx.ALL, 0)
257         sizer_4.Add(self.button_forw, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
258         sizer_2.Add(sizer_5, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
259         sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
260         sizer_2.Add(sizer_6, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
261         sizer_2.Add(sizer_4, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
262         sizer_2.Add(sizer_7, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
263         sizer_1.Add(sizer_2, 1, wx.EXPAND, 4)
264         self.SetSizer(sizer_1)
265         sizer_1.Fit(self)
266         self.Layout()
267         # end wxGlade
268 #--------------FIXME-----------------------
269 #NETTOYAGE des variables inutiles
270     def OnSuivant(self, event): 
271         LISTACTIVE = self.list_box_1.GetSelections()
272         if len(LISTACTIVE) != len(self.LABELLISTTOT) and len(LISTACTIVE) >= 3: 
273             self.button_ok.Enable(True)
274         self.Box = 2
275         self.LISTHEADERINDICE = []
276         self.LISTNUMACTIVE = []
277         COMPT = 0
278         header = self.header[:]
279         for i in range(0, len(header)):
280             self.LISTHEADERINDICE.append(i)
281         for i in LISTACTIVE :
282             self.LISTNUMACTIVE.append(i)
283             header.pop(i - COMPT)
284             self.LISTHEADERINDICE.pop(i - COMPT)
285             COMPT += 1
286         self.LABELLIST = []
287         for i in header:
288             if len(i) > 60 :
289                 self.LABELLIST.append(i[0:60])
290             else:
291                 self.LABELLIST.append(i)
292         self.list_box_2.Clear()
293         for i in self.LABELLIST :
294             self.list_box_2.Append(i)
295                     
296         self.list_box_1.Enable(False)    
297         self.list_box_2.Enable(True)
298         self.button_forw.Enable(False)
299         self.button_back.Enable(True)
300
301     def OnValider(self, event):
302         LISTVARSUPSEL = self.list_box_2.GetSelections()
303         for i in LISTVARSUPSEL :
304             self.LISTVARSUP.append(self.LISTHEADERINDICE[i])
305         event.Skip()
306
307     def OnPrec(self, event):
308         self.list_box_1.Enable(True)
309         self.list_box_2.Enable(False)
310         self.button_forw.Enable(True)
311         self.button_back.Enable(False)   
312         self.button_ok.Enable(False)
313         self.Box = 1
314         event.Skip()
315
316     def OnSelectAll(self, event):
317         if self.Box == 1:
318             for i in range(len(self.LABELLISTTOT)):
319                 self.list_box_1.Select(i)
320         else:
321             for i in range(len(self.LABELLIST)):
322                 self.list_box_2.Select(i)
323
324 class PrefDialog ( wx.Dialog ):
325     
326     def __init__( self, parent ):
327         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
328         self.parent = parent
329         
330         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
331         
332         bSizer1 = wx.BoxSizer( wx.VERTICAL )
333         
334         fgSizer1 = wx.FlexGridSizer( 0, 3, 0, 0 )
335         fgSizer1.SetFlexibleDirection( wx.BOTH )
336         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
337         
338         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Play a sound at the end of analysis").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
339         self.m_staticText1.Wrap( -1 )
340         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
341         
342         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
343         self.m_staticText2.Wrap( -1 )
344         fgSizer1.Add( self.m_staticText2, 0, wx.ALL, 5 )
345         
346         m_radioBox1Choices = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
347         self.m_radioBox1 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox1Choices, 1, wx.RA_SPECIFY_COLS )
348         self.m_radioBox1.SetSelection( 0 )
349         fgSizer1.Add( self.m_radioBox1, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
350
351         msg = _(u"""Check for new 
352 releases at startup""").decode('utf8')
353         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, msg, wx.DefaultPosition, wx.DefaultSize, 0 )
354         self.m_staticText3.Wrap( -1 )
355         fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
356         
357         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
358         self.m_staticText4.Wrap( -1 )
359         fgSizer1.Add( self.m_staticText4, 0, wx.ALL, 5 )
360         
361         m_radioBox2Choices = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
362         self.m_radioBox2 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox2Choices, 1, wx.RA_SPECIFY_COLS )
363         self.m_radioBox2.SetSelection( 0 )
364         fgSizer1.Add( self.m_radioBox2, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
365
366         msg = _(u"Interface language").decode('utf8')
367         self.m_staticText45 = wx.StaticText( self, wx.ID_ANY, msg, wx.DefaultPosition, wx.DefaultSize, 0 )
368         self.m_staticText45.Wrap( -1 )
369         fgSizer1.Add( self.m_staticText45, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
370         
371         self.m_staticText46 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
372         self.m_staticText46.Wrap( -1 )
373         fgSizer1.Add( self.m_staticText46, 0, wx.ALL, 5 )
374         
375         self.listlangues = [ u"french", u"english", u"spanish", u"portuguese", u"italian" ]
376         self.langues = wx.Choice( self, wx.ID_ANY, (200, -1), choices = self.listlangues)
377         #self.langues.SetSelection( 0 )
378         fgSizer1.Add( self.langues, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
379         
380         msg = _(u"""Check installation 
381 of R packages""").decode('utf8')
382         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, msg, wx.DefaultPosition, wx.DefaultSize, 0 )
383         self.m_staticText5.Wrap( -1 )
384         fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
385         
386         self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
387         self.m_staticText6.Wrap( -1 )
388         fgSizer1.Add( self.m_staticText6, 0, wx.ALL, 5 )
389         
390         self.m_button1 = wx.Button( self, wx.ID_ANY, _(u"Check").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
391         fgSizer1.Add( self.m_button1, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
392         
393         bSizer1.Add( fgSizer1, 1, wx.EXPAND, 5 )
394         if sys.platform == 'win32' :
395             bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
396             
397             msg = _(u"""Maximum 
398 memory for R""").decode('utf8')
399             self.m_staticText7 = wx.StaticText( self, wx.ID_ANY, msg, wx.DefaultPosition, wx.DefaultSize, 0 )
400             self.m_staticText7.Wrap( -1 )
401             bSizer2.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
402             
403             self.m_checkBox1 = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
404             bSizer2.Add( self.m_checkBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
405             
406             self.m_spinCtrl1 = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 32, 16000, 1535 )
407             bSizer2.Add( self.m_spinCtrl1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
408             
409             self.m_staticline7 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
410             bSizer2.Add( self.m_staticline7, 0, wx.EXPAND |wx.ALL, 5 )
411             
412             bSizer1.Add( bSizer2, 0, wx.EXPAND, 5 )
413             self.m_checkBox1.Bind( wx.EVT_CHECKBOX, self.oncheckmem )
414
415         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
416         bSizer4 = wx.BoxSizer( wx.HORIZONTAL )
417         self.text8 = wx.StaticText( self, wx.ID_ANY, _(u"Use svdlibc").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
418         self.text8.Wrap( -1 )
419         fgSizer1.Add( self.text8, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
420         self.check_svdc = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
421         bSizer4.Add( self.check_svdc, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
422         bSizer3.Add( bSizer4, 0, wx.EXPAND, 5 )
423         self.fbb = filebrowse.FileBrowseButton(self, -1, size=(250, -1), fileMode = 2, fileMask = '*')
424         bSizer3.Add( self.fbb, 0, wx.EXPAND, 5 )
425         self.fbb.SetLabel(_(u"Path : ").decode('utf8'))
426         fgSizer1.Add( wx.StaticText(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ),  wx.ID_ANY, wx.ALL, 5)
427         fgSizer1.Add( bSizer3, 0,  wx.ALIGN_RIGHT|wx.ALL, 5 )
428
429         Rpath_text =  wx.StaticText( self, wx.ID_ANY, _(u"R path").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
430         Rpath_text.Wrap( -1 )
431         fgSizer1.Add( Rpath_text, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
432         fgSizer1.Add( wx.StaticText(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ),  wx.ID_ANY, wx.ALL, 5)
433         self.Rpath_value = filebrowse.FileBrowseButton(self, -1, size=(350, -1), fileMode = 2, fileMask = '*')
434         self.Rpath_value.SetLabel(_(u"Path : ").decode('utf8'))
435         fgSizer1.Add( self.Rpath_value, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
436
437         mirror_text =  wx.StaticText( self, wx.ID_ANY, _(u"Default R mirror").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
438         mirror_text.Wrap( -1 )
439         fgSizer1.Add( mirror_text, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
440         fgSizer1.Add( wx.StaticText(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ),  wx.ID_ANY, wx.ALL, 5)
441         self.mirror_value = wx.TextCtrl( self, wx.ID_ANY, u'http://cran.univ-lyon1.fr', wx.DefaultPosition, wx.Size( 300,30 ), 0 ) 
442         fgSizer1.Add( self.mirror_value, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
443
444
445         m_sdbSizer1 = wx.StdDialogButtonSizer()
446         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
447         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
448         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
449         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
450         m_sdbSizer1.Realize()
451         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
452         
453         self.SetSizer( bSizer1 )
454         self.Layout()
455         bSizer1.Fit( self )
456         
457         self.Centre( wx.BOTH )
458         
459         # Connect Events
460         self.m_sdbSizer1OK.Bind( wx.EVT_BUTTON, self.OnValid )
461         self.m_button1.Bind( wx.EVT_BUTTON, parent.OnVerif )
462         self.check_svdc.Bind( wx.EVT_CHECKBOX, self.OnSVDC )
463         self.__set_properties()
464
465     def __set_properties(self):
466         self.SetTitle(_(u"Settings").decode('utf8'))
467         if self.parent.pref.getboolean('iramuteq', 'sound'): val1 = 0
468         else : val1 = 1
469         self.m_radioBox1.SetSelection(val1)
470         if self.parent.pref.getboolean('iramuteq', 'checkupdate') : val2 = 0
471         else : val2 = 1
472         self.m_radioBox2.SetSelection(val2)
473         self.langues.SetSelection(self.listlangues.index(self.parent.pref.get('iramuteq', 'guilanguage')))
474         if sys.platform == 'win32' :
475             if self.parent.pref.getboolean('iramuteq', 'R_mem') :
476                 self.m_checkBox1.SetValue(True)
477                 self.m_spinCtrl1.Enable(True)
478                 self.m_spinCtrl1.SetValue(self.parent.pref.getint('iramuteq', 'R_max_mem'))
479             else :
480                 self.m_checkBox1.SetValue(False)
481                 self.m_spinCtrl1.Enable(False)
482         if self.parent.pref.getboolean('iramuteq', 'libsvdc') : 
483             self.check_svdc.SetValue(True)
484             self.fbb.SetValue(self.parent.pref.get('iramuteq', 'libsvdc_path'))
485         else :
486             self.check_svdc.SetValue(False)
487             self.fbb.SetValue(self.parent.pref.get('iramuteq', 'libsvdc_path'))
488             self.fbb.Enable(False)
489         self.Rpath_value.SetValue(self.parent.PathPath.get('PATHS', 'rpath'))
490         self.mirror_value.SetValue(self.parent.pref.get('iramuteq', 'rmirror'))
491         
492     def oncheckmem(self, evt):
493         if self.m_checkBox1.GetValue() :
494             self.m_spinCtrl1.Enable(True)
495         else :
496             self.m_spinCtrl1.Enable(False)
497
498     def OnSVDC(self, evt):
499         if self.check_svdc.GetValue() :
500             self.fbb.Enable(True)
501         else :
502             self.fbb.Enable(False)
503
504     def OnValid(self, event):
505         parent = self.parent
506         if self.m_radioBox1.GetSelection() == 0 : valsound = 'true'
507         else :  valsound = 'false'
508         parent.pref.set('iramuteq', 'sound', valsound)
509         if self.m_radioBox2.GetSelection() == 0 : valcheck = 'true'
510         else :  valcheck = 'false'
511         parent.pref.set('iramuteq', 'checkupdate', valcheck)
512         parent.pref.set('iramuteq', 'guilanguage', self.listlangues[self.langues.GetSelection()])
513         if sys.platform == 'win32' :
514             if self.m_checkBox1.GetValue() :
515                 parent.pref.set('iramuteq', 'R_mem', 'true')
516                 parent.pref.set('iramuteq', 'R_max_mem', str(self.m_spinCtrl1.GetValue()))
517             else :
518                 parent.pref.set('iramuteq', 'R_mem', 'false')
519         if self.check_svdc.GetValue() :
520             parent.pref.set('iramuteq', 'libsvdc', 'true')
521         else :
522             parent.pref.set('iramuteq', 'libsvdc', 'false')
523         parent.pref.set('iramuteq', 'libsvdc_path', self.fbb.GetValue())
524         self.parent.pref.set('iramuteq', 'rmirror', self.mirror_value.GetValue())
525         file = open(parent.ConfigPath['preferences'], 'w')
526         parent.pref.write(file)
527         file.close()
528         self.parent.PathPath.set('PATHS', 'rpath', self.Rpath_value.GetValue())
529         with open(self.parent.ConfigPath['path'], 'w') as f:
530             self.parent.PathPath.write(f)
531         self.Close()
532
533 class PrefGraph(wx.Dialog):
534     def __init__(self, parent, ID, paramgraph, title = '', size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE):
535         pre = wx.PreDialog()
536         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
537         pre.Create(parent, ID, title, pos, size, style)
538         self.PostCreate(pre)
539         self.parent = parent
540         self.paramgraph=paramgraph
541         self.labeltype = wx.StaticText(self, -1, _(u"Graphic type").decode('utf8'))
542         if self.paramgraph['clnb'] <= 3 :
543             choix = [u'2D', 'web 2D']
544         else :
545             choix=[u'2D' ,u'3D', 'web 2D', 'web 3D']
546         self.choicetype = wx.Choice(self, -1, (100,50), choices=choix)
547         self.label_format = wx.StaticText(self, -1, _(u"Picture format").decode('utf8'))
548         self.choix_format =  wx.Choice(self, -1, (100,50), choices = ['png', 'svg'])        
549         self.label_1 = wx.StaticText(self, -1, _(u"width").decode('utf8'))
550         self.spin1 = wx.SpinCtrl(self, -1, '',size = (100,30), min=100, max=5000)
551         self.label_2 = wx.StaticText(self, -1, _(u"height").decode('utf8'))
552         self.spin2 = wx.SpinCtrl(self, -1, '', size = (100,30), min=100, max=5000)
553         self.label_what = wx.StaticText(self, -1, _(u"Representation").decode('utf8'))
554         self.choice1 = wx.Choice(self, -1, (100,50), choices=[_(u"coordinates").decode('utf8'),_(u"correlations").decode('utf8')])
555         self.label_qui = wx.StaticText(self, -1, u'Variables')
556         self.choice2 = wx.Choice(self, -1, (100,50), choices=[_(u"actives").decode('utf8') ,_(u"supplementaries").decode('utf8'), _(u"stars").decode('utf8'), _(u"clusters").decode('utf8')])
557         self.label_3 = wx.StaticText(self, -1, _(u"Text size").decode('utf8'))
558         self.spin3 = wx.SpinCtrl(self, -1, '', size = (100,30), min=1, max=20)
559         txt = _(u"Take the x first points").decode('utf8')
560         self.label_4 = wx.StaticText(self, -1, txt)
561         self.check1 = wx.CheckBox(self, -1)
562         self.spin_nb = wx.SpinCtrl(self, -1, '', size = (100,30), min=2, max=1000)
563         txt = _(u"Take the x first points by cluster").decode('utf8')
564         self.label_chic = wx.StaticText(self, -1, txt)
565         self.check_chic = wx.CheckBox(self, -1)
566         self.spin_nbchic = wx.SpinCtrl(self, -1, '', size = (100,30), min=2, max=1000)        
567         txt = _(u"Limit points by cluster chi2").decode('utf8')
568         self.label_5 = wx.StaticText(self, -1, txt)
569         self.check2 = wx.CheckBox(self, -1)
570         self.spin_chi = wx.SpinCtrl(self, -1, '',size = (100,30),  min=2, max=1000)
571         self.label_6 = wx.StaticText(self, -1, _(u"Avoid overlay").decode('utf8'))
572         self.check3 = wx.CheckBox(self, -1)
573         txt = _(u"Text size proportional to frequency").decode('utf8')
574         self.label_7 = wx.StaticText(self, -1, txt)
575         self.check4 = wx.CheckBox(self, -1)
576         self.label_min = wx.StaticText(self, -1, 'min')
577         self.spin_min = wx.SpinCtrl(self, -1, '',size = (100,30), min = 1, max = 100)
578         self.label_max = wx.StaticText(self, -1, 'max')
579         self.spin_max = wx.SpinCtrl(self, -1, '',size = (100,30), min = 1, max = 100)
580         txt = _(u"Text size proportional to chi2").decode('utf8')
581         self.label_tchi = wx.StaticText(self, -1, txt)
582         self.check_tchi = wx.CheckBox(self, -1)
583         self.label_min_tchi = wx.StaticText(self, -1, 'min')
584         self.spin_min_tchi = wx.SpinCtrl(self, -1, '', size = (100,30), min = 1, max = 100)
585         self.label_max_tchi = wx.StaticText(self, -1, 'max')
586         self.spin_max_tchi = wx.SpinCtrl(self, -1, '', size = (100,30), min = 1, max = 100)
587         self.label_8 = wx.StaticText(self, -1, _(u"Factor x : ").decode('utf8'))
588         self.spin_f1 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=self.paramgraph['clnb']-1)
589         self.label_9 = wx.StaticText(self, -1, _(u"Factor y : ").decode('utf8'))
590         self.spin_f2 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=self.paramgraph['clnb']-1)
591         self.label_f3 = wx.StaticText(self, -1, _(u"Factor z : ").decode('utf8'))
592         self.spin_f3 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=self.paramgraph['clnb']-1)
593         self.label_sphere = wx.StaticText(self, -1, _(u"Sphere transparency").decode('utf8'))
594         self.slider_sphere = wx.Slider(self, -1, 10, 1, 100, size = (255,-1), style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
595
596         self.label_film = wx.StaticText(self, -1, _(u"Make a movie").decode('utf8'))
597         self.film = wx.CheckBox(self, -1)
598                
599         self.btnsizer = wx.StdDialogButtonSizer()
600         if wx.Platform != "__WXMSW__":
601             btn = wx.ContextHelpButton(self)
602             self.btnsizer.AddButton(btn)
603         btn = wx.Button(self, wx.ID_OK)
604         btn.SetDefault()
605         self.btnsizer.AddButton(btn)
606         btn = wx.Button(self, wx.ID_CANCEL)
607         self.btnsizer.AddButton(btn)
608         self.btnsizer.Realize()
609         
610         self.Bind(wx.EVT_CHECKBOX, self.OnCheck1, self.check1)
611         self.Bind(wx.EVT_CHECKBOX, self.OnCheck2, self.check2)
612         self.Bind(wx.EVT_CHECKBOX, self.OnNorm, self.check4)
613         self.Bind(wx.EVT_CHECKBOX, self.OnCheckTchi, self.check_tchi)
614         self.Bind(wx.EVT_CHOICE, self.On3D, self.choicetype)
615         self.Bind(wx.EVT_CHOICE, self.OnPass, self.choice2)
616         self.Bind(wx.EVT_CHECKBOX, self.OnCheckChic, self.check_chic)
617         self.__set_properties()
618         self.OnNorm(wx.EVT_CHECKBOX)
619         self.OnCheckTchi(wx.EVT_CHECKBOX)
620         self.__do_layout()
621
622     def __set_properties(self):
623         self.choicetype.SetSelection(self.paramgraph['typegraph'])
624         if self.paramgraph['typegraph'] == 0  or self.paramgraph['typegraph'] == 2:
625             self.film.Enable(False)
626             self.spin_f3.Enable(False)
627             self.slider_sphere.Enable(False)
628         self.choix_format.SetSelection(self.paramgraph['svg'])
629         self.choice1.SetSelection(self.paramgraph['what'])
630         self.choice2.SetSelection(self.paramgraph['qui'])
631         self.spin_chi.SetValue(self.paramgraph['select_nb'])
632         self.spin_nb.SetValue(self.paramgraph['select_chi'])
633         self.spin1.SetValue(self.paramgraph['width'])
634         self.spin2.SetValue(self.paramgraph['height'])
635         self.spin3.SetValue(self.paramgraph['taillecar'])
636         self.spin_nb.SetValue(self.paramgraph['select_nb'])
637         self.spin_chi.SetValue(self.paramgraph['select_chi'])
638         self.spin_nbchic.SetValue(self.paramgraph['nbchic'])
639         self.check1.SetValue(self.paramgraph['do_select_nb'])
640         self.check2.SetValue(self.paramgraph['do_select_chi'])
641         self.check_chic.SetValue(self.paramgraph['do_select_chi_classe'])
642         self.check3.SetValue(self.paramgraph['over'])
643         if self.paramgraph['do_select_nb'] :
644             self.spin_nb.Enable(True)
645             self.spin_chi.Enable(False)
646             self.spin_nbchic.Enable(False)
647         elif self.paramgraph['do_select_chi_classe'] :
648             self.spin_nb.Enable(False)
649             self.spin_chi.Enable(False)
650             self.spin_nbchic.Enable(True)
651         elif self.paramgraph['do_select_chi'] :
652             self.spin_nb.Enable(False)
653             self.spin_chi.Enable(True)
654             self.spin_nbchic.Enable(False)
655         else :
656             self.spin_nb.Enable(False)
657             self.spin_chi.Enable(False)
658             self.spin_nbchic.Enable(False)
659
660             
661         self.check4.SetValue(self.paramgraph['cex_txt'])
662         self.spin_min.SetValue(self.paramgraph['txt_min'])
663         self.spin_max.SetValue(self.paramgraph['txt_max'])
664         self.check_tchi.SetValue(self.paramgraph['tchi'])
665         self.spin_min_tchi.SetValue(self.paramgraph['tchi_min'])
666         self.spin_max_tchi.SetValue(self.paramgraph['tchi_max'])
667
668         self.spin_f1.SetValue(self.paramgraph['facteur'][0])
669         self.spin_f2.SetValue(self.paramgraph['facteur'][1])
670         self.spin_f3.SetValue(self.paramgraph['facteur'][2])
671         self.slider_sphere.SetValue(self.paramgraph['alpha'])
672
673     def __do_layout(self):
674         sizer_2 = wx.BoxSizer(wx.VERTICAL)
675         fsizer = wx.FlexGridSizer(0,2,0,5)
676         grid_min = wx.FlexGridSizer(0, 2, 0, 0)
677         grid_max = wx.FlexGridSizer(0, 2, 0, 0)
678         grid_minmax = wx.FlexGridSizer(0, 2, 0, 0)
679         grid_min_tchi = wx.FlexGridSizer(0, 2, 0, 0)
680         grid_max_tchi = wx.FlexGridSizer(0, 2, 0, 0)
681         grid_minmax_tchi = wx.FlexGridSizer(0, 2, 0, 0)
682
683         sizer_3 = wx.BoxSizer(wx.VERTICAL)
684         
685         fsizer.Add(self.labeltype, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
686         fsizer.Add(self.choicetype, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
687         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
688         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
689
690         fsizer.Add(self.label_format, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
691         fsizer.Add(self.choix_format, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
692         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
693         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
694
695         fsizer.Add(self.label_what, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
696         fsizer.Add(self.choice1, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
697         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
698         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
699         
700         fsizer.Add(self.label_qui, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
701         fsizer.Add(self.choice2, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
702         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
703         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)              
704         
705         sizer_h1 = wx.BoxSizer(wx.HORIZONTAL)
706         sizer_h1.Add(self.label_1, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
707         sizer_h1.Add(self.spin1, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
708         fsizer.Add(sizer_h1, 0, wx.ALL, 5)
709         sizer_h2 = wx.BoxSizer(wx.HORIZONTAL)
710         sizer_h2.Add(self.label_2, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
711         sizer_h2.Add(self.spin2, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
712         fsizer.Add(sizer_h2, 0, wx.ALL, 5)
713         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
714         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
715         
716         fsizer.Add(self.label_3, 0, wx.ALL | wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
717         fsizer.Add(self.spin3, 0, wx.ALL | wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)        
718         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
719         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
720         
721         fsizer.Add(self.label_4, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
722         sizer_nb = wx.BoxSizer(wx.HORIZONTAL)
723         sizer_nb.Add(self.check1, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
724         sizer_nb.Add(self.spin_nb, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
725         fsizer.Add(sizer_nb, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
726         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
727         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
728         
729         fsizer.Add(self.label_chic, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
730         sizer_nbchic = wx.BoxSizer(wx.HORIZONTAL)
731         sizer_nbchic.Add(self.check_chic, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
732         sizer_nbchic.Add(self.spin_nbchic, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
733         fsizer.Add(sizer_nbchic, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
734         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
735         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
736
737         fsizer.Add(self.label_5, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
738         sizer_chi = wx.BoxSizer(wx.HORIZONTAL)
739         sizer_chi.Add(self.check2, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
740         sizer_chi.Add(self.spin_chi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
741         fsizer.Add(sizer_chi, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
742         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
743         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
744         
745         fsizer.Add(self.label_6, 0,  wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL| wx.ADJUST_MINSIZE, 5)
746         fsizer.Add(self.check3, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 5)
747         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
748         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 
749         
750         sizer_2.Add(fsizer, 0, wx.EXPAND, 0)
751         
752         bsizer_1 = wx.FlexGridSizer(0,3,0,0)
753         bsizer_1.Add(self.label_7, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
754         bsizer_1.Add(self.check4, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5)
755         grid_min.Add(self.label_min, 0,wx.ALL |  wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
756         grid_min.Add(self.spin_min, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
757         grid_max.Add(self.label_max, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
758         grid_max.Add(self.spin_max, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
759         grid_minmax.Add(grid_min, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
760         grid_minmax.Add(grid_max, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
761
762         bsizer_1.Add(grid_minmax, 0, wx.ALL, 5)
763
764         bsizer_1.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
765         bsizer_1.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 
766         bsizer_1.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)        
767
768         bsizer_1.Add(self.label_tchi, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
769         bsizer_1.Add(self.check_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5)
770         grid_min_tchi.Add(self.label_min_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
771         grid_min_tchi.Add(self.spin_min_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
772         grid_max_tchi.Add(self.label_max_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
773         grid_max_tchi.Add(self.spin_max_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
774         grid_minmax_tchi.Add(grid_min_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
775         grid_minmax_tchi.Add(grid_max_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
776         
777         bsizer_1.Add(grid_minmax_tchi, 0,  wx.ALL, 5)
778         sizer_2.Add(bsizer_1, 0, wx.EXPAND, 5)
779         
780         sizer_2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 
781         
782         sizer_f = wx.BoxSizer(wx.HORIZONTAL)
783         sizer_f.Add(self.label_8, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
784         sizer_f.Add(self.spin_f1, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
785         
786         sizer_f.Add(self.label_9, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
787         sizer_f.Add(self.spin_f2, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
788
789         sizer_f.Add(self.label_f3, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
790         sizer_f.Add(self.spin_f3, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
791         sizer_2.Add(sizer_f, 0, wx.EXPAND, 5)
792         
793         sizer_2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 5)
794         
795         fsizer2 = wx.FlexGridSizer(0,2,0,0)
796         fsizer2.Add(self.label_sphere, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
797         fsizer2.Add(self.slider_sphere, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
798         fsizer2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
799         fsizer2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
800
801         fsizer2.Add(self.label_film, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
802         fsizer2.Add(self.film, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
803         sizer_2.Add(fsizer2, 0, wx.EXPAND, 5)
804         sizer_2.Add(self.btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5)
805         self.SetSizer(sizer_2)
806         sizer_2.Fit(self)
807         self.Layout()
808         
809     def OnCheck1(self, event):
810         if self.check1.GetValue() :
811             self.check2.SetValue(False)
812             self.check_chic.SetValue(False)
813             self.spin_chi.Enable(False)
814             self.spin_nb.Enable(True)
815             self.spin_nbchic.Enable(False)
816         else : 
817             self.spin_nb.Enable(False)
818             
819     def OnCheck2(self, event):
820         if self.check2.GetValue() :
821             self.check1.SetValue(False)
822             self.check_chic.SetValue(False)
823             self.spin_chi.Enable(True)
824             self.spin_nb.Enable(False)
825             self.spin_nbchic.Enable(False)
826         else :
827             self.spin_chi.Enable(False) 
828
829     def OnCheckChic(self, event) :
830         if self.check_chic.GetValue() :
831             self.check1.SetValue(False)
832             self.check2.SetValue(False)
833             self.spin_chi.Enable(False)
834             self.spin_nb.Enable(False)
835             self.spin_nbchic.Enable(True)
836         else :
837             self.spin_nbchic.Enable(False)
838
839     def OnNorm(self, event):
840         if not self.check4.GetValue() :
841             self.spin_min.Disable()
842             self.spin_max.Disable()
843         else :
844             self.spin_min.Enable(True)
845             self.spin_max.Enable(True)
846             self.check_tchi.SetValue(False)
847             self.OnCheckTchi(wx.EVT_CHECKBOX)
848
849     def OnCheckTchi(self, evt) :
850         if not self.check_tchi.GetValue() :
851             self.spin_min_tchi.Disable()
852             self.spin_max_tchi.Disable()
853         else :
854             self.spin_min_tchi.Enable(True)
855             self.spin_max_tchi.Enable(True)
856             self.check4.SetValue(False)
857             self.OnNorm(wx.EVT_CHECKBOX)
858
859     def On3D(self, event) :
860         if event.GetString() == u'3D' :
861             self.film.Enable(True)
862             self.spin_f3.Enable(True)
863             self.slider_sphere.Enable(True)
864         else :
865             self.film.Enable(False)
866             self.spin_f3.Enable(False)
867             self.slider_sphere.Enable(False)
868     
869     def OnPass(self,evt) :
870         if evt.GetString() == _(u"clusters").decode('utf8') :
871             self.check4.SetValue(False)
872             self.check4.Enable(False)
873             self.OnNorm(wx.EVT_CHECKBOX)
874         else :
875             self.check4.Enable()
876             
877
878 class SelectColDial ( wx.Dialog ):
879     
880     def __init__( self, parent ):
881         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 400,500 ), style = wx.DEFAULT_DIALOG_STYLE )
882         
883         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
884         
885         self.bSizer2 = wx.BoxSizer( wx.VERTICAL )
886         
887         #self.m_checkList2 = wx.CheckListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ['r','t','y'], 0 ) 
888         #bSizer2.Add( self.m_checkList2, 2, wx.ALL|wx.EXPAND, 5 )
889         
890         self.m_sdbSizer2 = wx.StdDialogButtonSizer()
891         self.m_sdbSizer2OK = wx.Button( self, wx.ID_CANCEL)
892         self.butok = wx.Button( self, wx.ID_OK)
893         #m_sdbSizer2.AddButton( self.m_sdbSizer2OK )
894         #self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL )
895         #m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel )
896         #m_sdbSizer2.Realize();
897         #self.bSizer2.Add( m_sdbSizer2, 0, wx.EXPAND, 5 )
898         
899         self.SetSizer( self.bSizer2 )
900         self.Layout()
901         
902         self.Centre( wx.BOTH )
903     
904     def __del__( self ):
905         pass
906
907 class PrefExport(wx.Dialog):
908     def __init__(self, parent, *args, **kwds):
909         kwds['style'] = wx.OK|wx.DEFAULT_DIALOG_STYLE 
910         wx.Dialog.__init__(self, *args, **kwds)
911         self.fileout = ""
912         self.parent = parent
913         sizer = wx.BoxSizer(wx.VERTICAL)
914         box = wx.BoxSizer(wx.HORIZONTAL)
915         box3 = wx.BoxSizer(wx.HORIZONTAL)
916         self.label_lem = wx.StaticText(self, -1, _(u"Lemmatised corpora").decode('utf8'))
917         box3.Add(self.label_lem, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
918         self.radio_lem = wx.RadioBox(self, -1, u"", choices= [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
919         box3.Add(self.radio_lem, 0, wx.ALIGN_RIGHT, 5)
920         sizer.Add(box3, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
921         self.label_txt = wx.StaticText(self, -1, _(u"Export for ...").decode('utf8'))
922         box.Add(self.label_txt, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
923         self.radio_type = wx.RadioBox(self, -1, u"", choices=['IRaMuTeQ/ALCESTE', 'Lexico'], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
924         box.Add(self.radio_type, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
925         sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
926         box2 = wx.BoxSizer(wx.HORIZONTAL)
927         self.txt2 = wx.StaticText(self, -1, _(u"Output file").decode('utf8'))
928         box2.Add(self.txt2, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
929         self.fbb = filebrowse.FileBrowseButton(self, -1, size=(450, -1), fileMode = 2)
930         box2.Add(self.fbb, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
931         self.fbb.SetLabel("")
932         sizer.Add(box2, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
933
934         btnsizer = wx.StdDialogButtonSizer()
935         btn = wx.Button(self, wx.ID_CANCEL)
936         btnsizer.AddButton(btn)
937         btn_ok = wx.Button(self, wx.ID_OK)
938         btn_ok.SetDefault()
939         btnsizer.AddButton(btn_ok)
940         btnsizer.Realize()
941         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT, 5)
942         self.Bind(wx.EVT_BUTTON, self.check_file, btn_ok)
943         self.SetSizer(sizer)
944         sizer.Fit(self)        
945
946     def check_file(self, evt) :
947         if evt.GetId() == wx.ID_OK :
948             if os.path.exists(self.fbb.GetValue()):
949                 dlg = wx.MessageDialog(self, '\n'.join([u"%s" % self.fbb.GetValue(), _(u"This file already exists. Continue anyway ?").decode('utf8')]), _(u"Attention").decode('utf8'), wx.NO | wx.YES | wx.ICON_WARNING)
950                 dlg.CenterOnParent()
951                 if dlg.ShowModal() not in [wx.ID_NO, wx.ID_CANCEL]:
952                     self.EndModal(wx.ID_OK)
953             else :
954                 self.EndModal(wx.ID_OK)
955         else :
956             self.EndModal(wx.ID_CANCEL)
957
958 class PrefProfTypes(wx.Dialog):
959     def __init__(self, parent, *args, **kwds):
960         kwds['style'] = wx.OK|wx.DEFAULT_DIALOG_STYLE 
961         wx.Dialog.__init__(self, parent, *args, **kwds)
962         self.fileout = ""
963         self.parent = parent
964         sizer = wx.BoxSizer(wx.VERTICAL)
965         box = wx.BoxSizer(wx.HORIZONTAL)
966         box3 = wx.BoxSizer(wx.HORIZONTAL)
967         self.label_txt = wx.StaticText(self, -1, _(u"Settings").decode('utf8'))
968         box.Add(self.label_txt, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
969         self.radio_type = wx.RadioBox(self, -1, u"", choices=[_(u"Like ALCESTE").decode('utf8'), _(u"Like Lexico").decode('utf8')], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
970         box.Add(self.radio_type, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
971         sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
972         box2 = wx.BoxSizer(wx.HORIZONTAL)
973         self.txt2 = wx.StaticText(self, -1, _(u"Output file").decode('utf8'))
974         box2.Add(self.txt2, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
975         self.fbb = filebrowse.FileBrowseButton(self, -1, size=(450, -1), fileMode = 2)
976         box2.Add(self.fbb, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
977         self.fbb.SetLabel("")
978         sizer.Add(box2, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
979
980         btnsizer = wx.StdDialogButtonSizer()
981         btn = wx.Button(self, wx.ID_CANCEL)
982         btnsizer.AddButton(btn)
983         btn_ok = wx.Button(self, wx.ID_OK)
984         btn_ok.SetDefault()
985         btnsizer.AddButton(btn_ok)
986         btnsizer.Realize()
987         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT, 5)
988         #self.Bind(wx.EVT_BUTTON, self.check_file, btn_ok)
989         self.SetSizer(sizer)
990         sizer.Fit(self)
991
992 class PrefSimpleFile(wx.Dialog):
993     def __init__(self, parent, *args, **kwds):
994         kwds['style'] = wx.OK|wx.DEFAULT_DIALOG_STYLE 
995         if 'mask' in kwds :
996             self.mask = kwds['mask']
997             del(kwds['mask'])
998         else : self.mask = '*.*'
999         wx.Dialog.__init__(self, *args, **kwds)
1000         self.fileout = ""
1001         self.parent = parent
1002         sizer = wx.BoxSizer(wx.VERTICAL)
1003         box2 = wx.BoxSizer(wx.HORIZONTAL)
1004         self.txt2 = wx.StaticText(self, -1, _(u"Output file").decode('utf8'))
1005         box2.Add(self.txt2, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
1006         self.fbb = filebrowse.FileBrowseButton(self, -1, size=(450, -1), fileMode = 2, fileMask = self.mask)
1007         box2.Add(self.fbb, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
1008         self.fbb.SetLabel("")
1009         sizer.Add(box2, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
1010
1011         btnsizer = wx.StdDialogButtonSizer()
1012         btn = wx.Button(self, wx.ID_CANCEL)
1013         btnsizer.AddButton(btn)
1014         btn_ok = wx.Button(self, wx.ID_OK)
1015         btn_ok.SetDefault()
1016         btnsizer.AddButton(btn_ok)
1017         btnsizer.Realize()
1018         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT, 5)
1019         self.Bind(wx.EVT_BUTTON, self.check_file, btn_ok)
1020         self.SetSizer(sizer)
1021         sizer.Fit(self)        
1022
1023     def check_file(self, evt) :
1024         if evt.GetId() == wx.ID_OK :
1025             if os.path.exists(self.fbb.GetValue()):
1026                 dlg = wx.MessageDialog(self, '\n'.join([u"%s" % self.fbb.GetValue(), _(u"This file already exists. Continue anyway ?").decode('utf8')]), _(u"Attention").decode('utf8'), wx.NO | wx.YES | wx.ICON_WARNING)
1027                 dlg.CenterOnParent()
1028                 if dlg.ShowModal() not in [wx.ID_NO, wx.ID_CANCEL]:
1029                     self.EndModal(wx.ID_OK)
1030             else :
1031                 self.EndModal(wx.ID_OK)
1032         else :
1033             self.EndModal(wx.ID_CANCEL)
1034
1035
1036 class StatDialog(wx.Dialog):
1037     def __init__(self, parent, *args, **kwds):
1038         kwds['style'] = wx.DEFAULT_DIALOG_STYLE 
1039         wx.Dialog.__init__(self, *args, **kwds)
1040         self.fileout = ""
1041         self.parent = parent
1042         self.label_lem = wx.StaticText(self, -1, _(u"Lemmatization").decode('utf8'))
1043         self.radio_lem = wx.RadioBox(self, -1, u"", choices=['oui', 'non'], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
1044         #txt = u"""Fréquence minimum d'une forme
1045 #analysée (0 = non utilisé)"""
1046         #self.label_8 = wx.StaticText(self, -1, txt)
1047         #self.spin_ctrl_5 = wx.SpinCtrl(self, -1, "",size = (100,30), min=0, max=1000, initial=0)
1048         #self.label_max_actives =  wx.StaticText(self, -1, u"Nombre maximum de formes analysées")
1049         #self.spin_max_actives = wx.SpinCtrl(self, -1, "",size = (100,30), min=20, max=10000, initial=1500)
1050         self.label_4 = wx.StaticText(self, -1, _(u"Keys settings").decode('utf8'))
1051         self.button_5 = wx.Button(self, wx.ID_PREFERENCES, "")
1052
1053         #self.Bind(wx.EVT_CHECKBOX, self.OnCheckUce, self.check_uce)
1054         #self.Bind(wx.EVT_SPINCTRL, self.OnSpin, self.spin_ctrl_5)
1055         self.Bind(wx.EVT_BUTTON, self.OnKeys, self.button_5)
1056         self.__do_layout()
1057         self.__set_properties()
1058
1059     def __do_layout(self) :
1060         first = wx.BoxSizer(wx.VERTICAL)
1061         sizer = wx.FlexGridSizer(0,2,0,0)
1062         sizer.Add(self.label_lem, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1063         sizer.Add(self.radio_lem, 0, wx.ALIGN_LEFT, 5)
1064         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1065         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1066         #sizer.Add(self.txt_exp, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1067         #sizer.Add(self.exp, 0, wx.ALIGN_RIGHT, 5)
1068         #sizer.Add(self.label_uce, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1069         #sizer.Add(self.check_uce, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1070         #sizer.Add(self.label_occuce, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1071         #sizer.Add(self.spin_ctrl_4, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1072         #sizer.Add(self.label_8, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1073         #sizer.Add(self.spin_ctrl_5, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1074         #sizer.Add(self.label_max_actives, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1075         #sizer.Add(self.spin_max_actives, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1076         sizer.Add(self.label_4, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1077         sizer.Add(self.button_5, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1078         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1079         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1080         #sizer.Add(box2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, 5)
1081         first.Add(sizer, 0, wx.ALL, 5)
1082         btnsizer = wx.StdDialogButtonSizer()
1083         btn = wx.Button(self, wx.ID_CANCEL)
1084         btnsizer.AddButton(btn)
1085         btn_ok = wx.Button(self, wx.ID_OK)
1086         btn_ok.SetDefault()
1087         btnsizer.AddButton(btn_ok)
1088         btnsizer.Realize()
1089         first.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, 5)
1090         self.SetSizer(first)
1091         first.Fit(self)
1092
1093     def __set_properties(self) :
1094         self.SetTitle(_(u"Settings").decode('utf8'))
1095
1096     def OnKeys(self, evt):
1097         dial = AlcOptFrame(self, self.parent.parent)
1098         dial.CenterOnParent()
1099         dial.ShowModal()
1100         for i in range(0,len(dial.listlabel)):
1101             dial.keys[dial.listcle[i]] = dial.listspin[i].GetValue()
1102         DoConf().makeoptions(['KEY'], [dial.keys], outfile = self.parent.parent.ConfigPath['key'])
1103         dial.Destroy()
1104
1105 class PrefUCECarac(wx.Dialog):
1106     def __init__(self, parent, *args, **kwds):
1107         kwds['style'] = wx.DEFAULT_DIALOG_STYLE 
1108         kwds['title'] = _(u"Characteristic text segments").decode('utf8')
1109         wx.Dialog.__init__(self, *args, **kwds)
1110         self.parent = parent
1111         first = wx.BoxSizer(wx.VERTICAL)
1112         sizer = wx.FlexGridSizer(0,2,0,0)
1113         self.label_type = wx.StaticText(self, -1, _(u"Ranking score").decode('utf8'))
1114         sizer.Add(self.label_type, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1115         self.radio_type = wx.RadioBox(self, -1, u"", choices=[_(u"absolute (sum of chi2 of marked forms in segment)").decode('utf8'), _(u"relative (mean of chi2 of marked forms in segment)").decode('utf8')], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
1116         sizer.Add(self.radio_type, 0, wx.ALIGN_RIGHT, 5)
1117         self.txt_eff = wx.StaticText(self, -1, _(u"Maximum number of text segments").decode('utf8'))
1118         sizer.Add(self.txt_eff, 0, wx.ALIGN_CENTRE, 5)
1119         self.spin_eff = wx.SpinCtrl(self, -1, '', size = (100, 30), min = 1, max = 100000, initial = 50)
1120         self.spin_eff.SetValue(50)
1121         sizer.Add(self.spin_eff, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
1122         first.Add(sizer, 0, wx.ALL, 5)
1123         btnsizer = wx.StdDialogButtonSizer()
1124         btn = wx.Button(self, wx.ID_CANCEL)
1125         btnsizer.AddButton(btn)
1126         btn_ok = wx.Button(self, wx.ID_OK)
1127         btn_ok.SetDefault()
1128         btnsizer.AddButton(btn_ok)
1129         btnsizer.Realize()
1130         first.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, 5)
1131         self.SetSizer(first)
1132         first.Fit(self)
1133
1134 class PrefSegProf(wx.Dialog) :
1135     def __init__( self, parent ):
1136         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Repeated segments profiles").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
1137         
1138         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1139         bSizer1 = wx.BoxSizer( wx.VERTICAL )
1140         txt = _(u"Be carefull : computation of repeated segments profiles can be very long on large corpora").decode('utf8')
1141         self.label = wx.StaticText( self, wx.ID_ANY, txt, wx.DefaultPosition, wx.DefaultSize, 0 ) 
1142         bSizer1.Add( self.label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5 )
1143
1144         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
1145         fgSizer1.SetFlexibleDirection( wx.BOTH )
1146         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1147         
1148         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Lemmatised corpora").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1149         self.m_staticText1.Wrap( -1 )
1150         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1151         
1152         box_lemChoices = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
1153         self.box_lem = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, box_lemChoices, 1, wx.RA_SPECIFY_COLS )
1154         self.box_lem.SetSelection( 1 )
1155         fgSizer1.Add( self.box_lem, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1156         #self.box_lem.Enable(False)
1157         
1158         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Minimum size of segments").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1159         self.m_staticText3.Wrap( -1 )
1160         fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1161         
1162         self.spin_min = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (100,30), wx.SP_ARROW_KEYS, 2, 30, 2 )
1163         self.spin_min.SetValue(2)
1164         fgSizer1.Add( self.spin_min, 0, wx.ALL, 5 )
1165         
1166         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Minimum size of segments").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1167         self.m_staticText4.Wrap( -1 )
1168         fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1169         
1170         self.spin_max = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (100,30), wx.SP_ARROW_KEYS, 2, 30, 10 )
1171         self.spin_max.SetValue(10)
1172         fgSizer1.Add( self.spin_max, 0, wx.ALL, 5 )
1173         
1174         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Minimum frequency of segments").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1175         self.m_staticText5.Wrap( -1 )
1176         fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1177         
1178         self.spin_eff = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (100,30), wx.SP_ARROW_KEYS, 4, 1000, 4 )
1179         self.spin_eff.SetValue(4)
1180         fgSizer1.Add( self.spin_eff, 0, wx.ALL, 5 )
1181         
1182         bSizer1.Add( fgSizer1, 1, wx.EXPAND, 5 )
1183         btnsizer = wx.StdDialogButtonSizer()
1184         btn = wx.Button(self, wx.ID_CANCEL)
1185         btnsizer.AddButton(btn)
1186         btn_ok = wx.Button(self, wx.ID_OK)
1187         btn_ok.SetDefault()
1188         btnsizer.AddButton(btn_ok)
1189         btnsizer.Realize()
1190         bSizer1.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, 5)
1191
1192         self.SetSizer( bSizer1 )
1193         self.Layout()
1194         bSizer1.Fit( self )
1195         
1196         self.Centre( wx.BOTH )
1197
1198 class PrefQuestAlc ( wx.Dialog ):
1199     
1200     def __init__( self, parent, sim = False):
1201         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Clustering").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
1202         
1203         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1204         
1205         #---------------------------------------------------------------
1206         #self.content = parent.content[:]
1207         self.header = parent.tableau.get_colnames()
1208         labels = [val for val in self.header]
1209         self.labels_tot = labels
1210         self.varsup = []
1211         self.sim = sim
1212         #---------------------------------------------------------------
1213         bSizer2 = wx.BoxSizer( wx.VERTICAL )
1214         
1215         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
1216         fgSizer1.SetFlexibleDirection( wx.BOTH )
1217         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1218
1219         if not self.sim :
1220             self.lab_format = wx.StaticText( self, wx.ID_ANY, _(u"Supplementary variables are marked with a *").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1221             self.lab_format.Wrap( -1 )
1222             fgSizer1.Add( self.lab_format, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1223         
1224             m_radioBox1Choices = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
1225             self.m_radioBox1 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox1Choices, 1, wx.RA_SPECIFY_COLS )
1226             self.m_radioBox1.SetSelection( 0 )
1227             fgSizer1.Add( self.m_radioBox1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1228         
1229         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Actives variables (almost 3)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1230         self.m_staticText3.Wrap( -1 )
1231         fgSizer1.Add( self.m_staticText3, 0, wx.ALL, 5 )
1232         
1233         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Supplementaries variables (almost 1)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1234         self.m_staticText2.Wrap( -1 )
1235         fgSizer1.Add( self.m_staticText2, 0, wx.ALL, 5 )
1236         
1237         self.ListActive = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, labels,  wx.LB_EXTENDED )
1238         self.ListActive.SetMinSize( wx.Size( 300,250 ) )
1239         
1240         fgSizer1.Add( self.ListActive, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
1241         
1242         self.ListSup = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, labels, wx.LB_EXTENDED )
1243         self.ListSup.SetMinSize( wx.Size( 300,250 ) )
1244         
1245         fgSizer1.Add( self.ListSup, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
1246         
1247         self.but_suiv = wx.Button( self, wx.ID_ANY, _(u"Next").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1248         fgSizer1.Add( self.but_suiv, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1249         
1250         self.but_prec = wx.Button( self, wx.ID_ANY, _(u"Previous").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1251         fgSizer1.Add( self.but_prec, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1252         
1253         if not sim :
1254             self.lab_nbcl = wx.StaticText( self, wx.ID_ANY, _(u"Number of terminal clusters in phase 1").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1255             self.lab_nbcl.Wrap( -1 )
1256             fgSizer1.Add( self.lab_nbcl, 0, wx.ALL, 5 )
1257             
1258             self.spin_nbcl = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 2, 100, 10 )
1259             self.spin_nbcl.SetValue(10)
1260             self.spin_nbcl.SetMinSize( wx.Size( 100,30 ) )
1261             
1262             fgSizer1.Add( self.spin_nbcl, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1263             
1264             self.lab_mincl = wx.StaticText( self, wx.ID_ANY, _(u"Minimum text segments frenquency in clusters (2= automatic)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1265             self.lab_mincl.Wrap( -1 )
1266             fgSizer1.Add( self.lab_mincl, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1267             
1268             self.spin_mincl = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 2, 1000, 0 )
1269             self.spin_mincl.SetValue(2)
1270             self.spin_mincl.SetMinSize( wx.Size( 100,30 ) )
1271             
1272             fgSizer1.Add( self.spin_mincl, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1273             
1274         bSizer2.Add( fgSizer1, 1, wx.EXPAND, 5 )
1275         
1276         m_sdbSizer2 = wx.StdDialogButtonSizer()
1277         self.m_sdbSizer2OK = wx.Button( self, wx.ID_OK )
1278         m_sdbSizer2.AddButton( self.m_sdbSizer2OK )
1279         self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL )
1280         m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel )
1281         m_sdbSizer2.Realize();
1282         bSizer2.Add( m_sdbSizer2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1283         
1284         self.SetSizer( bSizer2 )
1285         self.Layout()
1286         bSizer2.Fit( self )
1287         
1288         self.Centre( wx.BOTH )
1289         
1290         if not self.sim :
1291             self.ListActive.Enable(False)
1292             self.ListSup.Enable(False)
1293             self.but_suiv.Enable(False)
1294             self.but_prec.Enable(False)
1295         else :
1296             self.ListSup.Enable(False)
1297             self.but_prec.Enable(False)
1298         
1299         # Connect Events
1300         if not self.sim :
1301             self.m_radioBox1.Bind( wx.EVT_RADIOBOX, self.onformat )
1302         self.but_suiv.Bind(wx.EVT_BUTTON, self.onsuivant)
1303         self.but_prec.Bind(wx.EVT_BUTTON, self.onprec)
1304         self.m_sdbSizer2OK.Bind(wx.EVT_BUTTON, self.onvalid)
1305
1306     def __del__( self ):
1307         pass
1308     
1309     # Virtual event handlers, overide them in your derived class
1310     def onformat( self, event ):
1311         if self.m_radioBox1.GetSelection() == 0 :
1312             self.ListActive.Enable(False)
1313             self.ListSup.Enable(False)
1314             self.but_suiv.Enable(False)
1315             self.m_sdbSizer2OK.Enable(True)
1316         else :
1317             self.ListActive.Enable(True)
1318             self.but_suiv.Enable(True)
1319             self.m_sdbSizer2OK.Enable(False)
1320         
1321     def onsuivant(self, evt) :
1322         actives = list(self.ListActive.GetSelections())
1323         actives.sort()
1324         if len(actives)>=3 and len(actives) != len(self.header) :
1325             self.hindices = []
1326             self.nactives = []
1327             compt = 0
1328             header = self.header[:]
1329             for i in range(0, len(header)):
1330                 self.hindices.append(i)
1331             for i in actives :
1332                 self.nactives.append(i)
1333                 header.pop(i - compt)
1334                 self.hindices.pop(i - compt)
1335                 compt += 1
1336             self.labels = [val for val in header]
1337             self.ListSup.Clear()
1338             for i in header :
1339                 self.ListSup.Append(i)
1340                         
1341             self.ListActive.Enable(False)    
1342             self.ListSup.Enable(True)
1343             self.but_suiv.Enable(False)
1344             self.but_prec.Enable(True)
1345             if not self.sim :
1346                 self.m_sdbSizer2OK.Enable(True)
1347
1348     def onprec(self, evt) :
1349         self.ListActive.Enable(True)    
1350         self.ListSup.Enable(False)
1351         self.but_suiv.Enable(True)
1352         self.but_prec.Enable(False)
1353         if not self.sim :
1354             self.m_sdbSizer2OK.Enable(False)
1355
1356     def onvalid(self, evt) :
1357         for i in self.ListSup.GetSelections() :
1358             self.varsup.append(self.hindices[i])
1359         if not self.sim :
1360             if len(self.varsup) >= 1 or self.m_radioBox1.GetSelection() == 0 :
1361                 evt.Skip()
1362         else :
1363             if len(self.varsup) >= 1 :
1364                 evt.Skip()
1365
1366 class FindInCluster(wx.Frame):
1367     def __init__(self, parent, id, result, style = wx.DEFAULT_FRAME_STYLE):
1368         # begin wxGlade: MyFrame.__init__
1369         wx.Frame.__init__(self, parent, id)
1370         self.spanel =  wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
1371         self.sizer1 = wx.FlexGridSizer(0,4,0,0)
1372         self.parent = parent
1373         self.formes = {}
1374         txt =  [_(u"form").decode('utf8'),_(u"cluster").decode('utf8'),_(u"Chi2").decode('utf8'), _(u"see").decode('utf8')]
1375         for val in txt :
1376             self.sizer1.Add( wx.StaticText(self.spanel, -1, val), 0, wx.ALL, 5)
1377         for val in txt :
1378             self.sizer1.Add(wx.StaticLine(self.spanel, -1), 0, wx.ALL, 5)
1379         for i,val in enumerate(result) :
1380             forme = val[0]
1381             cl = val[1]
1382             chi = val[2]
1383             pan = wx.Panel(self.spanel, -1, style=wx.SIMPLE_BORDER)
1384             siz = wx.BoxSizer(wx.VERTICAL)
1385             txt = wx.StaticText(pan, -1, forme)
1386             siz.Add(txt, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
1387             pan.SetSizer(siz)
1388             self.sizer1.Add(pan, 0, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5)
1389             pan = wx.Panel(self.spanel, -1, style=wx.SIMPLE_BORDER)
1390             siz = wx.BoxSizer(wx.VERTICAL)
1391             txt = wx.StaticText(pan, -1, str(cl))
1392             siz.Add(txt, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
1393             pan.SetSizer(siz)
1394             self.sizer1.Add(pan, 0, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5)
1395             pan = wx.Panel(self.spanel, -1, style=wx.SIMPLE_BORDER)
1396             siz = wx.BoxSizer(wx.VERTICAL)
1397             txt = wx.StaticText(pan, -1, str(chi))
1398             siz.Add(txt, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
1399             pan.SetSizer(siz)
1400             self.sizer1.Add(pan, 0, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5)
1401             idbut = wx.NewId()
1402             self.formes[idbut] = [forme, cl]
1403             but = wx.Button(self.spanel, idbut, u"voir")
1404             self.sizer1.Add(but, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
1405             self.Bind(wx.EVT_BUTTON, self.showitem, but)
1406         self.button_1 = wx.Button(self, -1, "Fermer")
1407         self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
1408         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
1409         self.__set_properties()
1410         self.__do_layout()
1411         # end wxGlade
1412     
1413     def __set_properties(self):
1414         self.SetTitle(_(u"Results").decode('utf8'))
1415         self.spanel.EnableScrolling(True,True)
1416         #self.panel_1.SetSize((1000,1000))
1417         self.spanel.SetScrollRate(20, 20)
1418         h = 60 * len(self.formes)
1419         if h > 600 :
1420             h = 600
1421         if h < 150 :
1422             h = 150
1423         self.SetSize(wx.Size(400,h))
1424
1425     def __do_layout(self):
1426         # begin wxGlade: MyFrame.__do_layout
1427         sizer_1 = wx.BoxSizer(wx.VERTICAL)
1428         sizer_2 = wx.BoxSizer(wx.VERTICAL)
1429         self.spanel.SetSizer(self.sizer1)
1430         sizer_1.Add(self.spanel, 4, wx.EXPAND, 0)
1431         sizer_1.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ADJUST_MINSIZE, 0)
1432         #sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
1433         self.SetAutoLayout(True)
1434         self.SetSizer(sizer_1)
1435         self.Layout()
1436         # end wxGlade
1437
1438     def showitem(self, evt) :
1439         idb = evt.GetEventObject().GetId()
1440         nb = self.parent.nb
1441         profile = nb.GetPage(nb.GetSelection())
1442         cl = self.formes[idb][1] - 1
1443         forme = self.formes[idb][0]
1444         profile.ProfNB.SetSelection(cl)
1445         UnSelectList(profile.ProfNB.GetPage(cl))
1446         datas = dict([[profile.ProfNB.GetPage(cl).getColumnText(i,6),i] for i in range(profile.ProfNB.GetPage(cl).GetItemCount())])
1447         profile.ProfNB.GetPage(cl).SetItemState(datas[self.formes[idb][0]], wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
1448         profile.ProfNB.GetPage(cl).Focus(datas[forme])
1449         profile.ProfNB.GetPage(cl).SetFocus()
1450
1451     def OnCloseMe(self, evt) :
1452         self.Close(True)
1453
1454     def OnCloseWindow(self, evt):
1455         self.Destroy()
1456
1457 class SearchDial ( wx.Frame ):
1458     
1459     def __init__( self, parent, listctrl, col, shown):
1460         wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE )
1461         self.parent = parent
1462         self.listctrl = listctrl
1463         self.col = col
1464         self.shown = shown
1465         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1466         
1467         bSizer1 = wx.BoxSizer( wx.VERTICAL )
1468         
1469         self.search = wx.SearchCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_PROCESS_ENTER )
1470         self.search.ShowSearchButton( True )
1471         self.search.ShowCancelButton( True )
1472         bSizer1.Add( self.search, 0, wx.ALL, 5 )
1473         sizer2 = wx.BoxSizer(wx.HORIZONTAL)
1474         self.backward = wx.Button(self, wx.ID_BACKWARD, _(u"Previous").decode('utf8'))
1475         self.forward = wx.Button(self, wx.ID_FORWARD, _(u"Next").decode('utf8'))
1476         sizer2.Add(self.backward, 0, wx.ALL, 5)
1477         sizer2.Add(self.forward, 0, wx.ALL, 5)
1478         bSizer1.Add( sizer2, 0, wx.ALL, 5 )
1479
1480         self.SetSizer( bSizer1 )
1481         self.Layout()
1482         bSizer1.Fit( self )
1483         self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.OnSearch, self.search)
1484         self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.OnCancel, self.search)
1485         self.Bind(wx.EVT_TEXT_ENTER, self.OnSearch, self.search)
1486         self.Bind(wx.EVT_BUTTON, self.onforward, self.forward)
1487         self.Bind(wx.EVT_BUTTON, self.onbackward, self.backward)
1488         self.search.SetFocus()
1489         self.forward.Enable(False)
1490         self.backward.Enable(False)
1491
1492         self.Centre( wx.BOTH )
1493     
1494     def __del__( self ):
1495         pass
1496
1497     def OnSearch(self, evt):
1498         UnSelectList(self.listctrl)
1499         search_word = self.search.GetValue()
1500         if search_word.strip() != '' :
1501             formes = [self.listctrl.getColumnText(i, self.col) for i in range(self.listctrl.GetItemCount())]
1502             if search_word.endswith(u'*') :
1503                 search_word = search_word[0:-1]
1504                 result = [j for j, forme in enumerate(formes) if forme.startswith(search_word)]
1505             else :
1506                 result = [j for j, forme in enumerate(formes) if forme == search_word]
1507             if result == [] :
1508                 self.noresult()
1509             elif self.shown == True :
1510                 self.showitems(result)
1511             else :
1512                 self.showresult(result)
1513         else :
1514             self.Destroy()
1515
1516     
1517     def showitems(self, items) :
1518         if len(items) == 1 :
1519             self.listctrl.SetItemState(items[0], wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
1520             self.listctrl.Focus(items[0])
1521             self.listctrl.SetFocus()
1522             self.Destroy()
1523         else :
1524             for i in items :
1525                 self.listctrl.SetItemState(i, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
1526             self.listctrl.Focus(items[0])
1527             self.listctrl.SetFocus()
1528             self.forward.Enable(True)
1529             self.backward.Enable(False)
1530             self.items = items
1531             self.forwitem = 1
1532             self.backitem = -1
1533     
1534     def showresult(self, result) :
1535         toshow = [self.listctrl.itemDataMap[int(self.listctrl.getColumnText(i,0))] for i in result]
1536         proflist = [[[line[1], i+1, val] for i, val in enumerate(line[2:]) if val>=2] for line in toshow]
1537         #FIXME: intervenir en aval en virant les forme avec chi<2
1538         if proflist != [[]] :
1539             proflist = [val for line in proflist for val in line if line !=[]]
1540             nb = self.parent.parent.nb
1541             profile = nb.GetPage(nb.GetSelection())
1542             first_forme = proflist[0]
1543             cl = first_forme[1] - 1
1544             profile.ProfNB.SetSelection(cl)
1545             profile.ProfNB.GetPage(cl).SetFocus()
1546             UnSelectList(profile.ProfNB.GetPage(cl))
1547             datas = dict([[profile.ProfNB.GetPage(cl).getColumnText(i,6),i] for i in range(profile.ProfNB.GetPage(cl).GetItemCount())])
1548             profile.ProfNB.GetPage(cl).SetItemState(datas[first_forme[0]], wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
1549             profile.ProfNB.GetPage(cl).Focus(datas[first_forme[0]])
1550             profile.ProfNB.GetPage(cl).SetFocus()
1551             if len(proflist) == 1 :
1552                 self.Destroy()
1553             else :
1554                 SearchResult = FindInCluster(self.parent.parent, -1, proflist)
1555                 SearchResult.Show()
1556                 self.Destroy()
1557         else :
1558             self.noresult()
1559
1560     def onforward(self, evt) :
1561         self.listctrl.Focus(self.items[self.forwitem])
1562         self.listctrl.SetFocus()
1563         self.forwitem += 1
1564         if self.forwitem == len(self.items) :
1565             self.forward.Enable(False)
1566             self.backward.Enable(True)
1567             self.backitem += 1
1568         else :
1569             self.backitem += 1
1570             self.backward.Enable(True)
1571
1572     def onbackward(self, evt) :
1573         self.listctrl.Focus(self.items[self.backitem])
1574         self.listctrl.SetFocus()
1575         self.backitem -= 1
1576         if self.backitem == -1 :
1577             self.forwitem -= 1
1578             self.forward.Enable(True)
1579             self.backward.Enable(False)
1580         else :
1581             self.forwitem -= 1
1582             self.forward.Enable(True)
1583
1584     def noresult(self) :
1585         msg = _(u"Absent form").decode('utf8')
1586         dial = wx.MessageDialog(self, _(u"Absent form").decode('utf8'),_(u"Absent form").decode('utf8'), wx.OK | wx.ICON_INFORMATION)
1587         dial.CenterOnParent()
1588         dial.ShowModal()
1589         dial.Destroy()
1590
1591     def OnCancel(self, evt) :
1592         self.search.Clear()
1593
1594 def UnSelectList(liste) :
1595     if liste.GetFirstSelected() != -1 :
1596         last = liste.GetFirstSelected()
1597         liste.Select(liste.GetFirstSelected(), False)
1598         while liste.GetNextSelected(last) != -1 :
1599             last = liste.GetNextSelected(last)
1600             liste.Select(liste.GetFirstSelected(),False)
1601
1602
1603 class OptLexi(wx.Dialog):
1604     def __init__(self, parent, force_chi = False):
1605         # begin wxGlade: MyDialog.__init__
1606         #kwds["style"] = wx.DEFAULT_DIALOG_STYLE
1607         wx.Dialog.__init__(self, parent, style = wx.DEFAULT_DIALOG_STYLE)
1608         self.listet = None
1609         self.variables = None
1610         self.force_chi = force_chi
1611         #self.labellem =  wx.StaticText(self, -1, u"Lemmatisation : ")
1612         #self.checklem = wx.CheckBox(self, -1)
1613         if not self.force_chi :
1614             self.label_typeformes =  wx.StaticText(self, -1, _(u"Used forms").decode('utf8'))
1615             typeformeschoiceChoices = [ _(u"actives and supplementaries").decode('utf8'), _(u"actives").decode('utf8'), _(u"supplementaries").decode('utf8')]
1616             self.typeformes = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, typeformeschoiceChoices, 0 )
1617             self.typeformes.SetSelection( 0 )
1618
1619         self.label_var =  wx.StaticText(self, -1, _(u"Select by").decode('utf8'))
1620         self.choice = wx.Choice(self, -1, (100,50), choices = [_(u"variables").decode('utf8'), _(u"modalities").decode('utf8')])
1621         self.label1 =  wx.StaticText(self, -1, _(u"Choice").decode('utf8'))
1622         self.list_box_1 = wx.ListBox(self, -1, choices=[],  size = wx.Size( 150,200 ), style=wx.LB_EXTENDED | wx.LB_HSCROLL)
1623         self.button_2 = wx.Button(self, wx.ID_CANCEL, "")
1624         self.button_1 = wx.Button(self, wx.ID_OK, "")
1625         if not self.force_chi :
1626             indices = [_(u"hypergeometrical law").decode('utf8'), _(u"chi2").decode('utf8')]
1627         else :
1628             indices = [_(u"chi2").decode('utf8')]
1629         self.label_indice =  wx.StaticText(self, -1, _(u"Score").decode('utf8'))
1630         self.choice_indice =  wx.Choice(self, -1, (100,50), choices = indices)
1631         if not self.force_chi :
1632             self.label = wx.StaticText(self, -1, _(u"Minimum frequency").decode('utf8'))
1633             self.spin = wx.SpinCtrl(self, -1, min = 1, max = 10000, initial = 10)
1634         self.Bind(wx.EVT_CHOICE, self.onselect, self.choice)
1635         self.__set_properties()
1636         self.__do_layout()
1637         # end wxGlade
1638
1639     def __set_properties(self):
1640         # begin wxGlade: MyDialog.__set_properties
1641         self.SetTitle(_(u"Variables choice").decode('utf8'))
1642         if not self.force_chi :
1643             self.spin.SetValue(10)
1644         self.choice.SetSelection(0)
1645         self.choice_indice.SetSelection(0)
1646         #self.SetMinSize(wx.Size(300, 400))
1647         # end wxGlade
1648
1649     def __do_layout(self):
1650         # begin wxGlade: MyDialog.__do_layout
1651         sizer_1 = wx.BoxSizer(wx.VERTICAL)
1652         sizer_2 = wx.FlexGridSizer(0,2,0,0)
1653         sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
1654         #sizer_2.Add(self.labellem, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1655         #sizer_2.Add(self.checklem, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1656         if not self.force_chi :
1657             sizer_2.Add(self.label_typeformes, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1658             sizer_2.Add(self.typeformes, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1659         sizer_2.Add(self.label_var, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1660         sizer_2.Add(self.choice, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1661         sizer_2.Add(self.label1, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1662         sizer_2.Add(self.list_box_1, 0, wx.ALIGN_RIGHT, 3)
1663         sizer_3.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1664         sizer_3.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1665         sizer_2.Add(self.label_indice, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1666         sizer_2.Add(self.choice_indice, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1667         if not self.force_chi :
1668             sizer_2.Add(self.label, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1669             sizer_2.Add(self.spin, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 3)
1670         sizer_1.Add(sizer_2, 0, wx.ALIGN_CENTER_HORIZONTAL, 3)
1671         sizer_1.Add(sizer_3, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_RIGHT, 3)
1672         self.SetSizer(sizer_1)
1673         sizer_1.Fit(self)
1674         self.Layout()
1675         self.Centre()
1676
1677     def onselect(self, evt):
1678         self.list_box_1.Clear()
1679         if self.choice.GetSelection() == 0 :
1680             for var in self.variables :
1681                 self.list_box_1.Append(var)
1682         else :
1683             for et in self.listet :
1684                 self.list_box_1.Append(et)
1685
1686
1687 class PrefDendro ( wx.Dialog ):
1688     
1689     def __init__( self, parent, param ):
1690         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Dendrogram").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
1691         self.param = param
1692         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1693         
1694         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
1695         fgSizer1.SetFlexibleDirection( wx.BOTH )
1696         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1697         
1698         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Picture size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1699         self.m_staticText1.Wrap( -1 )
1700         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1701         
1702         bSizer2 = wx.BoxSizer( wx.VERTICAL )
1703         
1704         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
1705         
1706         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"height").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1707         self.m_staticText2.Wrap( -1 )
1708         bSizer3.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1709         
1710         self.m_spinCtrl1 = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 50, 10000, 600 )
1711         bSizer3.Add( self.m_spinCtrl1, 0, wx.ALL, 5 )
1712         
1713         bSizer2.Add( bSizer3, 1, wx.EXPAND, 5 )
1714         
1715         bSizer31 = wx.BoxSizer( wx.HORIZONTAL )
1716         
1717         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"width").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1718         self.m_staticText3.Wrap( -1 )
1719         bSizer31.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1720         
1721         self.m_spinCtrl2 = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 50, 10000, 600 )
1722         bSizer31.Add( self.m_spinCtrl2, 0, wx.ALL, 5 )
1723         
1724         bSizer2.Add( bSizer31, 1, wx.EXPAND, 5 )
1725         
1726         fgSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
1727         
1728         self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1729         fgSizer1.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )
1730         
1731         self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1732         fgSizer1.Add( self.m_staticline2, 0, wx.EXPAND |wx.ALL, 5 )
1733         
1734         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Dendrogram type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1735         self.m_staticText4.Wrap( -1 )
1736         fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1737         
1738         m_choice1Choices = [ u"phylogram", u"cladogram", u"fan", u"unrooted", u"radial" ]
1739         self.m_choice1 = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice1Choices, 0 )
1740         self.m_choice1.SetSelection( 0 )
1741         fgSizer1.Add( self.m_choice1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1742         
1743         self.m_staticline3 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1744         fgSizer1.Add( self.m_staticline3, 0, wx.EXPAND |wx.ALL, 5 )
1745         
1746         self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1747         fgSizer1.Add( self.m_staticline4, 0, wx.EXPAND |wx.ALL, 5 )
1748         
1749         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Color or black and white").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1750         self.m_staticText5.Wrap( -1 )
1751         fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1752         
1753         m_radioBox1Choices = [ _(u"color").decode('utf8'), _(u"black and white").decode('utf8') ]
1754         self.m_radioBox1 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox1Choices, 1, wx.RA_SPECIFY_COLS )
1755         self.m_radioBox1.SetSelection( 0 )
1756         fgSizer1.Add( self.m_radioBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1757         
1758         self.m_staticline5 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1759         fgSizer1.Add( self.m_staticline5, 0, wx.EXPAND |wx.ALL, 5 )
1760         
1761         self.m_staticline6 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1762         fgSizer1.Add( self.m_staticline6, 0, wx.EXPAND |wx.ALL, 5 )
1763         
1764         bSizer4 = wx.BoxSizer( wx.HORIZONTAL )
1765         
1766         self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, _(u"Add cluster size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1767         self.m_staticText6.Wrap( -1 )
1768         bSizer4.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1769         
1770         self.m_checkBox1 = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
1771         self.m_checkBox1.SetValue(True) 
1772         bSizer4.Add( self.m_checkBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1773         
1774         fgSizer1.Add( bSizer4, 1, wx.EXPAND, 5 )
1775         
1776         m_radioBox2Choices = [ _(u"circular diagram").decode('utf8'), _(u"bar").decode('utf8') ]
1777         self.m_radioBox2 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox2Choices, 1, wx.RA_SPECIFY_COLS )
1778         self.m_radioBox2.SetSelection( 0 )
1779         fgSizer1.Add( self.m_radioBox2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1780         
1781         self.m_staticline7 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1782         fgSizer1.Add( self.m_staticline7, 0, wx.EXPAND |wx.ALL, 5 )
1783         
1784         self.m_staticline8 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1785         fgSizer1.Add( self.m_staticline8, 0, wx.EXPAND |wx.ALL, 5 )
1786         
1787         
1788         fgSizer1.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
1789         
1790         m_sdbSizer2 = wx.StdDialogButtonSizer()
1791         self.m_sdbSizer2OK = wx.Button( self, wx.ID_OK )
1792         m_sdbSizer2.AddButton( self.m_sdbSizer2OK )
1793         self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL )
1794         m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel )
1795         m_sdbSizer2.Realize();
1796         fgSizer1.Add( m_sdbSizer2, 1, wx.EXPAND, 5 )
1797         
1798         self.__set_properties()
1799         self.SetSizer( fgSizer1 )
1800         self.Layout()
1801         fgSizer1.Fit( self )
1802         
1803         self.Centre( wx.BOTH )
1804
1805     def __set_properties(self):
1806         self.m_spinCtrl2.SetValue(self.param['width'])
1807         self.m_spinCtrl1.SetValue(self.param['height'])
1808         self.m_choice1.SetSelection(self.param['type_dendro'])
1809         self.m_radioBox1.SetSelection(self.param['color_nb'])
1810         self.m_checkBox1.SetValue(self.param['taille_classe'])
1811         self.m_radioBox2.SetSelection(self.param['type_tclasse'])
1812     
1813     def __del__( self ):
1814         pass
1815
1816
1817 class PrefWordCloud ( wx.Dialog ):
1818     
1819     def __init__( self, parent, fromcluster = False ):
1820         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Wordcloud settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
1821         
1822         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1823         
1824         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
1825         fgSizer1.SetFlexibleDirection( wx.BOTH )
1826         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1827         
1828         #self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Sélectionner les formes", wx.DefaultPosition, wx.DefaultSize, 0 )
1829         #self.m_staticText1.Wrap( -1 )
1830         #fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1831         
1832         #self.but_selectcol = wx.Button( self, wx.ID_ANY, u"Sélectionner", wx.DefaultPosition, wx.DefaultSize, 0 )
1833         #fgSizer1.Add( self.but_selectcol, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1834         
1835         #self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1836         #fgSizer1.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )
1837         
1838         #self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1839         #fgSizer1.Add( self.m_staticline2, 0, wx.EXPAND |wx.ALL, 5 )
1840         
1841         bSizer1 = wx.BoxSizer( wx.HORIZONTAL )
1842         
1843         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"height").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1844         self.m_staticText3.Wrap( -1 )
1845         bSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1846         
1847         self.spin_H = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 100,30 ), wx.SP_ARROW_KEYS, 0, 10000, 600 )
1848         self.spin_H.SetValue( 800 )
1849         bSizer1.Add( self.spin_H, 0, wx.ALL, 5 )
1850         
1851         fgSizer1.Add( bSizer1, 1, wx.EXPAND, 5 )
1852         
1853         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
1854         
1855         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"width").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1856         self.m_staticText4.Wrap( -1 )
1857         bSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1858         
1859         self.spin_L = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 100,30 ), wx.SP_ARROW_KEYS, 0, 10000, 600 )
1860         self.spin_L.SetValue( 800 )
1861         bSizer3.Add( self.spin_L, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1862         
1863         fgSizer1.Add( bSizer3, 1, wx.EXPAND, 5 )
1864         
1865         self.m_staticline3 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1866         fgSizer1.Add( self.m_staticline3, 0, wx.EXPAND |wx.ALL, 5 )
1867         
1868         self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1869         fgSizer1.Add( self.m_staticline4, 0, wx.EXPAND |wx.ALL, 5 )
1870         
1871         self.m_staticText11 = wx.StaticText( self, wx.ID_ANY, _(u"Picture format").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1872         self.m_staticText11.Wrap( -1 )
1873         fgSizer1.Add( self.m_staticText11, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1874         
1875         formatChoices = [ u"png", u"svg" ]
1876         self.format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, formatChoices, 0 )
1877         self.format.SetSelection( 0 )
1878         fgSizer1.Add( self.format, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1879
1880         if fromcluster :
1881             self.m_staticText111 = wx.StaticText( self, wx.ID_ANY, _(u"Word size proportional to ...").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1882             self.m_staticText11.Wrap( -1 )
1883             fgSizer1.Add( self.m_staticText111, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1884         
1885             IndiceChoices = [ _(u"chi2").decode('utf8'), _(u"frequency").decode('utf8') ]
1886             self.indice = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, IndiceChoices, 0 )
1887             self.indice.SetSelection( 0 )
1888             fgSizer1.Add( self.indice, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1889
1890         self.m_staticline13 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1891         fgSizer1.Add( self.m_staticline13, 0, wx.EXPAND |wx.ALL, 5 )
1892         
1893         self.m_staticline14 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1894         fgSizer1.Add( self.m_staticline14, 0, wx.EXPAND |wx.ALL, 5 )
1895
1896         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Maximum number of forms").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1897         self.m_staticText5.Wrap( -1 )
1898         fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1899         
1900         self.spin_maxword = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 10000, 600 )
1901         self.spin_maxword.SetValue( 600 )
1902         fgSizer1.Add( self.spin_maxword, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1903         
1904         self.m_staticline5 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1905         fgSizer1.Add( self.m_staticline5, 0, wx.EXPAND |wx.ALL, 5 )
1906         
1907         self.m_staticline6 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1908         fgSizer1.Add( self.m_staticline6, 0, wx.EXPAND |wx.ALL, 5 )
1909         
1910         self.typeformes = wx.StaticText( self, wx.ID_ANY, _(u"Used forms").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1911         self.typeformes.Wrap( -1 )
1912         fgSizer1.Add( self.typeformes, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1913         
1914         typeformeschoiceChoices = [ _(u"actives").decode('utf8'), _(u"supplementaries").decode('utf8'), _(u"actives and supplementaries").decode('utf8') ]
1915         self.typeformeschoice = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, typeformeschoiceChoices, 0 )
1916         self.typeformeschoice.SetSelection( 0 )
1917         fgSizer1.Add( self.typeformeschoice, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1918         
1919         self.m_staticline11 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1920         fgSizer1.Add( self.m_staticline11, 0, wx.EXPAND |wx.ALL, 5 )
1921         
1922         self.m_staticline12 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1923         fgSizer1.Add( self.m_staticline12, 0, wx.EXPAND |wx.ALL, 5 )        
1924         
1925         self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, _(u"Text size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1926         self.m_staticText6.Wrap( -1 )
1927         fgSizer1.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1928         
1929         bSizer4 = wx.BoxSizer( wx.VERTICAL )
1930         
1931         bSizer5 = wx.BoxSizer( wx.HORIZONTAL )
1932         
1933         self.m_staticText7 = wx.StaticText( self, wx.ID_ANY, u"Min", wx.DefaultPosition, wx.DefaultSize, 0 )
1934         self.m_staticText7.Wrap( -1 )
1935         bSizer5.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1936         
1937         self.spin_mincex = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 5 )
1938         self.spin_mincex.SetValue( 5 )
1939         bSizer5.Add( self.spin_mincex, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1940         
1941         bSizer4.Add( bSizer5, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
1942         
1943         bSizer6 = wx.BoxSizer( wx.HORIZONTAL )
1944         
1945         self.m_staticText8 = wx.StaticText( self, wx.ID_ANY, u"Max", wx.DefaultPosition, wx.DefaultSize, 0 )
1946         self.m_staticText8.Wrap( -1 )
1947         bSizer6.Add( self.m_staticText8, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1948         
1949         self.spin_maxcex = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 50 )
1950         self.spin_maxcex.SetValue( 50 )
1951         bSizer6.Add( self.spin_maxcex, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1952         
1953         bSizer4.Add( bSizer6, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
1954         
1955         fgSizer1.Add( bSizer4, 1, wx.EXPAND, 5 )
1956         
1957         self.m_staticline7 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1958         fgSizer1.Add( self.m_staticline7, 0, wx.EXPAND |wx.ALL, 5 )
1959         
1960         self.m_staticline8 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1961         fgSizer1.Add( self.m_staticline8, 0, wx.EXPAND |wx.ALL, 5 )
1962         
1963         bSizer61 = wx.BoxSizer( wx.HORIZONTAL )
1964         
1965         self.m_staticText81 = wx.StaticText( self, wx.ID_ANY, _(u"Text color").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1966         self.m_staticText81.Wrap( -1 )
1967         bSizer61.Add( self.m_staticText81, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1968         
1969         self.color_text = wx.ColourPickerCtrl( self, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE )
1970         bSizer61.Add( self.color_text, 0, wx.ALL, 5 )
1971         
1972         fgSizer1.Add( bSizer61, 1, wx.EXPAND, 5 )
1973         
1974         bSizer7 = wx.BoxSizer( wx.HORIZONTAL )
1975         
1976         self.m_staticText9 = wx.StaticText( self, wx.ID_ANY, _(u"Background color").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1977         self.m_staticText9.Wrap( -1 )
1978         bSizer7.Add( self.m_staticText9, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1979         
1980         self.color_bg = wx.ColourPickerCtrl( self, wx.ID_ANY, (255,255,255), wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE )
1981         bSizer7.Add( self.color_bg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1982         
1983         fgSizer1.Add( bSizer7, 1, wx.EXPAND, 5 )
1984         
1985         self.m_staticline9 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1986         fgSizer1.Add( self.m_staticline9, 0, wx.EXPAND |wx.ALL, 5 )
1987         
1988         self.m_staticline10 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1989         fgSizer1.Add( self.m_staticline10, 0, wx.EXPAND |wx.ALL, 5 )
1990
1991         fgSizer1.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
1992         
1993         m_sdbSizer1 = wx.StdDialogButtonSizer()
1994         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
1995         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
1996         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
1997         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
1998         m_sdbSizer1.Realize();
1999         fgSizer1.Add( m_sdbSizer1, 1, wx.EXPAND, 5 )
2000         
2001         self.SetSizer( fgSizer1 )
2002         self.Layout()
2003         fgSizer1.Fit( self )
2004         
2005         self.Centre( wx.BOTH )
2006     
2007     def __del__( self ):
2008         pass
2009     
2010 class PrefChi(sc.SizedDialog):
2011     def __init__(self, parent, ID, optionchi, title):
2012
2013         sc.SizedDialog.__init__(self, None, -1, _(u"Settings").decode('utf8'), 
2014                         style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
2015         pane = self.GetContentsPane()
2016         pane.SetSizerType("form")
2017         pane.SetSizerProps(border=("all",5))
2018         self.parent = parent
2019         self.optionchi = optionchi
2020         
2021
2022         self.label_obs = wx.StaticText(pane, -1, _(u"observed values").decode('utf8'))
2023         self.check1 = wx.CheckBox(pane, -1)
2024  
2025         self.label_theo = wx.StaticText(pane, -1, _(u"expected values").decode('utf8'))
2026         self.check2 = wx.CheckBox(pane, -1)
2027
2028         self.label_resi = wx.StaticText(pane, -1, _(u"residuals").decode('utf8'))
2029         self.check3 = wx.CheckBox(pane, -1)
2030
2031         self.label_contrib = wx.StaticText(pane, -1, _(u"standardized residuals").decode('utf8'))
2032         self.check4 = wx.CheckBox(pane, -1)
2033 #        self.label_graph = wx.StaticText(pane, -1, u'graphique')
2034 #        self.check8 = wx.CheckBox(pane, -1)
2035         self.label_pourcent = wx.StaticText(pane, -1, _(u"total percentage").decode('utf8'))
2036         self.check5 = wx.CheckBox(pane, -1)
2037
2038         self.label_prl = wx.StaticText(pane, -1, _(u"row percentage").decode('utf8'))
2039         self.check6 = wx.CheckBox(pane, -1)
2040
2041         self.label_prc = wx.StaticText(pane, -1, _(u"column percentage").decode('utf8'))
2042         self.check7 = wx.CheckBox(pane, -1)
2043
2044         self.label_graph = wx.StaticText(pane, -1, _(u"graphical").decode('utf8'))
2045         self.check8 = wx.CheckBox(pane, -1)
2046         
2047         self.label_graphbw = wx.StaticText(pane, -1, _(u"black and white graphical").decode('utf8'))
2048         self.checkbw = wx.CheckBox(pane, -1)
2049
2050         self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL))
2051
2052         self.__set_properties()
2053         self.Fit()
2054         self.SetMinSize(self.GetSize())
2055
2056     def __set_properties(self):
2057         self.check1.SetValue(self.optionchi['valobs'])
2058         self.check2.SetValue(self.optionchi['valtheo'])
2059         self.check3.SetValue(self.optionchi['resi'])
2060         self.check4.SetValue(self.optionchi['contrib'])
2061         self.check5.SetValue(self.optionchi['pourcent'])
2062         self.check6.SetValue(self.optionchi['pourcentl'])
2063         self.check7.SetValue(self.optionchi['pourcentc'])
2064         self.check8.SetValue(self.optionchi['graph'])
2065         self.checkbw.SetValue(self.optionchi['bw'])
2066
2067 class ChiDialog(wx.Dialog):
2068     def __init__(
2069             self, parent, ID, title, optionchi, size=wx.DefaultSize, pos=wx.DefaultPosition, 
2070             style=wx.DEFAULT_DIALOG_STYLE
2071             ):
2072
2073         pre = wx.PreDialog()
2074         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
2075         pre.Create(parent, ID, title, pos, size, style)
2076
2077         self.PostCreate(pre)
2078         self.parent = parent 
2079         self.optionchi = optionchi
2080         self.chiopt = False
2081         #self.Filename=parent.filename
2082         #self.content=parent.content[:]
2083         self.headers=parent.tableau.get_colnames()
2084         LABELLIST=[]
2085         
2086         for i in self.headers:
2087             if len(i)>60 :
2088                 LABELLIST.append(i[0:60])
2089             else:
2090                 LABELLIST.append(i)
2091         
2092         self.ListOK=[]
2093         self.LabelListOK=LABELLIST
2094  
2095         self.list_box_1 = wx.ListBox(self, -1, choices=self.LabelListOK, style=wx.LB_EXTENDED|wx.LB_HSCROLL)
2096         self.list_box_2 = wx.ListBox(self, -1, choices=self.LabelListOK, style=wx.LB_EXTENDED|wx.LB_HSCROLL)
2097         self.button_1 = wx.Button(self, wx.ID_OK)
2098         self.button_cancel = wx.Button(self, wx.ID_CANCEL)
2099         self.button_pref = wx.Button(self, wx.ID_PREFERENCES)
2100         self.__set_properties()
2101         self.__do_layout()
2102
2103         self.Bind(wx.EVT_LISTBOX, self.Select1, self.list_box_1)
2104         self.Bind(wx.EVT_BUTTON, self.onparam, self.button_pref)
2105         # end wxGlade
2106 #-------------------------------
2107     def __set_properties(self):
2108         # begin wxGlade: ConfChi2.__set_properties
2109         self.SetTitle(_(u"Variables selection").decode('utf8'))
2110
2111     def __do_layout(self):
2112         # begin wxGlade: ConfChi2.__do_layout
2113         sizer_1 = wx.BoxSizer(wx.VERTICAL)
2114         sizer_2 = wx.BoxSizer(wx.VERTICAL)
2115         sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
2116         sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
2117         sizer_3.Add(self.list_box_1, 0, wx.EXPAND, 0)
2118         sizer_3.Add(self.list_box_2, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 0)
2119         sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
2120         sizer_4.Add(self.button_cancel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 0)
2121         sizer_4.Add(self.button_pref, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 0)
2122         sizer_4.Add(self.button_1, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 0)
2123         sizer_2.Add(sizer_4, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
2124         sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
2125         self.SetSizer(sizer_1)
2126         sizer_1.Fit(self)
2127         self.Layout()
2128         # end wxGlade
2129
2130     def Select1(self, event): # wxGlade: ConfChi2.<event_handler>
2131         event.Skip()
2132     
2133     
2134     def onparam(self,event):
2135         self.dial = PrefChi(self.parent, -1, self.optionchi, '')
2136         self.dial.CenterOnParent()
2137         self.chiopt = self.dial.ShowModal()
2138
2139 class CorpusPref ( wx.Dialog ):
2140     
2141     def __init__( self, parent, parametres ):
2142         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
2143         self.parent = parent 
2144         langues_n = [u'français', u'english', u'german (expérimentale)', u'italian', u'swedish (expérimentale)', u'portuguese (expérimentale)', u'spanish (expérimentale)', u'greek (expériementale)', u'autre...']
2145         self.langues = [u'french', u'english', u'german', u'italian', u'swedish', u'portuguese', u'spanish', u'greek', u'other']
2146         self.encodages = [enc[0].lower() for enc in encodages]
2147
2148         ucimark = [u'****', u'0000']
2149         ucemethod = [_(u"characters").decode('utf8'), _(u"occurrences").decode('utf8'), _(u"paragraphs").decode('utf8')]
2150
2151         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2152         
2153         bSizer1 = wx.BoxSizer( wx.VERTICAL )
2154         
2155         self.m_notebook1 = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
2156         self.m_panel1 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
2157         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2158         fgSizer1.SetFlexibleDirection( wx.BOTH )
2159         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2160         
2161         self.m_staticText7 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Corpora").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2162         self.m_staticText7.Wrap( -1 )
2163         fgSizer1.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2164         
2165         self.txtpath = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Path").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2166         self.txtpath.Wrap( -1 )
2167         fgSizer1.Add( self.txtpath, 0, wx.ALL, 5 )
2168         
2169         self.m_staticText1 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Characters set").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2170         self.m_staticText1.Wrap( -1 )
2171         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2172         
2173         encodage_choicesChoices = [' - '.join(encodage) for encodage in encodages]
2174         self.encodage_choices = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, encodage_choicesChoices, 0 )
2175         self.encodage_choices.SetSelection( 0 )
2176         fgSizer1.Add( self.encodage_choices, 0, wx.ALL, 5 )
2177         
2178         self.m_staticText2 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Language").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2179         self.m_staticText2.Wrap( -1 )
2180         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2181         
2182         lang_choicesChoices = langues_n
2183         self.lang_choices = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, lang_choicesChoices, 0 )
2184         self.lang_choices.SetSelection( 0 )
2185         fgSizer1.Add( self.lang_choices, 0, wx.ALL, 5 )
2186
2187         self.m_staticText3 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Output folder").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2188         self.m_staticText3.Wrap( -1 )
2189         fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2190         
2191         
2192         fgSizer41 = wx.FlexGridSizer( 0, 2, 0, 0 )
2193         fgSizer41.SetFlexibleDirection( wx.BOTH )
2194         fgSizer41.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2195         
2196         self.repout_choices = wx.TextCtrl( self.m_panel1, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0 )
2197         self.repout_choices.SetMinSize( wx.Size( 400,-1 ) )
2198         fgSizer41.Add( self.repout_choices, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2199         
2200         self.m_button1 = wx.Button( self.m_panel1, wx.ID_ANY, _(u"Change ...").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2201         fgSizer41.Add( self.m_button1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2202         
2203         fgSizer1.Add( fgSizer41, 1, wx.EXPAND, 5 )        
2204
2205         self.m_staticText12 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Text mark").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2206         self.m_staticText12.Wrap( -1 )
2207         fgSizer1.Add( self.m_staticText12, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2208         
2209         ucimark_choicesChoices = ucimark
2210         self.ucimark_choices = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ucimark_choicesChoices, 0 )
2211         self.ucimark_choices.SetSelection( 0 )
2212         fgSizer1.Add( self.ucimark_choices, 0, wx.ALL, 5 )
2213         
2214         self.m_staticText6 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Use the expression dictionary").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2215         self.m_staticText6.Wrap( -1 )
2216         fgSizer1.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2217         
2218         self.check_expressions = wx.CheckBox( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2219         self.check_expressions.SetValue(True) 
2220         fgSizer1.Add( self.check_expressions, 0, wx.ALL, 5 )
2221         
2222         self.m_staticText9 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Make text segments").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2223         self.m_staticText9.Wrap( -1 )
2224         fgSizer1.Add( self.m_staticText9, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2225         
2226         self.check_makeuce = wx.CheckBox( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2227         self.check_makeuce.SetValue(True) 
2228         fgSizer1.Add( self.check_makeuce, 0, wx.ALL, 5 )
2229         
2230         self.m_staticText10 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Text segments build process").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2231         self.m_staticText10.Wrap( -1 )
2232         fgSizer1.Add( self.m_staticText10, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2233         
2234         uce_modeChoices = ucemethod
2235         self.uce_mode = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, uce_modeChoices, 0 )
2236         self.uce_mode.SetSelection( 0 )
2237         fgSizer1.Add( self.uce_mode, 0, wx.ALL, 5 )
2238         
2239         self.m_staticText13 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Text segments size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2240         self.m_staticText13.Wrap( -1 )
2241         fgSizer1.Add( self.m_staticText13, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2242         
2243         self.uce_size = wx.SpinCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 1000000, 40 )
2244         fgSizer1.Add( self.uce_size, 0, wx.ALL, 5 )
2245         
2246         
2247         self.m_panel1.SetSizer( fgSizer1 )
2248         self.m_panel1.Layout()
2249         fgSizer1.Fit( self.m_panel1 )
2250         self.m_notebook1.AddPage( self.m_panel1, _(u"General").decode('utf8'), True )
2251         self.m_panel2 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
2252         fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
2253         fgSizer3.SetFlexibleDirection( wx.BOTH )
2254         fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2255         
2256         self.m_staticText4 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Put text in lowercase").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2257         self.m_staticText4.Wrap( -1 )
2258         fgSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2259         
2260         self.check_lower = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2261         self.check_lower.SetValue(True) 
2262         fgSizer3.Add( self.check_lower, 0, wx.ALL, 5 )
2263         
2264         self.m_staticText5 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Delete characters not in this list").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2265         self.m_staticText5.Wrap( -1 )
2266         fgSizer3.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2267         
2268         fgSizer4 = wx.FlexGridSizer( 0, 2, 0, 0 )
2269         fgSizer4.SetFlexibleDirection( wx.BOTH )
2270         fgSizer4.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2271         
2272         self.check_charact = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2273         self.check_charact.SetValue(True) 
2274         fgSizer4.Add( self.check_charact, 0, wx.ALL, 5 )
2275         
2276         self.txt_charact = wx.TextCtrl( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2277         self.txt_charact.SetMinSize( wx.Size( 400,-1 ) )
2278         
2279         fgSizer4.Add( self.txt_charact, 0, wx.ALL|wx.EXPAND, 5 )
2280         
2281         
2282         fgSizer3.Add( fgSizer4, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
2283         
2284         self.m_staticText14 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Replace apostrophe by space").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2285         self.m_staticText14.Wrap( -1 )
2286         fgSizer3.Add( self.m_staticText14, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2287         
2288         self.check_apos = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2289         self.check_apos.SetValue(True) 
2290         fgSizer3.Add( self.check_apos, 0, wx.ALL, 5 )
2291         
2292         self.m_staticText15 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Replace dash by space").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2293         self.m_staticText15.Wrap( -1 )
2294         fgSizer3.Add( self.m_staticText15, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2295         
2296         self.check_tirets = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2297         self.check_tirets.SetValue(True) 
2298         fgSizer3.Add( self.check_tirets, 0, wx.ALL, 5 )
2299         
2300         self.m_staticText17 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Keep punctuation").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2301         self.m_staticText17.Wrap( -1 )
2302         fgSizer3.Add( self.m_staticText17, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2303         
2304         self.check_ponct = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2305         fgSizer3.Add( self.check_ponct, 0, wx.ALL, 5 )
2306
2307         self.m_staticText16 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"No space between two forms").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2308         self.m_staticText16.Wrap( -1 )
2309         fgSizer3.Add( self.m_staticText16, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2310         
2311         self.check_tolist = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2312         fgSizer3.Add( self.check_tolist, 0, wx.ALL, 5 )
2313         
2314         
2315         self.m_panel2.SetSizer( fgSizer3 )
2316         self.m_panel2.Layout()
2317         fgSizer3.Fit( self.m_panel2 )
2318         self.m_notebook1.AddPage( self.m_panel2, _(u"Cleaning").decode('utf8'), False )
2319         
2320         bSizer1.Add( self.m_notebook1, 1, wx.EXPAND |wx.ALL, 5 )
2321         
2322         m_sdbSizer1 = wx.StdDialogButtonSizer()
2323         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2324         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2325         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2326         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2327         m_sdbSizer1.Realize();
2328         
2329         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
2330        
2331
2332         self.Bind(wx.EVT_BUTTON, self.OnChangeDir, self.m_button1)
2333         self.setparametres(parametres) 
2334         self.SetSizer( bSizer1 )
2335         self.Layout()
2336         bSizer1.Fit( self )
2337         
2338         self.Centre( wx.BOTH )
2339
2340     def OnChangeDir(self, evt) :
2341         dlg = wx.DirDialog(self.parent, _(u"Choose a folder").decode('utf8'), style = wx.DD_DEFAULT_STYLE)
2342         if dlg.ShowModal() == wx.ID_OK :
2343             self.repout_choices.SetValue(dlg.GetPath())
2344     
2345     def __del__( self ):
2346         pass
2347
2348     def setparametres(self, parametres) :
2349         if  locale.getpreferredencoding().lower() == 'mac-roman' :
2350             enc = self.encodages.index('macroman')
2351         else :
2352             try :
2353                 enc = self.encodages.index(locale.getpreferredencoding().lower())
2354             except ValueError :
2355                 enc = self.encodages.index('utf-8')
2356         self.encodage_choices.SetSelection(enc)
2357         self.lang_choices.SetSelection(0)
2358         self.repout_choices.SetValue(parametres['pathout'])
2359         self.ucimark_choices.SetSelection(parametres['ucimark'])
2360         self.check_expressions.SetValue(parametres['expressions'])
2361         self.check_makeuce.SetValue(parametres['douce'])
2362         self.uce_mode.SetSelection(parametres['ucemethod'])
2363         self.uce_size.SetValue(parametres['ucesize'])
2364         self.check_lower.SetValue(parametres['lower'])
2365         #self.check_charact.SetValue(parametres['charact'])
2366         self.txt_charact.SetValue(parametres['keep_caract'])
2367         self.check_apos.SetValue(parametres['apos'])
2368         self.check_tirets.SetValue(parametres['tiret'])
2369         self.check_tolist.SetValue(parametres['tolist'])
2370         self.check_ponct.SetValue(parametres['keep_ponct'])
2371
2372     def doparametres(self) :
2373         parametres = {}
2374         parametres['encoding'] = encodages[self.encodage_choices.GetSelection()][0]
2375         parametres['lang'] = self.langues[self.lang_choices.GetSelection()]
2376         parametres['pathout'] = self.repout_choices.GetValue()
2377         parametres['ucimark'] = self.ucimark_choices.GetSelection()
2378         parametres['expressions'] = self.check_expressions.GetValue()
2379         parametres['douce'] =  self.check_makeuce.GetValue()
2380         parametres['ucemethod'] = self.uce_mode.GetSelection()
2381         parametres['ucesize'] = self.uce_size.GetValue()
2382         parametres['lower'] = self.check_lower.GetValue()
2383         parametres['charact'] = self.check_charact.GetValue()
2384         parametres['keep_caract'] = self.txt_charact.GetValue()
2385         parametres['apos'] = self.check_apos.GetValue()
2386         parametres['tiret'] = self.check_tirets.GetValue()
2387         parametres['tolist'] = self.check_tolist.GetValue()
2388         parametres['keep_ponct'] = self.check_ponct.GetValue()
2389         for val in parametres :
2390             if isinstance(parametres[val], bool) :
2391                 if parametres[val] :
2392                     parametres[val] = 1
2393                 else :
2394                     parametres[val] = 0
2395         return parametres
2396
2397 class message(wx.Dialog):
2398     def __init__(self, parent, title, size, save = True):
2399         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.DEFAULT_DIALOG_STYLE )
2400         self.save = save    
2401         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2402
2403         self.html = ""
2404         self.HtmlPage=wx.html.HtmlWindow(self, -1)
2405         self.HtmlPage.SetMinSize( size )
2406         if "gtk2" in wx.PlatformInfo:
2407             self.HtmlPage.SetStandardFonts()
2408         self.HtmlPage.SetFonts('Courier','Courier')
2409
2410         self.button_1 = wx.Button(self, wx.ID_CANCEL)
2411
2412         self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
2413         if self.save :
2414             self.button_2 = wx.Button(self, wx.ID_SAVE)
2415             self.Bind(wx.EVT_BUTTON, self.OnSavePage, self.button_2)
2416         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
2417         self.__do_layout()
2418
2419     def __do_layout(self):
2420         sizer_2 = wx.BoxSizer(wx.VERTICAL)
2421         sizer_2.Add(self.HtmlPage, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
2422         m_sdbSizer1 = wx.StdDialogButtonSizer()
2423         m_sdbSizer1.AddButton(  self.button_1 )
2424         if self.save :
2425             m_sdbSizer1.AddButton(  self.button_2 )
2426         m_sdbSizer1.Realize()
2427         sizer_2.Add(m_sdbSizer1, 1, wx.EXPAND, 5)
2428         self.SetSizer(sizer_2)
2429         self.Layout()
2430         sizer_2.Fit( self )
2431
2432     def OnSavePage(self, evt) :
2433         dlg = wx.FileDialog(
2434             self, message=_(u"Save as ...").decode('utf8'), defaultDir=os.getcwd(),
2435             defaultFile="concordancier.html", wildcard="html|*.html", style=wx.SAVE | wx.OVERWRITE_PROMPT
2436             )
2437         dlg.SetFilterIndex(2)
2438         dlg.CenterOnParent()
2439         if dlg.ShowModal() == wx.ID_OK:
2440             path = dlg.GetPath()
2441             with open(path, 'w') as f :
2442                 f.write(self.html)
2443
2444     def OnCloseMe(self, event):
2445         self.Close(True)
2446
2447     def OnCloseWindow(self, event):
2448         self.Destroy()
2449
2450 class ExtractDialog ( wx.Dialog ):
2451     
2452     def __init__( self, parent, option ):
2453         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
2454
2455         self.option = option
2456         
2457         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2458         
2459         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2460         fgSizer1.SetFlexibleDirection( wx.BOTH )
2461         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2462         
2463         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Corpora").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2464         self.m_staticText1.Wrap( -1 )
2465         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2466         
2467         self.corpusfile = wx.FilePickerCtrl( self, wx.ID_ANY, wx.EmptyString, _(u"Select a file").decode('utf8'), u"*.txt", wx.DefaultPosition, wx.Size( -1,-1 ), wx.FLP_DEFAULT_STYLE|wx.FLP_FILE_MUST_EXIST|wx.FLP_OPEN )
2468         self.corpusfile.SetMinSize( wx.Size( 500,-1 ) )
2469         
2470         fgSizer1.Add( self.corpusfile, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2471         
2472         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Characters set").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2473         self.m_staticText2.Wrap( -1 )
2474         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2475         
2476         encodageChoices = [' - '.join(encodage) for encodage in encodages]
2477         self.encodage = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, encodageChoices, 0 )
2478         self.encodage.SetSelection( 0 )
2479         self.encodage.SetMinSize( wx.Size( 200,-1 ) )
2480         
2481         fgSizer1.Add( self.encodage, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2482         
2483         if option == 'splitvar' :
2484             self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Variables (with the * but without the _)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2485             self.m_staticText3.Wrap( -1 )
2486             fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2487             
2488             self.txtvar = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2489             self.txtvar.SetMinSize( wx.Size( 200,-1 ) )
2490             
2491             fgSizer1.Add( self.txtvar, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2492         
2493         if option == 'mods' :
2494             self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Modalities (one by line, with the *)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2495             self.m_staticText4.Wrap( -1 )
2496             fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2497             
2498             self.txtmods = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE )
2499             self.txtmods.SetMinSize( wx.Size( 200,150 ) )
2500             
2501             fgSizer1.Add( self.txtmods, 0, wx.ALL|wx.EXPAND, 5 )
2502             
2503             self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Extraction type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2504             self.m_staticText5.Wrap( -1 )
2505             fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2506             
2507             extractformatChoices = [ _(u"Only one file").decode('utf8'), _(u"One file by modality").decode('utf8') ]
2508             self.extractformat = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, extractformatChoices, 1, wx.RA_SPECIFY_COLS )
2509             self.extractformat.SetSelection( 0 )
2510             fgSizer1.Add( self.extractformat, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2511             
2512         
2513         fgSizer1.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
2514         
2515         m_sdbSizer1 = wx.StdDialogButtonSizer()
2516         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2517         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2518         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2519         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2520         m_sdbSizer1.Realize();
2521         
2522         fgSizer1.Add( m_sdbSizer1, 1, wx.EXPAND, 5 )
2523         
2524         
2525         self.SetSizer( fgSizer1 )
2526         self.Layout()
2527         fgSizer1.Fit( self )
2528         
2529         self.Centre( wx.BOTH )
2530
2531     def make_param(self) :
2532         parametres = {}
2533         le = [enc[0].lower() for enc in encodages]
2534         parametres['filein'] = self.corpusfile.GetPath()
2535         encodage = le[self.encodage.GetSelection()]
2536         parametres['encodein'] = encodage
2537         if self.option == 'splitvar' :
2538             parametres['var'] = self.txtvar.GetValue()
2539         if self.option == 'mods' :
2540             parametres['mods'] = self.txtmods.GetValue().splitlines()
2541             if self.extractformat.GetSelection() == 0 :
2542                 parametres['onefile'] = True
2543             else :
2544                 parametres['onefile'] = False
2545         parametres['encodeout'] = locale.getpreferredencoding()
2546         return parametres
2547     
2548     def __del__( self ):
2549         pass
2550
2551 class FreqDialog(wx.Dialog):
2552     def __init__(self, parent, ID, listcol, title, size) :
2553         wx.Dialog.__init__(self, parent, ID, title, size=size, pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK )
2554         pre = wx.PreDialog()
2555         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
2556         pre.Create(parent, ID, title, wx.DefaultPosition, size, wx.DEFAULT_DIALOG_STYLE | wx.CANCEL | wx.OK)
2557         self.PostCreate(pre)
2558         self.parent = parent 
2559         sizer = wx.BoxSizer(wx.VERTICAL)
2560         #self.content = parent.content
2561         self.header = listcol
2562         #LABELLIST = []
2563         #for i in self.header:
2564         #    forme = i
2565         #    if len(forme) > 60 :
2566         #        LABELLIST.append(i[0:60])
2567         #    else:
2568         #        LABELLIST.append(i)
2569         self.list_box_1 = wx.ListBox(self, -1, choices=self.header, style=wx.LB_EXTENDED | wx.LB_HSCROLL)
2570         sizer.Add(self.list_box_1, 0, 5)
2571         
2572         btnsizer = wx.BoxSizer(wx.HORIZONTAL)
2573         
2574         btn = wx.Button(self, wx.ID_CANCEL)
2575         btnsizer.Add(btn)
2576         
2577         btn = wx.Button(self, wx.ID_OK)
2578         btn.SetDefault()
2579         btnsizer.Add(btn)
2580         
2581         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5)
2582         self.SetSizer(sizer)
2583         sizer.Fit(self)
2584         self.SetTitle(_(u"Selection").decode('utf8'))
2585   
2586         # end wxGlade
2587
2588 class ProtoDial ( wx.Dialog ):
2589     
2590     def __init__( self, parent, headers ):
2591         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
2592         
2593         self.SetSizeHintsSz( wx.Size( 200,300 ), wx.DefaultSize )
2594         
2595         bSizer1 = wx.BoxSizer( wx.VERTICAL )
2596         
2597         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2598         fgSizer1.SetFlexibleDirection( wx.BOTH )
2599         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2600         
2601         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Variables").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2602         self.m_staticText1.Wrap( -1 )
2603         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
2604         
2605         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Ranks").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2606         self.m_staticText2.Wrap( -1 )
2607         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
2608         
2609         variablesChoices = headers
2610         self.variables = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, variablesChoices, wx.LB_MULTIPLE )
2611         self.variables.SetMinSize( wx.Size( 150,-1 ) )
2612         
2613         fgSizer1.Add( self.variables, 0, wx.ALL|wx.EXPAND, 5 )
2614         
2615         rangsChoices = headers
2616         self.rangs = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, rangsChoices, wx.LB_MULTIPLE )
2617         self.rangs.SetMinSize( wx.Size( 150,-1 ) )
2618         
2619         fgSizer1.Add( self.rangs, 0, wx.ALL|wx.EXPAND, 5 )
2620         
2621         
2622         bSizer1.Add( fgSizer1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5 )
2623         
2624         fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
2625         fgSizer3.SetFlexibleDirection( wx.BOTH )
2626         fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2627         
2628         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Limit frequency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2629         self.m_staticText3.Wrap( -1 )
2630         fgSizer3.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2631         
2632         bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
2633         
2634         choix_freqChoices = [ _(u"automatic (mean)").decode('utf8'), _(u"manual").decode('utf8') ]
2635         self.choix_freq = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choix_freqChoices, 0 )
2636         self.choix_freq.SetSelection( 0 )
2637         bSizer2.Add( self.choix_freq, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2638         
2639         self.freqlim = wx.TextCtrl( self, wx.ID_ANY, u"0", wx.DefaultPosition, wx.DefaultSize, wx.TE_CENTRE )
2640         self.freqlim.Enable( False )
2641         self.freqlim.SetMinSize( wx.Size( 100,-1 ) )
2642         
2643         bSizer2.Add( self.freqlim, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2644         
2645         
2646         fgSizer3.Add( bSizer2, 1, wx.EXPAND, 5 )
2647         
2648         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Limit rank").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2649         self.m_staticText4.Wrap( -1 )
2650         fgSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2651         
2652         bSizer21 = wx.BoxSizer( wx.HORIZONTAL )
2653         
2654         choix_rangChoices = [ _(u"automatic (mean)").decode('utf8'), _(u"manual").decode('utf8')]
2655         self.choix_rang = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choix_rangChoices, 0 )
2656         self.choix_rang.SetSelection( 0 )
2657         bSizer21.Add( self.choix_rang, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2658         
2659         self.ranglim = wx.TextCtrl( self, wx.ID_ANY, u"0", wx.DefaultPosition, wx.DefaultSize, wx.TE_CENTRE )
2660         self.ranglim.Enable( False )
2661         self.ranglim.SetMinSize( wx.Size( 100,-1 ) )
2662         
2663         bSizer21.Add( self.ranglim, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2664         
2665         
2666         fgSizer3.Add( bSizer21, 1, wx.EXPAND, 5 )
2667         
2668         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Minimum frequency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2669         self.m_staticText5.Wrap( -1 )
2670         fgSizer3.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2671         
2672         self.m_textCtrl4 = wx.TextCtrl( self, wx.ID_ANY, u"2", wx.DefaultPosition, wx.DefaultSize, wx.TE_CENTRE )
2673         fgSizer3.Add( self.m_textCtrl4, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
2674         
2675         
2676         bSizer1.Add( fgSizer3, 1, wx.EXPAND, 5 )
2677         
2678         m_sdbSizer1 = wx.StdDialogButtonSizer()
2679         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2680         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2681         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2682         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2683         m_sdbSizer1.Realize();
2684         
2685         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
2686         
2687         self.SetSizer( bSizer1 )
2688         self.Layout()
2689         bSizer1.Fit( self )
2690         
2691         self.Centre( wx.BOTH )
2692         
2693         # Connect Events
2694         self.choix_freq.Bind( wx.EVT_CHOICE, self.UpdateText )
2695         self.choix_rang.Bind( wx.EVT_CHOICE, self.UpdateText )
2696     
2697     def __del__( self ):
2698         pass
2699     
2700     
2701     # Virtual event handlers, overide them in your derived class
2702     def UpdateText( self, event ):
2703         event.Skip()
2704
2705 class SimpleDialog ( wx.Dialog ):
2706     
2707     def __init__( self, parent ):
2708         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
2709         
2710         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2711         
2712         bSizer1 = wx.BoxSizer( wx.VERTICAL )
2713         
2714         self.m_panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
2715         bSizer2 = wx.BoxSizer( wx.VERTICAL )
2716         
2717         self.m_staticText1 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Export finished. Open in a web browser :").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2718         self.m_staticText1.Wrap( -1 )
2719         bSizer2.Add( self.m_staticText1, 0, wx.ALL, 5 )
2720         
2721         self.link = wx.HyperlinkCtrl( self.m_panel1, wx.ID_ANY, u"wxFB Website", u"http://www.wxformbuilder.org", wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE )
2722         bSizer2.Add( self.link, 0, wx.ALL, 5 )
2723         
2724         
2725         self.m_panel1.SetSizer( bSizer2 )
2726         self.m_panel1.Layout()
2727         bSizer2.Fit( self.m_panel1 )
2728         bSizer1.Add( self.m_panel1, 1, wx.EXPAND |wx.ALL, 5 )
2729         
2730         m_sdbSizer1 = wx.StdDialogButtonSizer()
2731         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2732         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2733         m_sdbSizer1.Realize();
2734         
2735         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
2736         
2737         
2738         self.SetSizer( bSizer1 )
2739         self.Layout()
2740         bSizer1.Fit( self )
2741         
2742         self.Centre( wx.BOTH )
2743     
2744     def __del__( self ):
2745         pass