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