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