...
[iramuteq] / dialog.py
1 #!/bin/env python
2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2008-2009 Pierre Ratinaud
5 #License: GNU/GPL
6 import  wx
7 import  wx.lib.colourselect as csel
8 import wx.lib.sized_controls as sc
9 import wx.lib.filebrowsebutton as filebrowse
10 import locale
11 from functions import DoConf, exec_rcode
12 import os
13 from shutil import copyfile
14 from PrintRScript import barplot
15 import tempfile
16 import sys
17 from KeyFrame import AlcOptFrame
18 import wx.lib.hyperlink as hl
19 #---------------------------------------------------------------------------
20 provider = wx.SimpleHelpProvider()
21 wx.HelpProvider_Set(provider)
22
23 #---------------------------------------------------------------------------
24
25
26 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']]
27
28 class FileOptionDialog(wx.Dialog):
29     def __init__(
30             self, parent, ID, title, sep=False, sheet = False, size=wx.DefaultSize, pos=wx.DefaultPosition,
31             style=wx.DEFAULT_DIALOG_STYLE
32             ):
33
34         pre = wx.PreDialog()
35         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
36         pre.Create(parent, ID, title, pos, size, style)
37
38         self.PostCreate(pre)
39
40         sizer = wx.BoxSizer(wx.VERTICAL)
41         grid_sizer = wx.FlexGridSizer(0, 2, 2, 2)
42 ##############################
43
44         label = wx.StaticText(self, -1, _(u"First line is header").decode('utf8'))
45         label.SetHelpText(_(u"First line is header").decode('utf8'))
46         grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
47         on = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
48         self.radio_box_1 = wx.RadioBox(self, -1, u"", choices=on, majorDimension=0, style=wx.RA_SPECIFY_ROWS)
49         self.radio_box_1.SetHelpText(_(u"First line is header").decode('utf8'))
50         grid_sizer.Add(self.radio_box_1, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
51
52 ##############################
53
54         label = wx.StaticText(self, -1, _(u"First column is an id").decode('utf8'))
55         label.SetHelpText(_(u"First column is an id").decode('utf8'))
56         grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
57         on = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
58         self.radio_box_2 = wx.RadioBox(self, -1, u"", choices=on, majorDimension=0, style=wx.RA_SPECIFY_ROWS)
59         self.radio_box_2.SetHelpText(_(u"First column is an id").decode('utf8'))
60         grid_sizer.Add(self.radio_box_2, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
61
62 ##############################
63         if sep:
64             label = wx.StaticText(self, -1, _(u"Column separator").decode('utf8'))
65             label.SetHelpText(_(u"Column separator").decode('utf8'))
66             grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
67             self.colsep = [";", "tabulation", ","]
68             self.choice3 = wx.Choice(self, -1, (100, 50), choices=self.colsep)
69             self.choice3.SetHelpText(_(u"Column separator").decode('utf8'))
70             grid_sizer.Add(self.choice3, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
71     
72     ##############################
73     
74             label = wx.StaticText(self, -1, _(u"Text separator").decode('utf8'))
75             label.SetHelpText(_(u"Text separator").decode('utf8'))
76             grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
77             self.txtsep = ["\"", "'"]
78             self.choice4 = wx.Choice(self, -1, (100, 50), choices=self.txtsep)
79             self.choice4.SetHelpText(_(u"Text separator").decode('utf8'))
80             grid_sizer.Add(self.choice4, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
81             self.choice3.SetSelection(0)
82             self.choice4.SetSelection(0)
83             self.text = wx.StaticText(self, -1, _(u"Characters set").decode('utf8'))
84             grid_sizer.Add(self.text, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
85             self.le = [enc[0].lower() for enc in encodages] 
86             self.list_encodages = wx.Choice(self, -1, (25, 30), choices=[' - '.join(encodage) for encodage in encodages])
87             if locale.getpreferredencoding().lower() == 'mac-roman' :
88                 enc = self.le.index('macroman')
89             else :
90                 try :
91                     enc = self.le.index(sys.getdefaultencoding().lower())
92                 except ValueError:
93                     enc = self.le.index('utf-8')
94             self.list_encodages.SetSelection(enc)
95             grid_sizer.Add(self.list_encodages, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
96         elif sheet :
97             label = wx.StaticText(self, -1, u"Feuille ")
98             grid_sizer.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
99             self.spin1 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=500)
100             grid_sizer.Add(self.spin1, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
101         
102         sizer.Add(grid_sizer, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
103
104
105         line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
106         sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)
107
108         btnsizer = wx.StdDialogButtonSizer()
109         
110         if wx.Platform != "__WXMSW__":
111             btn = wx.ContextHelpButton(self)
112             btnsizer.AddButton(btn)
113         
114         btn = wx.Button(self, wx.ID_OK)
115         btn.SetDefault()
116         btnsizer.AddButton(btn)
117
118         btn = wx.Button(self, wx.ID_CANCEL)
119         btnsizer.AddButton(btn)
120         btnsizer.Realize()
121
122         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5)
123
124         self.SetSizer(sizer)
125         sizer.Fit(self)
126
127
128 class ClusterNbDialog(wx.Dialog):
129     def __init__(
130             self, LIST_CLASSE, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition,
131             style=wx.DEFAULT_DIALOG_STYLE
132             ):
133
134         pre = wx.PreDialog()
135         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
136         pre.Create(parent, ID, title, pos, size, style)
137
138         self.PostCreate(pre)
139
140         # Now continue with the normal construction of the dialog
141         # contents
142         sizer = wx.BoxSizer(wx.VERTICAL)
143
144         label = wx.StaticText(self, -1, u"Résultats de la classification")
145         label.SetHelpText("This is the help text for the label")
146         sizer.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
147
148         box = wx.BoxSizer(wx.HORIZONTAL)
149
150         label = wx.StaticText(self, -1, u"Choisissez le nombre de classes")
151         label.SetHelpText("This is the help text for the label")
152         box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
153         LIST_CLASSE_OK = []
154         if type(LIST_CLASSE) != float :
155             for i in LIST_CLASSE :
156                 LIST_CLASSE_OK.append(str(i))
157         else :
158             LIST_CLASSE_OK.append(str(LIST_CLASSE))
159         self.list_box_1 = wx.ListBox(self, -1, choices=LIST_CLASSE_OK, style=wx.LB_SINGLE | wx.LB_HSCROLL)
160         self.list_box_1.SetHelpText("Here's some help text for field #1")
161         box.Add(self.list_box_1, 1, wx.ALIGN_CENTRE | wx.ALL, 5)
162
163         sizer.Add(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
164
165
166 ###############################
167         line = wx.StaticLine(self, -1, size=(20, -1), style=wx.LI_HORIZONTAL)
168         sizer.Add(line, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.TOP, 5)
169
170         btnsizer = wx.StdDialogButtonSizer()
171         
172         if wx.Platform != "__WXMSW__":
173             btn = wx.ContextHelpButton(self)
174             btnsizer.AddButton(btn)
175         
176         btn = wx.Button(self, wx.ID_OK)
177         btn.SetDefault()
178         btnsizer.AddButton(btn)
179
180         btn = wx.Button(self, wx.ID_CANCEL)
181         btnsizer.AddButton(btn)
182         btnsizer.Realize()
183
184         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
185
186         self.SetSizer(sizer)
187         sizer.Fit(self)
188
189 class CHDDialog(wx.Dialog):
190     def __init__(
191             self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition,
192             style=wx.DEFAULT_DIALOG_STYLE | wx.CANCEL
193             ):
194         pre = wx.PreDialog()
195         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
196         pre.Create(parent, ID, title, pos, size, style)
197
198         self.PostCreate(pre)
199        
200         self.colsep = parent.colsep
201         self.Box = 1
202         self.content = parent.content[:]
203         self.header = parent.header[:]
204         LABELLIST = []
205         for i in self.header:
206             if len(i) > 60 :
207                 LABELLIST.append(i[0:60])
208             else:
209                 LABELLIST.append(i)
210         self.LABELLISTTOT = LABELLIST
211         self.LISTVARSUP = []
212 #----------------------------------------------------------------------------------------------------
213         self.text1 = wx.StaticText(self, -1, u"Variables Actives (au moins 3)")
214         self.text2 = wx.StaticText(self, -1, u"Variables Supplémentaires (au moins 1)")
215         self.list_box_1 = wx.ListBox(self, -1, choices=LABELLIST, style=wx.LB_EXTENDED | wx.LB_HSCROLL)
216         self.list_box_2 = wx.ListBox(self, -1, choices=LABELLIST, style=wx.LB_EXTENDED | wx.LB_HSCROLL)
217         self.button_cancel = wx.Button(self, wx.ID_CANCEL)
218         self.button_back = wx.Button(self, wx.ID_BACKWARD)
219         self.button_forw = wx.Button(self, wx.ID_FORWARD)
220         self.button_ok = wx.Button(self, wx.ID_OK)
221         self.button_pref = wx.Button(self, wx.ID_PROPERTIES)
222         self.button_selectall = wx.Button(self, wx.NewId(), u"Sélectionner tout")
223         self.__set_properties()
224         self.__do_layout()
225
226         self.Bind(wx.EVT_BUTTON, self.OnPrec, self.button_back)
227         self.Bind(wx.EVT_BUTTON, self.OnSuivant, self.button_forw)
228         self.Bind(wx.EVT_BUTTON, self.OnValider, self.button_ok)
229         self.Bind(wx.EVT_BUTTON, self.OnSelectAll, self.button_selectall)
230         # end wxGlade
231         self.parent = parent
232         self.TEMPDIR = parent.TEMPDIR
233         self.num = 0
234
235     def __set_properties(self):
236         # begin wxGlade: ConfChi2.__set_properties
237         self.SetTitle(u"Sélection des variables")
238         self.list_box_2.Enable(False)
239         self.button_ok.Enable(False)        
240         self.button_back.Enable(False)
241         # end wxGlade
242
243     def __do_layout(self):
244         # begin wxGlade: ConfChi2.__do_layout
245         sizer_1 = wx.BoxSizer(wx.VERTICAL)
246         sizer_2 = wx.BoxSizer(wx.VERTICAL)
247         sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
248         sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
249         sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
250         sizer_6 = wx.BoxSizer(wx.HORIZONTAL)
251         sizer_7 = wx.BoxSizer(wx.HORIZONTAL)
252         sizer_5.Add(self.text1, 1, wx.CENTER | wx.ALL, 0)
253         sizer_5.Add(self.text2, 1, wx.CENTER | wx.ALL, 0)
254         sizer_3.Add(self.list_box_1, 0, wx.EXPAND, 0)
255         sizer_3.Add(self.list_box_2, 0, wx.EXPAND, 0)
256         sizer_6.Add(self.button_selectall, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 0) 
257         sizer_7.Add(self.button_cancel, 0, wx.ALL, 0)
258         sizer_7.Add(self.button_pref, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
259         sizer_7.Add(self.button_ok, 0, wx.wx.ALIGN_CENTER_HORIZONTAL, 0)
260         sizer_4.Add(self.button_back, 0, wx.ALL, 0)
261         sizer_4.Add(self.button_forw, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
262         sizer_2.Add(sizer_5, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
263         sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
264         sizer_2.Add(sizer_6, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
265         sizer_2.Add(sizer_4, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
266         sizer_2.Add(sizer_7, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
267         sizer_1.Add(sizer_2, 1, wx.EXPAND, 4)
268         self.SetSizer(sizer_1)
269         sizer_1.Fit(self)
270         self.Layout()
271         # end wxGlade
272 #--------------FIXME-----------------------
273 #NETTOYAGE des variables inutiles
274     def OnSuivant(self, event): 
275         LISTACTIVE = self.list_box_1.GetSelections()
276         if len(LISTACTIVE) != len(self.LABELLISTTOT) and len(LISTACTIVE) >= 3: 
277             self.button_ok.Enable(True)
278         self.Box = 2
279         self.LISTHEADERINDICE = []
280         self.LISTNUMACTIVE = []
281         COMPT = 0
282         header = self.header[:]
283         for i in range(0, len(header)):
284             self.LISTHEADERINDICE.append(i)
285         for i in LISTACTIVE :
286             self.LISTNUMACTIVE.append(i)
287             header.pop(i - COMPT)
288             self.LISTHEADERINDICE.pop(i - COMPT)
289             COMPT += 1
290         self.LABELLIST = []
291         for i in header:
292             if len(i) > 60 :
293                 self.LABELLIST.append(i[0:60])
294             else:
295                 self.LABELLIST.append(i)
296         self.list_box_2.Clear()
297         for i in self.LABELLIST :
298             self.list_box_2.Append(i)
299                     
300         self.list_box_1.Enable(False)    
301         self.list_box_2.Enable(True)
302         self.button_forw.Enable(False)
303         self.button_back.Enable(True)
304
305     def OnValider(self, event):
306         LISTVARSUPSEL = self.list_box_2.GetSelections()
307         for i in LISTVARSUPSEL :
308             self.LISTVARSUP.append(self.LISTHEADERINDICE[i])
309         event.Skip()
310
311     def OnPrec(self, event):
312         self.list_box_1.Enable(True)
313         self.list_box_2.Enable(False)
314         self.button_forw.Enable(True)
315         self.button_back.Enable(False)   
316         self.button_ok.Enable(False)
317         self.Box = 1
318         event.Skip()
319
320     def OnSelectAll(self, event):
321         if self.Box == 1:
322             for i in range(len(self.LABELLISTTOT)):
323                 self.list_box_1.Select(i)
324         else:
325             for i in range(len(self.LABELLIST)):
326                 self.list_box_2.Select(i)
327
328 class PrefDialog ( wx.Dialog ):
329     
330     def __init__( self, parent ):
331         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
332         self.parent = parent
333         
334         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
335         
336         bSizer1 = wx.BoxSizer( wx.VERTICAL )
337         
338         fgSizer1 = wx.FlexGridSizer( 0, 3, 0, 0 )
339         fgSizer1.SetFlexibleDirection( wx.BOTH )
340         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
341         
342         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Play a sound at the end of analysis").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
343         self.m_staticText1.Wrap( -1 )
344         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
345         
346         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
347         self.m_staticText2.Wrap( -1 )
348         fgSizer1.Add( self.m_staticText2, 0, wx.ALL, 5 )
349         
350         m_radioBox1Choices = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
351         self.m_radioBox1 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox1Choices, 1, wx.RA_SPECIFY_COLS )
352         self.m_radioBox1.SetSelection( 0 )
353         fgSizer1.Add( self.m_radioBox1, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
354
355         msg = _(u"""Check for new 
356 releases at startup""").decode('utf8')
357         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, msg, wx.DefaultPosition, wx.DefaultSize, 0 )
358         self.m_staticText3.Wrap( -1 )
359         fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
360         
361         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
362         self.m_staticText4.Wrap( -1 )
363         fgSizer1.Add( self.m_staticText4, 0, wx.ALL, 5 )
364         
365         m_radioBox2Choices = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
366         self.m_radioBox2 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox2Choices, 1, wx.RA_SPECIFY_COLS )
367         self.m_radioBox2.SetSelection( 0 )
368         fgSizer1.Add( self.m_radioBox2, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
369
370         msg = _(u"Interface language").decode('utf8')
371         self.m_staticText45 = wx.StaticText( self, wx.ID_ANY, msg, wx.DefaultPosition, wx.DefaultSize, 0 )
372         self.m_staticText45.Wrap( -1 )
373         fgSizer1.Add( self.m_staticText45, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
374         
375         self.m_staticText46 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
376         self.m_staticText46.Wrap( -1 )
377         fgSizer1.Add( self.m_staticText46, 0, wx.ALL, 5 )
378         
379         self.listlangues = [ u"english",u"french", u"italian", u"portuguese", u"spanish"]
380         self.langues = wx.Choice( self, wx.ID_ANY, (200, -1), choices = self.listlangues)
381         #self.langues.SetSelection( 0 )
382         fgSizer1.Add( self.langues, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
383         
384         msg = _(u"""Check installation 
385 of R packages""").decode('utf8')
386         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, msg, wx.DefaultPosition, wx.DefaultSize, 0 )
387         self.m_staticText5.Wrap( -1 )
388         fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
389         
390         self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
391         self.m_staticText6.Wrap( -1 )
392         fgSizer1.Add( self.m_staticText6, 0, wx.ALL, 5 )
393         
394         self.m_button1 = wx.Button( self, wx.ID_ANY, _(u"Check").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
395         fgSizer1.Add( self.m_button1, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
396         
397         bSizer1.Add( fgSizer1, 1, wx.EXPAND, 5 )
398         if sys.platform == 'win32' :
399             bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
400             
401             msg = _(u"""Maximum 
402 memory for R""").decode('utf8')
403             self.m_staticText7 = wx.StaticText( self, wx.ID_ANY, msg, wx.DefaultPosition, wx.DefaultSize, 0 )
404             self.m_staticText7.Wrap( -1 )
405             bSizer2.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
406             
407             self.m_checkBox1 = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
408             bSizer2.Add( self.m_checkBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
409             
410             self.m_spinCtrl1 = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 32, 16000, 1535 )
411             bSizer2.Add( self.m_spinCtrl1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
412             
413             self.m_staticline7 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
414             bSizer2.Add( self.m_staticline7, 0, wx.EXPAND |wx.ALL, 5 )
415             
416             bSizer1.Add( bSizer2, 0, wx.EXPAND, 5 )
417             self.m_checkBox1.Bind( wx.EVT_CHECKBOX, self.oncheckmem )
418
419         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
420         bSizer4 = wx.BoxSizer( wx.HORIZONTAL )
421         self.text8 = wx.StaticText( self, wx.ID_ANY, _(u"Use svdlibc").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
422         self.text8.Wrap( -1 )
423         fgSizer1.Add( self.text8, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
424         self.check_svdc = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
425         bSizer4.Add( self.check_svdc, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
426         bSizer3.Add( bSizer4, 0, wx.EXPAND, 5 )
427         self.fbb = filebrowse.FileBrowseButton(self, -1, size=(250, -1), fileMode = 2, fileMask = '*')
428         bSizer3.Add( self.fbb, 0, wx.EXPAND, 5 )
429         self.fbb.SetLabel(_(u"Path : ").decode('utf8'))
430         fgSizer1.Add( wx.StaticText(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ),  wx.ID_ANY, wx.ALL, 5)
431         fgSizer1.Add( bSizer3, 0,  wx.ALIGN_RIGHT|wx.ALL, 5 )
432
433         Rpath_text =  wx.StaticText( self, wx.ID_ANY, _(u"R path").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
434         Rpath_text.Wrap( -1 )
435         fgSizer1.Add( Rpath_text, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
436         fgSizer1.Add( wx.StaticText(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ),  wx.ID_ANY, wx.ALL, 5)
437         self.Rpath_value = filebrowse.FileBrowseButton(self, -1, size=(350, -1), fileMode = 2, fileMask = '*')
438         self.Rpath_value.SetLabel(_(u"Path : ").decode('utf8'))
439         fgSizer1.Add( self.Rpath_value, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
440
441         mirror_text =  wx.StaticText( self, wx.ID_ANY, _(u"Default R mirror").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
442         mirror_text.Wrap( -1 )
443         fgSizer1.Add( mirror_text, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
444         fgSizer1.Add( wx.StaticText(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ),  wx.ID_ANY, wx.ALL, 5)
445         self.mirror_value = wx.TextCtrl( self, wx.ID_ANY, u'http://cran.univ-lyon1.fr', wx.DefaultPosition, wx.Size( 300,30 ), 0 ) 
446         fgSizer1.Add( self.mirror_value, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
447
448
449         m_sdbSizer1 = wx.StdDialogButtonSizer()
450         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
451         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
452         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
453         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
454         m_sdbSizer1.Realize()
455         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
456         
457         self.SetSizer( bSizer1 )
458         self.Layout()
459         bSizer1.Fit( self )
460         
461         self.Centre( wx.BOTH )
462         
463         # Connect Events
464         self.m_sdbSizer1OK.Bind( wx.EVT_BUTTON, self.OnValid )
465         self.m_button1.Bind( wx.EVT_BUTTON, parent.OnVerif )
466         self.check_svdc.Bind( wx.EVT_CHECKBOX, self.OnSVDC )
467         self.__set_properties()
468
469     def __set_properties(self):
470         self.SetTitle(_(u"Settings").decode('utf8'))
471         if self.parent.pref.getboolean('iramuteq', 'sound'): val1 = 0
472         else : val1 = 1
473         self.m_radioBox1.SetSelection(val1)
474         if self.parent.pref.getboolean('iramuteq', 'checkupdate') : val2 = 0
475         else : val2 = 1
476         self.m_radioBox2.SetSelection(val2)
477         self.langues.SetSelection(self.listlangues.index(self.parent.pref.get('iramuteq', 'guilanguage')))
478         if sys.platform == 'win32' :
479             if self.parent.pref.getboolean('iramuteq', 'R_mem') :
480                 self.m_checkBox1.SetValue(True)
481                 self.m_spinCtrl1.Enable(True)
482                 self.m_spinCtrl1.SetValue(self.parent.pref.getint('iramuteq', 'R_max_mem'))
483             else :
484                 self.m_checkBox1.SetValue(False)
485                 self.m_spinCtrl1.Enable(False)
486         if self.parent.pref.getboolean('iramuteq', 'libsvdc') : 
487             self.check_svdc.SetValue(True)
488             self.fbb.SetValue(self.parent.pref.get('iramuteq', 'libsvdc_path'))
489         else :
490             self.check_svdc.SetValue(False)
491             self.fbb.SetValue(self.parent.pref.get('iramuteq', 'libsvdc_path'))
492             self.fbb.Enable(False)
493         self.Rpath_value.SetValue(self.parent.PathPath.get('PATHS', 'rpath'))
494         self.mirror_value.SetValue(self.parent.pref.get('iramuteq', 'rmirror'))
495         
496     def oncheckmem(self, evt):
497         if self.m_checkBox1.GetValue() :
498             self.m_spinCtrl1.Enable(True)
499         else :
500             self.m_spinCtrl1.Enable(False)
501
502     def OnSVDC(self, evt):
503         if self.check_svdc.GetValue() :
504             self.fbb.Enable(True)
505         else :
506             self.fbb.Enable(False)
507
508     def OnValid(self, event):
509         parent = self.parent
510         if self.m_radioBox1.GetSelection() == 0 : valsound = 'true'
511         else :  valsound = 'false'
512         parent.pref.set('iramuteq', 'sound', valsound)
513         if self.m_radioBox2.GetSelection() == 0 : valcheck = 'true'
514         else :  valcheck = 'false'
515         parent.pref.set('iramuteq', 'checkupdate', valcheck)
516         parent.pref.set('iramuteq', 'guilanguage', self.listlangues[self.langues.GetSelection()])
517         if sys.platform == 'win32' :
518             if self.m_checkBox1.GetValue() :
519                 parent.pref.set('iramuteq', 'R_mem', 'true')
520                 parent.pref.set('iramuteq', 'R_max_mem', str(self.m_spinCtrl1.GetValue()))
521             else :
522                 parent.pref.set('iramuteq', 'R_mem', 'false')
523         if self.check_svdc.GetValue() :
524             parent.pref.set('iramuteq', 'libsvdc', 'true')
525         else :
526             parent.pref.set('iramuteq', 'libsvdc', 'false')
527         parent.pref.set('iramuteq', 'libsvdc_path', self.fbb.GetValue())
528         self.parent.pref.set('iramuteq', 'rmirror', self.mirror_value.GetValue())
529         file = open(parent.ConfigPath['preferences'], 'w')
530         parent.pref.write(file)
531         file.close()
532         self.parent.PathPath.set('PATHS', 'rpath', self.Rpath_value.GetValue())
533         with open(self.parent.ConfigPath['path'], 'w') as f:
534             self.parent.PathPath.write(f)
535         self.Close()
536
537 class PrefGraph(wx.Dialog):
538     def __init__(self, parent, ID, paramgraph, title = '', size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE):
539         pre = wx.PreDialog()
540         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
541         pre.Create(parent, ID, title, pos, size, style)
542         self.PostCreate(pre)
543         self.parent = parent
544         self.paramgraph=paramgraph
545         self.labeltype = wx.StaticText(self, -1, _(u"Graphic type").decode('utf8'))
546         if self.paramgraph['clnb'] <= 3 :
547             choix = [u'2D', 'web 2D']
548         else :
549             choix=[u'2D' ,u'3D', 'web 2D', 'web 3D']
550         self.choicetype = wx.Choice(self, -1, (100,50), choices=choix)
551         self.label_format = wx.StaticText(self, -1, _(u"Picture format").decode('utf8'))
552         self.choix_format =  wx.Choice(self, -1, (100,50), choices = ['png', 'svg'])        
553         self.label_1 = wx.StaticText(self, -1, _(u"width").decode('utf8'))
554         self.spin1 = wx.SpinCtrl(self, -1, '',size = (100,30), min=100, max=5000)
555         self.label_2 = wx.StaticText(self, -1, _(u"height").decode('utf8'))
556         self.spin2 = wx.SpinCtrl(self, -1, '', size = (100,30), min=100, max=5000)
557         self.label_what = wx.StaticText(self, -1, _(u"Representation").decode('utf8'))
558         self.choice1 = wx.Choice(self, -1, (100,50), choices=[_(u"coordinates").decode('utf8'),_(u"correlations").decode('utf8')])
559         self.label_qui = wx.StaticText(self, -1, u'Variables')
560         self.choice2 = wx.Choice(self, -1, (100,50), choices=[_(u"actives").decode('utf8') ,_(u"supplementaries").decode('utf8'), _(u"stars").decode('utf8'), _(u"clusters").decode('utf8')])
561         self.label_3 = wx.StaticText(self, -1, _(u"Text size").decode('utf8'))
562         self.spin3 = wx.SpinCtrl(self, -1, '', size = (100,30), min=1, max=20)
563         txt = _(u"Take the x first points").decode('utf8')
564         self.label_4 = wx.StaticText(self, -1, txt)
565         self.check1 = wx.CheckBox(self, -1)
566         self.spin_nb = wx.SpinCtrl(self, -1, '', size = (100,30), min=2, max=1000)
567         txt = _(u"Take the x first points by cluster").decode('utf8')
568         self.label_chic = wx.StaticText(self, -1, txt)
569         self.check_chic = wx.CheckBox(self, -1)
570         self.spin_nbchic = wx.SpinCtrl(self, -1, '', size = (100,30), min=2, max=1000)        
571         txt = _(u"Limit points by cluster chi2").decode('utf8')
572         self.label_5 = wx.StaticText(self, -1, txt)
573         self.check2 = wx.CheckBox(self, -1)
574         self.spin_chi = wx.SpinCtrl(self, -1, '',size = (100,30),  min=2, max=1000)
575         self.label_6 = wx.StaticText(self, -1, _(u"Avoid overlay").decode('utf8'))
576         self.check3 = wx.CheckBox(self, -1)
577         txt = _(u"Text size proportional to frequency").decode('utf8')
578         self.label_7 = wx.StaticText(self, -1, txt)
579         self.check4 = wx.CheckBox(self, -1)
580         self.label_min = wx.StaticText(self, -1, 'min')
581         self.spin_min = wx.SpinCtrl(self, -1, '',size = (100,30), min = 1, max = 100)
582         self.label_max = wx.StaticText(self, -1, 'max')
583         self.spin_max = wx.SpinCtrl(self, -1, '',size = (100,30), min = 1, max = 100)
584         txt = _(u"Text size proportional to chi2").decode('utf8')
585         self.label_tchi = wx.StaticText(self, -1, txt)
586         self.check_tchi = wx.CheckBox(self, -1)
587         self.label_min_tchi = wx.StaticText(self, -1, 'min')
588         self.spin_min_tchi = wx.SpinCtrl(self, -1, '', size = (100,30), min = 1, max = 100)
589         self.label_max_tchi = wx.StaticText(self, -1, 'max')
590         self.spin_max_tchi = wx.SpinCtrl(self, -1, '', size = (100,30), min = 1, max = 100)
591         self.label_8 = wx.StaticText(self, -1, _(u"Factor x : ").decode('utf8'))
592         self.spin_f1 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=self.paramgraph['clnb']-1)
593         self.label_9 = wx.StaticText(self, -1, _(u"Factor y : ").decode('utf8'))
594         self.spin_f2 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=self.paramgraph['clnb']-1)
595         self.label_f3 = wx.StaticText(self, -1, _(u"Factor z : ").decode('utf8'))
596         self.spin_f3 = wx.SpinCtrl(self, -1, '',size = (100,30), min=1, max=self.paramgraph['clnb']-1)
597         self.label_sphere = wx.StaticText(self, -1, _(u"Spheres transparency").decode('utf8'))
598         self.slider_sphere = wx.Slider(self, -1, 10, 1, 100, size = (255,-1), style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
599
600         self.label_film = wx.StaticText(self, -1, _(u"Make a movie").decode('utf8'))
601         self.film = wx.CheckBox(self, -1)
602                
603         self.btnsizer = wx.StdDialogButtonSizer()
604         if wx.Platform != "__WXMSW__":
605             btn = wx.ContextHelpButton(self)
606             self.btnsizer.AddButton(btn)
607         btn = wx.Button(self, wx.ID_OK)
608         btn.SetDefault()
609         self.btnsizer.AddButton(btn)
610         btn = wx.Button(self, wx.ID_CANCEL)
611         self.btnsizer.AddButton(btn)
612         self.btnsizer.Realize()
613         
614         self.Bind(wx.EVT_CHECKBOX, self.OnCheck1, self.check1)
615         self.Bind(wx.EVT_CHECKBOX, self.OnCheck2, self.check2)
616         self.Bind(wx.EVT_CHECKBOX, self.OnNorm, self.check4)
617         self.Bind(wx.EVT_CHECKBOX, self.OnCheckTchi, self.check_tchi)
618         self.Bind(wx.EVT_CHOICE, self.On3D, self.choicetype)
619         self.Bind(wx.EVT_CHOICE, self.OnPass, self.choice2)
620         self.Bind(wx.EVT_CHECKBOX, self.OnCheckChic, self.check_chic)
621         self.__set_properties()
622         self.OnNorm(wx.EVT_CHECKBOX)
623         self.OnCheckTchi(wx.EVT_CHECKBOX)
624         self.__do_layout()
625
626     def __set_properties(self):
627         self.choicetype.SetSelection(self.paramgraph['typegraph'])
628         if self.paramgraph['typegraph'] == 0  or self.paramgraph['typegraph'] == 2:
629             self.film.Enable(False)
630             self.spin_f3.Enable(False)
631             self.slider_sphere.Enable(False)
632         self.choix_format.SetSelection(self.paramgraph['svg'])
633         self.choice1.SetSelection(self.paramgraph['what'])
634         self.choice2.SetSelection(self.paramgraph['qui'])
635         self.spin_chi.SetValue(self.paramgraph['select_nb'])
636         self.spin_nb.SetValue(self.paramgraph['select_chi'])
637         self.spin1.SetValue(self.paramgraph['width'])
638         self.spin2.SetValue(self.paramgraph['height'])
639         self.spin3.SetValue(self.paramgraph['taillecar'])
640         self.spin_nb.SetValue(self.paramgraph['select_nb'])
641         self.spin_chi.SetValue(self.paramgraph['select_chi'])
642         self.spin_nbchic.SetValue(self.paramgraph['nbchic'])
643         self.check1.SetValue(self.paramgraph['do_select_nb'])
644         self.check2.SetValue(self.paramgraph['do_select_chi'])
645         self.check_chic.SetValue(self.paramgraph['do_select_chi_classe'])
646         self.check3.SetValue(self.paramgraph['over'])
647         if self.paramgraph['do_select_nb'] :
648             self.spin_nb.Enable(True)
649             self.spin_chi.Enable(False)
650             self.spin_nbchic.Enable(False)
651         elif self.paramgraph['do_select_chi_classe'] :
652             self.spin_nb.Enable(False)
653             self.spin_chi.Enable(False)
654             self.spin_nbchic.Enable(True)
655         elif self.paramgraph['do_select_chi'] :
656             self.spin_nb.Enable(False)
657             self.spin_chi.Enable(True)
658             self.spin_nbchic.Enable(False)
659         else :
660             self.spin_nb.Enable(False)
661             self.spin_chi.Enable(False)
662             self.spin_nbchic.Enable(False)
663
664             
665         self.check4.SetValue(self.paramgraph['cex_txt'])
666         self.spin_min.SetValue(self.paramgraph['txt_min'])
667         self.spin_max.SetValue(self.paramgraph['txt_max'])
668         self.check_tchi.SetValue(self.paramgraph['tchi'])
669         self.spin_min_tchi.SetValue(self.paramgraph['tchi_min'])
670         self.spin_max_tchi.SetValue(self.paramgraph['tchi_max'])
671
672         self.spin_f1.SetValue(self.paramgraph['facteur'][0])
673         self.spin_f2.SetValue(self.paramgraph['facteur'][1])
674         self.spin_f3.SetValue(self.paramgraph['facteur'][2])
675         self.slider_sphere.SetValue(self.paramgraph['alpha'])
676
677     def __do_layout(self):
678         sizer_2 = wx.BoxSizer(wx.VERTICAL)
679         fsizer = wx.FlexGridSizer(0,2,0,5)
680         grid_min = wx.FlexGridSizer(0, 2, 0, 0)
681         grid_max = wx.FlexGridSizer(0, 2, 0, 0)
682         grid_minmax = wx.FlexGridSizer(0, 2, 0, 0)
683         grid_min_tchi = wx.FlexGridSizer(0, 2, 0, 0)
684         grid_max_tchi = wx.FlexGridSizer(0, 2, 0, 0)
685         grid_minmax_tchi = wx.FlexGridSizer(0, 2, 0, 0)
686
687         sizer_3 = wx.BoxSizer(wx.VERTICAL)
688         
689         fsizer.Add(self.labeltype, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
690         fsizer.Add(self.choicetype, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
691         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
692         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
693
694         fsizer.Add(self.label_format, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
695         fsizer.Add(self.choix_format, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
696         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
697         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
698
699         fsizer.Add(self.label_what, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
700         fsizer.Add(self.choice1, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
701         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
702         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
703         
704         fsizer.Add(self.label_qui, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
705         fsizer.Add(self.choice2, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
706         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
707         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)              
708         
709         sizer_h1 = wx.BoxSizer(wx.HORIZONTAL)
710         sizer_h1.Add(self.label_1, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
711         sizer_h1.Add(self.spin1, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
712         fsizer.Add(sizer_h1, 0, wx.ALL, 5)
713         sizer_h2 = wx.BoxSizer(wx.HORIZONTAL)
714         sizer_h2.Add(self.label_2, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
715         sizer_h2.Add(self.spin2, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
716         fsizer.Add(sizer_h2, 0, wx.ALL, 5)
717         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
718         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
719         
720         fsizer.Add(self.label_3, 0, wx.ALL | wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
721         fsizer.Add(self.spin3, 0, wx.ALL | wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)        
722         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
723         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
724         
725         fsizer.Add(self.label_4, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
726         sizer_nb = wx.BoxSizer(wx.HORIZONTAL)
727         sizer_nb.Add(self.check1, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
728         sizer_nb.Add(self.spin_nb, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
729         fsizer.Add(sizer_nb, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
730         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
731         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
732         
733         fsizer.Add(self.label_chic, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
734         sizer_nbchic = wx.BoxSizer(wx.HORIZONTAL)
735         sizer_nbchic.Add(self.check_chic, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
736         sizer_nbchic.Add(self.spin_nbchic, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
737         fsizer.Add(sizer_nbchic, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
738         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
739         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
740
741         fsizer.Add(self.label_5, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
742         sizer_chi = wx.BoxSizer(wx.HORIZONTAL)
743         sizer_chi.Add(self.check2, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
744         sizer_chi.Add(self.spin_chi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
745         fsizer.Add(sizer_chi, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
746         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
747         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
748         
749         fsizer.Add(self.label_6, 0,  wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL| wx.ADJUST_MINSIZE, 5)
750         fsizer.Add(self.check3, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 5)
751         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
752         fsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 
753         
754         sizer_2.Add(fsizer, 0, wx.EXPAND, 0)
755         
756         bsizer_1 = wx.FlexGridSizer(0,3,0,0)
757         bsizer_1.Add(self.label_7, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
758         bsizer_1.Add(self.check4, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5)
759         grid_min.Add(self.label_min, 0,wx.ALL |  wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
760         grid_min.Add(self.spin_min, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
761         grid_max.Add(self.label_max, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
762         grid_max.Add(self.spin_max, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
763         grid_minmax.Add(grid_min, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
764         grid_minmax.Add(grid_max, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
765
766         bsizer_1.Add(grid_minmax, 0, wx.ALL, 5)
767
768         bsizer_1.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
769         bsizer_1.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 
770         bsizer_1.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)        
771
772         bsizer_1.Add(self.label_tchi, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
773         bsizer_1.Add(self.check_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5)
774         grid_min_tchi.Add(self.label_min_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
775         grid_min_tchi.Add(self.spin_min_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
776         grid_max_tchi.Add(self.label_max_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
777         grid_max_tchi.Add(self.spin_max_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
778         grid_minmax_tchi.Add(grid_min_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
779         grid_minmax_tchi.Add(grid_max_tchi, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
780         
781         bsizer_1.Add(grid_minmax_tchi, 0,  wx.ALL, 5)
782         sizer_2.Add(bsizer_1, 0, wx.EXPAND, 5)
783         
784         sizer_2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 
785         
786         sizer_f = wx.BoxSizer(wx.HORIZONTAL)
787         sizer_f.Add(self.label_8, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
788         sizer_f.Add(self.spin_f1, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
789         
790         sizer_f.Add(self.label_9, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
791         sizer_f.Add(self.spin_f2, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
792
793         sizer_f.Add(self.label_f3, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
794         sizer_f.Add(self.spin_f3, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
795         sizer_2.Add(sizer_f, 0, wx.EXPAND, 5)
796         
797         sizer_2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 5)
798         
799         fsizer2 = wx.FlexGridSizer(0,2,0,0)
800         fsizer2.Add(self.label_sphere, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
801         fsizer2.Add(self.slider_sphere, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
802         fsizer2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
803         fsizer2.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
804
805         fsizer2.Add(self.label_film, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
806         fsizer2.Add(self.film, 0, wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
807         sizer_2.Add(fsizer2, 0, wx.EXPAND, 5)
808         sizer_2.Add(self.btnsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 5)
809         self.SetSizer(sizer_2)
810         sizer_2.Fit(self)
811         self.Layout()
812         
813     def OnCheck1(self, event):
814         if self.check1.GetValue() :
815             self.check2.SetValue(False)
816             self.check_chic.SetValue(False)
817             self.spin_chi.Enable(False)
818             self.spin_nb.Enable(True)
819             self.spin_nbchic.Enable(False)
820         else : 
821             self.spin_nb.Enable(False)
822             
823     def OnCheck2(self, event):
824         if self.check2.GetValue() :
825             self.check1.SetValue(False)
826             self.check_chic.SetValue(False)
827             self.spin_chi.Enable(True)
828             self.spin_nb.Enable(False)
829             self.spin_nbchic.Enable(False)
830         else :
831             self.spin_chi.Enable(False) 
832
833     def OnCheckChic(self, event) :
834         if self.check_chic.GetValue() :
835             self.check1.SetValue(False)
836             self.check2.SetValue(False)
837             self.spin_chi.Enable(False)
838             self.spin_nb.Enable(False)
839             self.spin_nbchic.Enable(True)
840         else :
841             self.spin_nbchic.Enable(False)
842
843     def OnNorm(self, event):
844         if not self.check4.GetValue() :
845             self.spin_min.Disable()
846             self.spin_max.Disable()
847         else :
848             self.spin_min.Enable(True)
849             self.spin_max.Enable(True)
850             self.check_tchi.SetValue(False)
851             self.OnCheckTchi(wx.EVT_CHECKBOX)
852
853     def OnCheckTchi(self, evt) :
854         if not self.check_tchi.GetValue() :
855             self.spin_min_tchi.Disable()
856             self.spin_max_tchi.Disable()
857         else :
858             self.spin_min_tchi.Enable(True)
859             self.spin_max_tchi.Enable(True)
860             self.check4.SetValue(False)
861             self.OnNorm(wx.EVT_CHECKBOX)
862
863     def On3D(self, event) :
864         if event.GetString() == u'3D' :
865             self.film.Enable(True)
866             self.spin_f3.Enable(True)
867             self.slider_sphere.Enable(True)
868         else :
869             self.film.Enable(False)
870             self.spin_f3.Enable(False)
871             self.slider_sphere.Enable(False)
872     
873     def OnPass(self,evt) :
874         if evt.GetString() == _(u"clusters").decode('utf8') :
875             self.check4.SetValue(False)
876             self.check4.Enable(False)
877             self.OnNorm(wx.EVT_CHECKBOX)
878         else :
879             self.check4.Enable()
880             
881
882 class SelectColDial ( wx.Dialog ):
883     
884     def __init__( self, parent ):
885         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 )
886         
887         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
888         
889         self.bSizer2 = wx.BoxSizer( wx.VERTICAL )
890         
891         #self.m_checkList2 = wx.CheckListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ['r','t','y'], 0 ) 
892         #bSizer2.Add( self.m_checkList2, 2, wx.ALL|wx.EXPAND, 5 )
893         
894         self.m_sdbSizer2 = wx.StdDialogButtonSizer()
895         self.m_sdbSizer2OK = wx.Button( self, wx.ID_CANCEL)
896         self.butok = wx.Button( self, wx.ID_OK)
897         #m_sdbSizer2.AddButton( self.m_sdbSizer2OK )
898         #self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL )
899         #m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel )
900         #m_sdbSizer2.Realize();
901         #self.bSizer2.Add( m_sdbSizer2, 0, wx.EXPAND, 5 )
902         
903         self.SetSizer( self.bSizer2 )
904         self.Layout()
905         
906         self.Centre( wx.BOTH )
907     
908     def __del__( self ):
909         pass
910
911 class PrefExport(wx.Dialog):
912     def __init__(self, parent, *args, **kwds):
913         kwds['style'] = wx.OK|wx.DEFAULT_DIALOG_STYLE 
914         wx.Dialog.__init__(self, *args, **kwds)
915         self.fileout = ""
916         self.parent = parent
917         sizer = wx.BoxSizer(wx.VERTICAL)
918         box = wx.BoxSizer(wx.HORIZONTAL)
919         box3 = wx.BoxSizer(wx.HORIZONTAL)
920         self.label_lem = wx.StaticText(self, -1, _(u"Lemmatised corpus").decode('utf8'))
921         box3.Add(self.label_lem, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
922         self.radio_lem = wx.RadioBox(self, -1, u"", choices= [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
923         box3.Add(self.radio_lem, 0, wx.ALIGN_RIGHT, 5)
924         sizer.Add(box3, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
925         self.label_txt = wx.StaticText(self, -1, _(u"Export for ...").decode('utf8'))
926         box.Add(self.label_txt, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
927         self.radio_type = wx.RadioBox(self, -1, u"", choices=['IRaMuTeQ/ALCESTE', 'Lexico'], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
928         box.Add(self.radio_type, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
929         sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
930         box2 = wx.BoxSizer(wx.HORIZONTAL)
931         self.txt2 = wx.StaticText(self, -1, _(u"Output file").decode('utf8'))
932         box2.Add(self.txt2, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
933         self.fbb = filebrowse.FileBrowseButton(self, -1, size=(450, -1), fileMode = 2)
934         box2.Add(self.fbb, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
935         self.fbb.SetLabel("")
936         sizer.Add(box2, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
937
938         btnsizer = wx.StdDialogButtonSizer()
939         btn = wx.Button(self, wx.ID_CANCEL)
940         btnsizer.AddButton(btn)
941         btn_ok = wx.Button(self, wx.ID_OK)
942         btn_ok.SetDefault()
943         btnsizer.AddButton(btn_ok)
944         btnsizer.Realize()
945         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT, 5)
946         self.Bind(wx.EVT_BUTTON, self.check_file, btn_ok)
947         self.SetSizer(sizer)
948         sizer.Fit(self)        
949
950     def check_file(self, evt) :
951         if evt.GetId() == wx.ID_OK :
952             if os.path.exists(self.fbb.GetValue()):
953                 dlg = wx.MessageDialog(self, '\n'.join([u"%s" % self.fbb.GetValue(), _(u"This file already exists. Continue anyway ?").decode('utf8')]), _(u"Attention").decode('utf8'), wx.NO | wx.YES | wx.ICON_WARNING)
954                 dlg.CenterOnParent()
955                 if dlg.ShowModal() not in [wx.ID_NO, wx.ID_CANCEL]:
956                     self.EndModal(wx.ID_OK)
957             else :
958                 self.EndModal(wx.ID_OK)
959         else :
960             self.EndModal(wx.ID_CANCEL)
961
962 class PrefProfTypes(wx.Dialog):
963     def __init__(self, parent, *args, **kwds):
964         kwds['style'] = wx.OK|wx.DEFAULT_DIALOG_STYLE 
965         wx.Dialog.__init__(self, parent, *args, **kwds)
966         self.fileout = ""
967         self.parent = parent
968         sizer = wx.BoxSizer(wx.VERTICAL)
969         box = wx.BoxSizer(wx.HORIZONTAL)
970         box3 = wx.BoxSizer(wx.HORIZONTAL)
971         self.label_txt = wx.StaticText(self, -1, _(u"Settings").decode('utf8'))
972         box.Add(self.label_txt, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
973         self.radio_type = wx.RadioBox(self, -1, u"", choices=[_(u"Like ALCESTE").decode('utf8'), _(u"Like Lexico").decode('utf8')], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
974         box.Add(self.radio_type, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
975         sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
976         box2 = wx.BoxSizer(wx.HORIZONTAL)
977         self.txt2 = wx.StaticText(self, -1, _(u"Output file").decode('utf8'))
978         box2.Add(self.txt2, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
979         self.fbb = filebrowse.FileBrowseButton(self, -1, size=(450, -1), fileMode = 2)
980         box2.Add(self.fbb, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
981         self.fbb.SetLabel("")
982         sizer.Add(box2, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
983
984         btnsizer = wx.StdDialogButtonSizer()
985         btn = wx.Button(self, wx.ID_CANCEL)
986         btnsizer.AddButton(btn)
987         btn_ok = wx.Button(self, wx.ID_OK)
988         btn_ok.SetDefault()
989         btnsizer.AddButton(btn_ok)
990         btnsizer.Realize()
991         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT, 5)
992         #self.Bind(wx.EVT_BUTTON, self.check_file, btn_ok)
993         self.SetSizer(sizer)
994         sizer.Fit(self)
995
996 class PrefSimpleFile(wx.Dialog):
997     def __init__(self, parent, *args, **kwds):
998         kwds['style'] = wx.OK|wx.DEFAULT_DIALOG_STYLE 
999         if 'mask' in kwds :
1000             self.mask = kwds['mask']
1001             del(kwds['mask'])
1002         else : self.mask = '*.*'
1003         wx.Dialog.__init__(self, *args, **kwds)
1004         self.fileout = ""
1005         self.parent = parent
1006         sizer = wx.BoxSizer(wx.VERTICAL)
1007         box2 = wx.BoxSizer(wx.HORIZONTAL)
1008         self.txt2 = wx.StaticText(self, -1, _(u"Output file").decode('utf8'))
1009         box2.Add(self.txt2, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
1010         self.fbb = filebrowse.FileBrowseButton(self, -1, size=(450, -1), fileMode = 2, fileMask = self.mask)
1011         box2.Add(self.fbb, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
1012         self.fbb.SetLabel("")
1013         sizer.Add(box2, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
1014
1015         btnsizer = wx.StdDialogButtonSizer()
1016         btn = wx.Button(self, wx.ID_CANCEL)
1017         btnsizer.AddButton(btn)
1018         btn_ok = wx.Button(self, wx.ID_OK)
1019         btn_ok.SetDefault()
1020         btnsizer.AddButton(btn_ok)
1021         btnsizer.Realize()
1022         sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT, 5)
1023         self.Bind(wx.EVT_BUTTON, self.check_file, btn_ok)
1024         self.SetSizer(sizer)
1025         sizer.Fit(self)        
1026
1027     def check_file(self, evt) :
1028         if evt.GetId() == wx.ID_OK :
1029             if os.path.exists(self.fbb.GetValue()):
1030                 dlg = wx.MessageDialog(self, '\n'.join([u"%s" % self.fbb.GetValue(), _(u"This file already exists. Continue anyway ?").decode('utf8')]), _(u"Attention").decode('utf8'), wx.NO | wx.YES | wx.ICON_WARNING)
1031                 dlg.CenterOnParent()
1032                 if dlg.ShowModal() not in [wx.ID_NO, wx.ID_CANCEL]:
1033                     self.EndModal(wx.ID_OK)
1034             else :
1035                 self.EndModal(wx.ID_OK)
1036         else :
1037             self.EndModal(wx.ID_CANCEL)
1038
1039 class StatDialog ( wx.Dialog ):
1040     
1041     def __init__( self, parent, keys ):
1042         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.DEFAULT_DIALOG_STYLE )
1043         
1044         self.fileout = ""
1045         self.parent = parent
1046         self.keys = keys
1047         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1048         
1049         bSizer1 = wx.BoxSizer( wx.VERTICAL )
1050         
1051         gSizer1 = wx.GridSizer( 0, 2, 0, 0 )
1052         
1053         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Lemmatization").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1054         self.m_staticText1.Wrap( -1 )
1055         gSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL, 1 )
1056         
1057         radio_lemChoices = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
1058         self.radio_lem = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, radio_lemChoices, 1, wx.RA_SPECIFY_COLS )
1059         self.radio_lem.SetSelection( 0 )
1060         gSizer1.Add( self.radio_lem, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 1 )
1061         
1062         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Keys properties").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1063         self.m_staticText2.Wrap( -1 )
1064         gSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL, 1 )
1065         
1066         self.button_5 = wx.Button( self, wx.ID_PREFERENCES, _(u"properties").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1067         gSizer1.Add( self.button_5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 1 )
1068         
1069         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Dictionary").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1070         self.m_staticText3.Wrap( -1 )
1071         gSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL, 1 )
1072         
1073         radio_dictchoiceChoices = [ _(u"indexation").decode('utf8'), _(u"other").decode('utf8') ]
1074         self.radio_dictchoice = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, radio_dictchoiceChoices, 1, wx.RA_SPECIFY_COLS )
1075         self.radio_dictchoice.SetSelection( 0 )
1076         gSizer1.Add( self.radio_dictchoice, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 1 )
1077         
1078         
1079         bSizer1.Add( gSizer1, 1, wx.EXPAND, 1 )
1080         
1081         self.dictpath = filebrowse.FileBrowseButton(self, -1, size=(350, -1),  labelText = _(u"Path").decode('utf8'), fileMode = 2, fileMask = '*')
1082         bSizer1.Add( self.dictpath, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 1 )
1083         self.dictpath.Enable(False)
1084
1085         m_sdbSizer1 = wx.StdDialogButtonSizer()
1086         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
1087         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
1088         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
1089         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
1090         m_sdbSizer1.Realize();
1091         
1092         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 0 )
1093         
1094         
1095         self.SetSizer( bSizer1 )
1096         self.Layout()
1097         bSizer1.Fit( self )
1098         
1099         self.Centre( wx.BOTH )
1100         
1101         # Connect Events
1102         self.button_5.Bind( wx.EVT_BUTTON, self.OnKeys )
1103         self.radio_dictchoice.Bind( wx.EVT_RADIOBOX, self.OnOther )
1104     
1105     def __del__( self ):
1106         pass
1107     
1108     
1109     # Virtual event handlers, overide them in your derived class
1110     def OnKeys( self, event ):
1111         dial = AlcOptFrame(self, self.parent)
1112         dial.CenterOnParent()
1113         dial.ShowModal()
1114         for i in range(0,len(dial.listlabel)):
1115             dial.keys[dial.listcle[i]] = dial.listspin[i].GetValue()
1116         DoConf().makeoptions(['KEY'], [dial.keys], outfile = self.parent.ConfigPath['key'])
1117         dial.Destroy()
1118     
1119     def OnOther( self, event ):
1120         if self.radio_dictchoice.GetSelection() :
1121             self.dictpath.Enable(True)
1122         else :
1123             self.dictpath.Enable(False)
1124
1125 # class StatDialog(wx.Dialog):
1126 #     def __init__(self, parent, *args, **kwds):
1127 #         kwds['style'] = wx.DEFAULT_DIALOG_STYLE 
1128 #         wx.Dialog.__init__(self, *args, **kwds)
1129 #         self.fileout = ""
1130 #         self.parent = parent
1131 #         self.label_lem = wx.StaticText(self, -1, _(u"Lemmatization").decode('utf8'))
1132 #         self.radio_lem = wx.RadioBox(self, -1, u"", choices=[_(u'oui').decode('utf8'), _(u'non').decode('utf8')], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
1133 #         #txt = u"""Fréquence minimum d'une forme
1134 # #analysée (0 = non utilisé)"""
1135 #         #self.label_8 = wx.StaticText(self, -1, txt)
1136 #         #self.spin_ctrl_5 = wx.SpinCtrl(self, -1, "",size = (100,30), min=0, max=1000, initial=0)
1137 #         #self.label_max_actives =  wx.StaticText(self, -1, u"Nombre maximum de formes analysées")
1138 #         #self.spin_max_actives = wx.SpinCtrl(self, -1, "",size = (100,30), min=20, max=10000, initial=1500)
1139 #         self.label_4 = wx.StaticText(self, -1, _(u"Keys settings").decode('utf8'))
1140 #         self.button_5 = wx.Button(self, wx.ID_PREFERENCES, "")
1141 #         self.labeldictchoice = wx.StaticText(self, -1, _(u"Dictionary").decode('utf8'))
1142 #         self.radio_dictchoice = wx.RadioBox(self, -1, u"", choices=[_(u'indexation').decode('utf8'), _(u'other').decode('utf8')], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
1143 #         #self.labeldictpath = wx.StaticText(self, -1, _(u"Path").decode('utf8'))
1144 #         self.dictpath = filebrowse.FileBrowseButton(self, -1, size=(350, -1),  labelText = _(u"Path").decode('utf8'), fileMode = 2, fileMask = '*')
1145 #         self.dictpath.Enable(False)
1146 #         #self.Bind(wx.EVT_CHECKBOX, self.OnCheckUce, self.check_uce)
1147 #         #self.Bind(wx.EVT_SPINCTRL, self.OnSpin, self.spin_ctrl_5)
1148 #         self.Bind(wx.EVT_BUTTON, self.OnKeys, self.button_5)
1149 #         self.Bind(wx.EVT_RADIOBOX, self.OnOther, self.radio_dictchoice)
1150 #         self.__do_layout()
1151 #         self.__set_properties()
1152
1153 #     def __do_layout(self) :
1154 #         first = wx.BoxSizer(wx.VERTICAL)
1155 #         sizer = wx.FlexGridSizer(0,2,0,0)
1156 #         sizer.Add(self.label_lem, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1157 #         sizer.Add(self.radio_lem, 0, wx.ALIGN_LEFT, 5)
1158 #         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1159 #         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1160 #         #sizer.Add(self.txt_exp, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1161 #         #sizer.Add(self.exp, 0, wx.ALIGN_RIGHT, 5)
1162 #         #sizer.Add(self.label_uce, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1163 #         #sizer.Add(self.check_uce, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1164 #         #sizer.Add(self.label_occuce, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1165 #         #sizer.Add(self.spin_ctrl_4, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1166 #         #sizer.Add(self.label_8, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1167 #         #sizer.Add(self.spin_ctrl_5, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1168 #         #sizer.Add(self.label_max_actives, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1169 #         #sizer.Add(self.spin_max_actives, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1170 #         sizer.Add(self.label_4, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1171 #         sizer.Add(self.button_5, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1172 #         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1173 #         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1174 #         sizer.Add(self.labeldictchoice, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1175 #         sizer.Add(self.radio_dictchoice, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1176 #         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1177 #         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1178 #         #sizer.Add(self.labeldictpath, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1179 #         sizer.Add(self.dictpath, 0,  wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1180 #         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)
1181 #         sizer.Add(wx.StaticLine(self),0, wx.ALIGN_LEFT, 5)      
1182 #         #sizer.Add(box2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, 5)
1183 #         first.Add(sizer, 0, wx.ALL, 5)
1184 #         btnsizer = wx.StdDialogButtonSizer()
1185 #         btn = wx.Button(self, wx.ID_CANCEL)
1186 #         btnsizer.AddButton(btn)
1187 #         btn_ok = wx.Button(self, wx.ID_OK)
1188 #         btn_ok.SetDefault()
1189 #         btnsizer.AddButton(btn_ok)
1190 #         btnsizer.Realize()
1191 #         first.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, 5)
1192 #         self.SetSizer(first)
1193 #         first.Fit(self)
1194
1195 #     def __set_properties(self) :
1196 #         self.SetTitle(_(u"Settings").decode('utf8'))
1197
1198 #     def OnKeys(self, evt):
1199 #         dial = AlcOptFrame(self, self.parent.parent)
1200 #         dial.CenterOnParent()
1201 #         dial.ShowModal()
1202 #         for i in range(0,len(dial.listlabel)):
1203 #             dial.keys[dial.listcle[i]] = dial.listspin[i].GetValue()
1204 #         DoConf().makeoptions(['KEY'], [dial.keys], outfile = self.parent.parent.ConfigPath['key'])
1205 #         dial.Destroy()
1206 #     
1207 #     def OnOther(self, evt):
1208 #         if self.radio_dictchoice.GetSelection() :
1209 #             self.dictpath.Enable(True)
1210 #         else :
1211 #             self.dictpath.Enable(False)
1212
1213 class PrefUCECarac(wx.Dialog):
1214     def __init__(self, parent, *args, **kwds):
1215         kwds['style'] = wx.DEFAULT_DIALOG_STYLE 
1216         kwds['title'] = _(u"Characteristic text segments").decode('utf8')
1217         wx.Dialog.__init__(self, *args, **kwds)
1218         self.parent = parent
1219         first = wx.BoxSizer(wx.VERTICAL)
1220         sizer = wx.FlexGridSizer(0,2,0,0)
1221         self.label_type = wx.StaticText(self, -1, _(u"Ranking score").decode('utf8'))
1222         sizer.Add(self.label_type, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, 5)
1223         self.radio_type = wx.RadioBox(self, -1, u"", choices=[_(u"absolute (sum of chi2 of marked forms in segment)").decode('utf8'), _(u"relative (mean of chi2 of marked forms in segment)").decode('utf8')], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
1224         sizer.Add(self.radio_type, 0, wx.ALIGN_RIGHT, 5)
1225         self.txt_eff = wx.StaticText(self, -1, _(u"Maximum number of text segments").decode('utf8'))
1226         sizer.Add(self.txt_eff, 0, wx.ALIGN_CENTRE, 5)
1227         self.spin_eff = wx.SpinCtrl(self, -1, '', size = (100, 30), min = 1, max = 100000, initial = 50)
1228         self.spin_eff.SetValue(50)
1229         sizer.Add(self.spin_eff, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
1230         first.Add(sizer, 0, wx.ALL, 5)
1231         btnsizer = wx.StdDialogButtonSizer()
1232         btn = wx.Button(self, wx.ID_CANCEL)
1233         btnsizer.AddButton(btn)
1234         btn_ok = wx.Button(self, wx.ID_OK)
1235         btn_ok.SetDefault()
1236         btnsizer.AddButton(btn_ok)
1237         btnsizer.Realize()
1238         first.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, 5)
1239         self.SetSizer(first)
1240         first.Fit(self)
1241
1242 class PrefSegProf(wx.Dialog) :
1243     def __init__( self, parent ):
1244         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Repeated segments profiles").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
1245         
1246         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1247         bSizer1 = wx.BoxSizer( wx.VERTICAL )
1248         txt = _(u"Be carefull : computation of repeated segments profiles can be very long on large corpus").decode('utf8')
1249         self.label = wx.StaticText( self, wx.ID_ANY, txt, wx.DefaultPosition, wx.DefaultSize, 0 ) 
1250         bSizer1.Add( self.label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5 )
1251
1252         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
1253         fgSizer1.SetFlexibleDirection( wx.BOTH )
1254         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1255         
1256         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Lemmatised corpus").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1257         self.m_staticText1.Wrap( -1 )
1258         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1259         
1260         box_lemChoices = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
1261         self.box_lem = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, box_lemChoices, 1, wx.RA_SPECIFY_COLS )
1262         self.box_lem.SetSelection( 1 )
1263         fgSizer1.Add( self.box_lem, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1264         #self.box_lem.Enable(False)
1265         
1266         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Minimum size of segments").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1267         self.m_staticText3.Wrap( -1 )
1268         fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1269         
1270         self.spin_min = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (100,30), wx.SP_ARROW_KEYS, 2, 30, 2 )
1271         self.spin_min.SetValue(2)
1272         fgSizer1.Add( self.spin_min, 0, wx.ALL, 5 )
1273         
1274         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Maxmum size of segments").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1275         self.m_staticText4.Wrap( -1 )
1276         fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1277         
1278         self.spin_max = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (100,30), wx.SP_ARROW_KEYS, 2, 30, 10 )
1279         self.spin_max.SetValue(10)
1280         fgSizer1.Add( self.spin_max, 0, wx.ALL, 5 )
1281         
1282         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Minimum frequency of segments").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1283         self.m_staticText5.Wrap( -1 )
1284         fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1285         
1286         self.spin_eff = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, (100,30), wx.SP_ARROW_KEYS, 4, 1000, 4 )
1287         self.spin_eff.SetValue(4)
1288         fgSizer1.Add( self.spin_eff, 0, wx.ALL, 5 )
1289         
1290         bSizer1.Add( fgSizer1, 1, wx.EXPAND, 5 )
1291         btnsizer = wx.StdDialogButtonSizer()
1292         btn = wx.Button(self, wx.ID_CANCEL)
1293         btnsizer.AddButton(btn)
1294         btn_ok = wx.Button(self, wx.ID_OK)
1295         btn_ok.SetDefault()
1296         btnsizer.AddButton(btn_ok)
1297         btnsizer.Realize()
1298         bSizer1.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, 5)
1299
1300         self.SetSizer( bSizer1 )
1301         self.Layout()
1302         bSizer1.Fit( self )
1303         
1304         self.Centre( wx.BOTH )
1305
1306 class PrefQuestAlc ( wx.Dialog ):
1307     
1308     def __init__( self, parent, tableau, sim = False):
1309         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Clustering").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
1310         
1311         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1312         
1313         #---------------------------------------------------------------
1314         #self.content = parent.content[:]
1315         self.header = tableau.get_colnames()
1316         labels = [val for val in self.header]
1317         self.labels_tot = labels
1318         self.varsup = []
1319         self.sim = sim
1320         #---------------------------------------------------------------
1321         bSizer2 = wx.BoxSizer( wx.VERTICAL )
1322         
1323         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
1324         fgSizer1.SetFlexibleDirection( wx.BOTH )
1325         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1326
1327         if not self.sim :
1328             self.lab_format = wx.StaticText( self, wx.ID_ANY, _(u"Supplementary variables are marked with a *").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1329             self.lab_format.Wrap( -1 )
1330             fgSizer1.Add( self.lab_format, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1331         
1332             m_radioBox1Choices = [ _(u"yes").decode('utf8'), _(u"no").decode('utf8') ]
1333             self.m_radioBox1 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox1Choices, 1, wx.RA_SPECIFY_COLS )
1334             self.m_radioBox1.SetSelection( 0 )
1335             fgSizer1.Add( self.m_radioBox1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1336         
1337         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Actives variables (almost 3)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1338         self.m_staticText3.Wrap( -1 )
1339         fgSizer1.Add( self.m_staticText3, 0, wx.ALL, 5 )
1340         
1341         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Supplementaries variables (almost 1)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1342         self.m_staticText2.Wrap( -1 )
1343         fgSizer1.Add( self.m_staticText2, 0, wx.ALL, 5 )
1344         
1345         self.ListActive = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, labels,  wx.LB_EXTENDED )
1346         self.ListActive.SetMinSize( wx.Size( 300,250 ) )
1347         
1348         fgSizer1.Add( self.ListActive, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
1349         
1350         self.ListSup = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, labels, wx.LB_EXTENDED )
1351         self.ListSup.SetMinSize( wx.Size( 300,250 ) )
1352         
1353         fgSizer1.Add( self.ListSup, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
1354         
1355         self.but_suiv = wx.Button( self, wx.ID_ANY, _(u"Next").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1356         fgSizer1.Add( self.but_suiv, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1357         
1358         self.but_prec = wx.Button( self, wx.ID_ANY, _(u"Previous").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1359         fgSizer1.Add( self.but_prec, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1360         
1361         if not sim :
1362             self.lab_nbcl = wx.StaticText( self, wx.ID_ANY, _(u"Number of terminal clusters on phase 1").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1363             self.lab_nbcl.Wrap( -1 )
1364             fgSizer1.Add( self.lab_nbcl, 0, wx.ALL, 5 )
1365             
1366             self.spin_nbcl = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 2, 100, 10 )
1367             self.spin_nbcl.SetValue(10)
1368             self.spin_nbcl.SetMinSize( wx.Size( 100,30 ) )
1369             
1370             fgSizer1.Add( self.spin_nbcl, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1371             
1372             self.lab_mincl = wx.StaticText( self, wx.ID_ANY, _(u"Minimum text segments frenquency in clusters (2= automatic)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1373             self.lab_mincl.Wrap( -1 )
1374             fgSizer1.Add( self.lab_mincl, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1375             
1376             self.spin_mincl = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 2, 1000, 0 )
1377             self.spin_mincl.SetValue(2)
1378             self.spin_mincl.SetMinSize( wx.Size( 100,30 ) )
1379             
1380             fgSizer1.Add( self.spin_mincl, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1381             
1382         bSizer2.Add( fgSizer1, 1, wx.EXPAND, 5 )
1383         
1384         m_sdbSizer2 = wx.StdDialogButtonSizer()
1385         self.m_sdbSizer2OK = wx.Button( self, wx.ID_OK )
1386         m_sdbSizer2.AddButton( self.m_sdbSizer2OK )
1387         self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL )
1388         m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel )
1389         m_sdbSizer2.Realize();
1390         bSizer2.Add( m_sdbSizer2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1391         
1392         self.SetSizer( bSizer2 )
1393         self.Layout()
1394         bSizer2.Fit( self )
1395         
1396         self.Centre( wx.BOTH )
1397         
1398         if not self.sim :
1399             self.ListActive.Enable(False)
1400             self.ListSup.Enable(False)
1401             self.but_suiv.Enable(False)
1402             self.but_prec.Enable(False)
1403         else :
1404             self.ListSup.Enable(False)
1405             self.but_prec.Enable(False)
1406         
1407         # Connect Events
1408         if not self.sim :
1409             self.m_radioBox1.Bind( wx.EVT_RADIOBOX, self.onformat )
1410         self.but_suiv.Bind(wx.EVT_BUTTON, self.onsuivant)
1411         self.but_prec.Bind(wx.EVT_BUTTON, self.onprec)
1412         self.m_sdbSizer2OK.Bind(wx.EVT_BUTTON, self.onvalid)
1413
1414     def __del__( self ):
1415         pass
1416     
1417     # Virtual event handlers, overide them in your derived class
1418     def onformat( self, event ):
1419         if self.m_radioBox1.GetSelection() == 0 :
1420             self.ListActive.Enable(False)
1421             self.ListSup.Enable(False)
1422             self.but_suiv.Enable(False)
1423             self.m_sdbSizer2OK.Enable(True)
1424         else :
1425             self.ListActive.Enable(True)
1426             self.but_suiv.Enable(True)
1427             self.m_sdbSizer2OK.Enable(False)
1428         
1429     def onsuivant(self, evt) :
1430         actives = list(self.ListActive.GetSelections())
1431         actives.sort()
1432         if len(actives)>=3 and len(actives) != len(self.header) :
1433             self.hindices = []
1434             self.nactives = []
1435             compt = 0
1436             header = self.header[:]
1437             for i in range(0, len(header)):
1438                 self.hindices.append(i)
1439             for i in actives :
1440                 self.nactives.append(i)
1441                 header.pop(i - compt)
1442                 self.hindices.pop(i - compt)
1443                 compt += 1
1444             self.labels = [val for val in header]
1445             self.ListSup.Clear()
1446             for i in header :
1447                 self.ListSup.Append(i)
1448                         
1449             self.ListActive.Enable(False)    
1450             self.ListSup.Enable(True)
1451             self.but_suiv.Enable(False)
1452             self.but_prec.Enable(True)
1453             if not self.sim :
1454                 self.m_sdbSizer2OK.Enable(True)
1455
1456     def onprec(self, evt) :
1457         self.ListActive.Enable(True)    
1458         self.ListSup.Enable(False)
1459         self.but_suiv.Enable(True)
1460         self.but_prec.Enable(False)
1461         if not self.sim :
1462             self.m_sdbSizer2OK.Enable(False)
1463
1464     def onvalid(self, evt) :
1465         for i in self.ListSup.GetSelections() :
1466             self.varsup.append(self.hindices[i])
1467         if not self.sim :
1468             if len(self.varsup) >= 1 or self.m_radioBox1.GetSelection() == 0 :
1469                 evt.Skip()
1470         else :
1471             if len(self.varsup) >= 1 :
1472                 evt.Skip()
1473
1474 class FindInCluster(wx.Frame):
1475     def __init__(self, parent, id, result, style = wx.DEFAULT_FRAME_STYLE):
1476         # begin wxGlade: MyFrame.__init__
1477         wx.Frame.__init__(self, parent, id)
1478         self.spanel =  wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
1479         self.sizer1 = wx.FlexGridSizer(0,4,0,0)
1480         self.parent = parent
1481         self.formes = {}
1482         txt =  [_(u"form").decode('utf8'),_(u"cluster").decode('utf8'),_(u"Chi2").decode('utf8'), _(u"see").decode('utf8')]
1483         for val in txt :
1484             self.sizer1.Add( wx.StaticText(self.spanel, -1, val), 0, wx.ALL, 5)
1485         for val in txt :
1486             self.sizer1.Add(wx.StaticLine(self.spanel, -1), 0, wx.ALL, 5)
1487         for i,val in enumerate(result) :
1488             forme = val[0]
1489             cl = val[1]
1490             chi = val[2]
1491             pan = wx.Panel(self.spanel, -1, style=wx.SIMPLE_BORDER)
1492             siz = wx.BoxSizer(wx.VERTICAL)
1493             txt = wx.StaticText(pan, -1, forme)
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(cl))
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             pan = wx.Panel(self.spanel, -1, style=wx.SIMPLE_BORDER)
1504             siz = wx.BoxSizer(wx.VERTICAL)
1505             txt = wx.StaticText(pan, -1, str(chi))
1506             siz.Add(txt, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
1507             pan.SetSizer(siz)
1508             self.sizer1.Add(pan, 0, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5)
1509             idbut = wx.NewId()
1510             self.formes[idbut] = [forme, cl]
1511             but = wx.Button(self.spanel, idbut, u"voir")
1512             self.sizer1.Add(but, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
1513             self.Bind(wx.EVT_BUTTON, self.showitem, but)
1514         self.button_1 = wx.Button(self, -1, "Fermer")
1515         self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
1516         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
1517         self.__set_properties()
1518         self.__do_layout()
1519         # end wxGlade
1520     
1521     def __set_properties(self):
1522         self.SetTitle(_(u"Results").decode('utf8'))
1523         self.spanel.EnableScrolling(True,True)
1524         #self.panel_1.SetSize((1000,1000))
1525         self.spanel.SetScrollRate(20, 20)
1526         h = 60 * len(self.formes)
1527         if h > 600 :
1528             h = 600
1529         if h < 150 :
1530             h = 150
1531         self.SetSize(wx.Size(400,h))
1532
1533     def __do_layout(self):
1534         # begin wxGlade: MyFrame.__do_layout
1535         sizer_1 = wx.BoxSizer(wx.VERTICAL)
1536         sizer_2 = wx.BoxSizer(wx.VERTICAL)
1537         self.spanel.SetSizer(self.sizer1)
1538         sizer_1.Add(self.spanel, 4, wx.EXPAND, 0)
1539         sizer_1.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ADJUST_MINSIZE, 0)
1540         #sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
1541         self.SetAutoLayout(True)
1542         self.SetSizer(sizer_1)
1543         self.Layout()
1544         # end wxGlade
1545
1546     def showitem(self, evt) :
1547         idb = evt.GetEventObject().GetId()
1548         nb = self.parent.nb
1549         profile = nb.GetPage(nb.GetSelection())
1550         cl = self.formes[idb][1] - 1
1551         forme = self.formes[idb][0]
1552         profile.ProfNB.SetSelection(cl)
1553         UnSelectList(profile.ProfNB.GetPage(cl))
1554         datas = dict([[profile.ProfNB.GetPage(cl).getColumnText(i,6),i] for i in range(profile.ProfNB.GetPage(cl).GetItemCount())])
1555         profile.ProfNB.GetPage(cl).SetItemState(datas[self.formes[idb][0]], wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
1556         profile.ProfNB.GetPage(cl).Focus(datas[forme])
1557         profile.ProfNB.GetPage(cl).SetFocus()
1558
1559     def OnCloseMe(self, evt) :
1560         self.Close(True)
1561
1562     def OnCloseWindow(self, evt):
1563         self.Destroy()
1564
1565 class SearchDial ( wx.Frame ):
1566     
1567     def __init__( self, parent, listctrl, col, shown):
1568         wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP )
1569         self.parent = parent
1570         self.listctrl = listctrl
1571         self.col = col
1572         self.shown = shown
1573         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1574         
1575         bSizer1 = wx.BoxSizer( wx.VERTICAL )
1576         
1577         self.search = wx.SearchCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_PROCESS_ENTER )
1578         self.search.ShowSearchButton( True )
1579         self.search.ShowCancelButton( True )
1580         bSizer1.Add( self.search, 0, wx.ALL|wx.EXPAND, 5 )
1581         sizer2 = wx.BoxSizer(wx.HORIZONTAL)
1582         self.backward = wx.Button(self, wx.ID_BACKWARD, _(u"Previous").decode('utf8'))
1583         self.forward = wx.Button(self, wx.ID_FORWARD, _(u"Next").decode('utf8'))
1584         sizer2.Add(self.backward, 0, wx.ALL, 5)
1585         sizer2.Add(self.forward, 0, wx.ALL, 5)
1586         bSizer1.Add( sizer2, 0, wx.ALL, 5 )
1587
1588         self.SetSizer( bSizer1 )
1589         self.Layout()
1590         bSizer1.Fit( self )
1591         self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.OnSearch, self.search)
1592         self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.OnCancel, self.search)
1593         self.Bind(wx.EVT_TEXT_ENTER, self.OnSearch, self.search)
1594         self.Bind(wx.EVT_BUTTON, self.onforward, self.forward)
1595         self.Bind(wx.EVT_BUTTON, self.onbackward, self.backward)
1596         self.search.SetFocus()
1597         self.forward.Enable(False)
1598         self.backward.Enable(False)
1599
1600         self.Centre( wx.BOTH )
1601     
1602     def __del__( self ):
1603         pass
1604
1605     def OnSearch(self, evt):
1606         UnSelectList(self.listctrl)
1607         search_word = self.search.GetValue()
1608         if search_word.strip() != '' :
1609             formes = [self.listctrl.getColumnText(i, self.col) for i in range(self.listctrl.GetItemCount())]
1610             if search_word.endswith(u'*') :
1611                 search_word = search_word[0:-1]
1612                 result = [j for j, forme in enumerate(formes) if forme.startswith(search_word)]
1613             else :
1614                 result = [j for j, forme in enumerate(formes) if forme == search_word]
1615             if result == [] :
1616                 self.noresult()
1617             elif self.shown == True :
1618                 self.showitems(result)
1619             else :
1620                 self.showresult(result)
1621         else :
1622             self.Destroy()
1623
1624     
1625     def showitems(self, items) :
1626         if len(items) == 1 :
1627             self.listctrl.SetItemState(items[0], wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
1628             self.listctrl.Focus(items[0])
1629             self.listctrl.SetFocus()
1630             self.Destroy()
1631         else :
1632             for i in items :
1633                 self.listctrl.SetItemState(i, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
1634             self.listctrl.Focus(items[0])
1635             self.listctrl.SetFocus()
1636             self.forward.Enable(True)
1637             self.backward.Enable(False)
1638             self.items = items
1639             self.forwitem = 1
1640             self.backitem = -1
1641     
1642     def showresult(self, result) :
1643         toshow = [self.listctrl.itemDataMap[int(self.listctrl.getColumnText(i,0))] for i in result]
1644         proflist = [[[line[1], i+1, val] for i, val in enumerate(line[2:]) if val>=2] for line in toshow]
1645         #FIXME: intervenir en aval en virant les forme avec chi<2
1646         if proflist != [[]] :
1647             proflist = [val for line in proflist for val in line if line !=[]]
1648             nb = self.parent.parent.nb
1649             profile = nb.GetPage(nb.GetSelection())
1650             first_forme = proflist[0]
1651             cl = first_forme[1] - 1
1652             profile.ProfNB.SetSelection(cl)
1653             profile.ProfNB.GetPage(cl).SetFocus()
1654             UnSelectList(profile.ProfNB.GetPage(cl))
1655             datas = dict([[profile.ProfNB.GetPage(cl).getColumnText(i,6),i] for i in range(profile.ProfNB.GetPage(cl).GetItemCount())])
1656             profile.ProfNB.GetPage(cl).SetItemState(datas[first_forme[0]], wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
1657             profile.ProfNB.GetPage(cl).Focus(datas[first_forme[0]])
1658             profile.ProfNB.GetPage(cl).SetFocus()
1659             if len(proflist) == 1 :
1660                 self.Destroy()
1661             else :
1662                 SearchResult = FindInCluster(self.parent.parent, -1, proflist)
1663                 SearchResult.Show()
1664                 self.Destroy()
1665         else :
1666             self.noresult()
1667
1668     def onforward(self, evt) :
1669         self.listctrl.Focus(self.items[self.forwitem])
1670         self.listctrl.SetFocus()
1671         self.forwitem += 1
1672         if self.forwitem == len(self.items) :
1673             self.forward.Enable(False)
1674             self.backward.Enable(True)
1675             self.backitem += 1
1676         else :
1677             self.backitem += 1
1678             self.backward.Enable(True)
1679
1680     def onbackward(self, evt) :
1681         self.listctrl.Focus(self.items[self.backitem])
1682         self.listctrl.SetFocus()
1683         self.backitem -= 1
1684         if self.backitem == -1 :
1685             self.forwitem -= 1
1686             self.forward.Enable(True)
1687             self.backward.Enable(False)
1688         else :
1689             self.forwitem -= 1
1690             self.forward.Enable(True)
1691
1692     def noresult(self) :
1693         msg = _(u"Absent form").decode('utf8')
1694         dial = wx.MessageDialog(self, _(u"Absent form").decode('utf8'),_(u"Absent form").decode('utf8'), wx.OK | wx.ICON_INFORMATION)
1695         dial.CenterOnParent()
1696         dial.ShowModal()
1697         dial.Destroy()
1698
1699     def OnCancel(self, evt) :
1700         self.search.Clear()
1701
1702 def UnSelectList(liste) :
1703     if liste.GetFirstSelected() != -1 :
1704         last = liste.GetFirstSelected()
1705         liste.Select(liste.GetFirstSelected(), False)
1706         while liste.GetNextSelected(last) != -1 :
1707             last = liste.GetNextSelected(last)
1708             liste.Select(liste.GetFirstSelected(),False)
1709
1710 class SearchCorpus(SearchDial):
1711     def OnSearch(self, evt):
1712         search_word = self.search.GetValue()
1713         if search_word.strip() != '' :
1714             self.corpus_ok = self.listctrl.GetCorpusByName(search_word)
1715             if self.corpus_ok != [] :
1716                 if len(self.corpus_ok) == 1 :
1717                     self.listctrl.GiveFocus(None, self.corpus_ok[0]['uuid'])
1718                     self.Destroy()
1719                 else :
1720                     self.listctrl.GiveFocus(None, self.corpus_ok[-1]['uuid'])
1721                     self.forward.Enable(True)
1722                     self.backward.Enable(False)                        
1723                     self.forwitem = 1
1724                     self.backitem = -1
1725                     #for corpus in corpus_ok :
1726                     #    self.listctrl.SetContentBackground(uuid = corpus['uuid'])
1727             else :
1728                 print 'no results'
1729         else :
1730             self.Destroy()
1731             
1732     def onforward(self, evt) :
1733         self.forwitem += 1
1734         self.listctrl.GiveFocus(uuid=self.corpus_ok[-self.forwitem]['uuid'])
1735         if self.forwitem == len(self.corpus_ok) :
1736             self.forward.Enable(False)
1737             self.backward.Enable(True)
1738             self.backitem = self.forwitem - 1
1739         else :
1740             self.backitem = self.forwitem - 1
1741             self.backward.Enable(True)
1742
1743     def onbackward(self, evt) :
1744         self.listctrl.GiveFocus(uuid=self.corpus_ok[-self.backitem]['uuid'])
1745         self.backitem -= 1
1746         if self.backitem == 0 :
1747             self.forwitem -= 1
1748             self.forward.Enable(True)
1749             self.backward.Enable(False)
1750         else :
1751             self.forwitem -= 1
1752             self.forward.Enable(True)
1753
1754 class OptLexi(wx.Dialog):
1755     def __init__(self, parent, force_chi = False):
1756         # begin wxGlade: MyDialog.__init__
1757         #kwds["style"] = wx.DEFAULT_DIALOG_STYLE
1758         wx.Dialog.__init__(self, parent, style = wx.DEFAULT_DIALOG_STYLE)
1759         self.listet = None
1760         self.variables = None
1761         self.force_chi = force_chi
1762         #self.labellem =  wx.StaticText(self, -1, u"Lemmatisation : ")
1763         #self.checklem = wx.CheckBox(self, -1)
1764         if not self.force_chi :
1765             self.label_typeformes =  wx.StaticText(self, -1, _(u"Used forms").decode('utf8'))
1766             typeformeschoiceChoices = [ _(u"actives and supplementaries").decode('utf8'), _(u"actives").decode('utf8'), _(u"supplementaries").decode('utf8')]
1767             self.typeformes = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, typeformeschoiceChoices, 0 )
1768             self.typeformes.SetSelection( 0 )
1769
1770         self.label_var =  wx.StaticText(self, -1, _(u"Select by").decode('utf8'))
1771         self.choice = wx.Choice(self, -1, (100,50), choices = [_(u"variables").decode('utf8'), _(u"modalities").decode('utf8')])
1772         self.label1 =  wx.StaticText(self, -1, _(u"Choice").decode('utf8'))
1773         self.list_box_1 = wx.ListBox(self, -1, choices=[],  size = wx.Size( 150,200 ), style=wx.LB_EXTENDED | wx.LB_HSCROLL)
1774         self.button_2 = wx.Button(self, wx.ID_CANCEL, "")
1775         self.button_1 = wx.Button(self, wx.ID_OK, "")
1776         if not self.force_chi :
1777             indices = [_(u"hypergeometrical law").decode('utf8'), _(u"chi2").decode('utf8')]
1778         else :
1779             indices = [_(u"chi2").decode('utf8')]
1780         self.label_indice =  wx.StaticText(self, -1, _(u"Score").decode('utf8'))
1781         self.choice_indice =  wx.Choice(self, -1, (100,50), choices = indices)
1782         if not self.force_chi :
1783             self.label = wx.StaticText(self, -1, _(u"Minimum frequency").decode('utf8'))
1784             self.spin = wx.SpinCtrl(self, -1, min = 1, max = 10000, initial = 10)
1785         self.Bind(wx.EVT_CHOICE, self.onselect, self.choice)
1786         self.Bind(wx.EVT_LISTBOX, self.onchoose, self.list_box_1)
1787         self.__set_properties()
1788         self.__do_layout()
1789         # end wxGlade
1790
1791     def __set_properties(self):
1792         # begin wxGlade: MyDialog.__set_properties
1793         self.SetTitle(_(u"Variables choice").decode('utf8'))
1794         if not self.force_chi :
1795             self.spin.SetValue(10)
1796         self.choice.SetSelection(0)
1797         self.choice_indice.SetSelection(0)
1798         self.button_1.Enable(False)
1799         #self.SetMinSize(wx.Size(300, 400))
1800         # end wxGlade
1801
1802     def __do_layout(self):
1803         # begin wxGlade: MyDialog.__do_layout
1804         sizer_1 = wx.BoxSizer(wx.VERTICAL)
1805         sizer_2 = wx.FlexGridSizer(0,2,0,0)
1806         sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
1807         #sizer_2.Add(self.labellem, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1808         #sizer_2.Add(self.checklem, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1809         if not self.force_chi :
1810             sizer_2.Add(self.label_typeformes, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1811             sizer_2.Add(self.typeformes, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1812         sizer_2.Add(self.label_var, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1813         sizer_2.Add(self.choice, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1814         sizer_2.Add(self.label1, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1815         sizer_2.Add(self.list_box_1, 0, wx.ALIGN_RIGHT, 3)
1816         sizer_3.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1817         sizer_3.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1818         sizer_2.Add(self.label_indice, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1819         sizer_2.Add(self.choice_indice, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1820         if not self.force_chi :
1821             sizer_2.Add(self.label, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1822             sizer_2.Add(self.spin, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 3)
1823         sizer_1.Add(sizer_2, 0, wx.ALIGN_CENTER_HORIZONTAL, 3)
1824         sizer_1.Add(sizer_3, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_RIGHT, 3)
1825         self.SetSizer(sizer_1)
1826         sizer_1.Fit(self)
1827         self.Layout()
1828         self.Centre()
1829
1830     def onselect(self, evt):
1831         self.list_box_1.Clear()
1832         if self.choice.GetSelection() == 0 :
1833             for var in self.variables :
1834                 self.list_box_1.Append(var)
1835         else :
1836             for et in self.listet :
1837                 self.list_box_1.Append(et)
1838     
1839     def onchoose(self, evt):
1840         if self.choice.GetSelection()== 0 :
1841             if len(self.list_box_1.GetSelections()) > 0 :
1842                 self.button_1.Enable(True)
1843             else :
1844                 self.button_1.Enable(False)
1845         elif self.choice.GetSelection() == 1 :
1846             if len(self.list_box_1.GetSelections()) > 1 :
1847                 self.button_1.Enable(True)
1848             else :
1849                 self.button_1.Enable(False)    
1850
1851 class PrefDendro ( wx.Dialog ):
1852     
1853     def __init__( self, parent, param ):
1854         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Dendrogram").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
1855         self.param = param
1856         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1857         
1858         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
1859         fgSizer1.SetFlexibleDirection( wx.BOTH )
1860         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1861         
1862         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Picture size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1863         self.m_staticText1.Wrap( -1 )
1864         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1865         
1866         bSizer2 = wx.BoxSizer( wx.VERTICAL )
1867         
1868         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
1869         
1870         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"height").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1871         self.m_staticText2.Wrap( -1 )
1872         bSizer3.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1873         
1874         self.m_spinCtrl1 = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 50, 10000, 600 )
1875         bSizer3.Add( self.m_spinCtrl1, 0, wx.ALL, 5 )
1876         
1877         bSizer2.Add( bSizer3, 1, wx.EXPAND, 5 )
1878         
1879         bSizer31 = wx.BoxSizer( wx.HORIZONTAL )
1880         
1881         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"width").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1882         self.m_staticText3.Wrap( -1 )
1883         bSizer31.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1884         
1885         self.m_spinCtrl2 = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 50, 10000, 600 )
1886         bSizer31.Add( self.m_spinCtrl2, 0, wx.ALL, 5 )
1887         
1888         bSizer2.Add( bSizer31, 1, wx.EXPAND, 5 )
1889         
1890         fgSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
1891         
1892         self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1893         fgSizer1.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )
1894         
1895         self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1896         fgSizer1.Add( self.m_staticline2, 0, wx.EXPAND |wx.ALL, 5 )
1897         
1898         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Dendrogram type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1899         self.m_staticText4.Wrap( -1 )
1900         fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1901         
1902         m_choice1Choices = [ u"phylogram", u"cladogram", u"fan", u"unrooted", u"radial" ]
1903         self.m_choice1 = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice1Choices, 0 )
1904         self.m_choice1.SetSelection( 0 )
1905         fgSizer1.Add( self.m_choice1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1906         
1907         self.m_staticline3 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1908         fgSizer1.Add( self.m_staticline3, 0, wx.EXPAND |wx.ALL, 5 )
1909         
1910         self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1911         fgSizer1.Add( self.m_staticline4, 0, wx.EXPAND |wx.ALL, 5 )
1912     
1913         self.text_format_image = wx.StaticText( self, wx.ID_ANY, _(u"Image format").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1914         self.text_format_image.Wrap( -1 )
1915         fgSizer1.Add( self.text_format_image, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1916         
1917         self.choice_format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ['png', 'svg'], 0 )
1918         self.choice_format.SetSelection( 0 )
1919         fgSizer1.Add( self.choice_format, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1920         
1921         self.m_staticline31 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1922         fgSizer1.Add( self.m_staticline31, 0, wx.EXPAND |wx.ALL, 5 )
1923         
1924         self.m_staticline41 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1925         fgSizer1.Add( self.m_staticline41, 0, wx.EXPAND |wx.ALL, 5 )        
1926         
1927         if self.param['typedendro'] == 'classique' :
1928             self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Color or black and white").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1929             self.m_staticText5.Wrap( -1 )
1930             fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1931         
1932             m_radioBox1Choices = [ _(u"color").decode('utf8'), _(u"black and white").decode('utf8') ]
1933             self.m_radioBox1 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox1Choices, 1, wx.RA_SPECIFY_COLS )
1934             self.m_radioBox1.SetSelection( 0 )
1935             fgSizer1.Add( self.m_radioBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1936         
1937             self.m_staticline5 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1938             fgSizer1.Add( self.m_staticline5, 0, wx.EXPAND |wx.ALL, 5 )
1939         
1940             self.m_staticline6 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1941             fgSizer1.Add( self.m_staticline6, 0, wx.EXPAND |wx.ALL, 5 )
1942         
1943             bSizer4 = wx.BoxSizer( wx.HORIZONTAL )
1944         
1945             self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, _(u"Add cluster size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1946             self.m_staticText6.Wrap( -1 )
1947             bSizer4.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1948         
1949             self.m_checkBox1 = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
1950             self.m_checkBox1.SetValue(True) 
1951             bSizer4.Add( self.m_checkBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1952         
1953             fgSizer1.Add( bSizer4, 1, wx.EXPAND, 5 )
1954         
1955             m_radioBox2Choices = [ _(u"circular diagram").decode('utf8'), _(u"bar").decode('utf8') ]
1956             self.m_radioBox2 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox2Choices, 1, wx.RA_SPECIFY_COLS )
1957             self.m_radioBox2.SetSelection( 0 )
1958             fgSizer1.Add( self.m_radioBox2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1959         
1960         self.m_staticline7 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1961         fgSizer1.Add( self.m_staticline7, 0, wx.EXPAND |wx.ALL, 5 )
1962         
1963         self.m_staticline8 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1964         fgSizer1.Add( self.m_staticline8, 0, wx.EXPAND |wx.ALL, 5 )
1965         
1966         
1967         fgSizer1.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
1968         
1969         m_sdbSizer2 = wx.StdDialogButtonSizer()
1970         self.m_sdbSizer2OK = wx.Button( self, wx.ID_OK )
1971         m_sdbSizer2.AddButton( self.m_sdbSizer2OK )
1972         self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL )
1973         m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel )
1974         m_sdbSizer2.Realize();
1975         fgSizer1.Add( m_sdbSizer2, 1, wx.EXPAND, 5 )
1976         
1977         self.__set_properties()
1978         self.SetSizer( fgSizer1 )
1979         self.Layout()
1980         fgSizer1.Fit( self )
1981         
1982         self.Centre( wx.BOTH )
1983
1984     def __set_properties(self):
1985         self.m_spinCtrl2.SetValue(self.param['width'])
1986         self.m_spinCtrl1.SetValue(self.param['height'])
1987         self.m_choice1.SetSelection(self.param['type_dendro'])
1988         self.choice_format.SetSelection(self.param['svg'])
1989         if self.param['typedendro'] == 'classique' :
1990             self.m_radioBox1.SetSelection(self.param['color_nb'])
1991             self.m_checkBox1.SetValue(self.param['taille_classe'])
1992             self.m_radioBox2.SetSelection(self.param['type_tclasse'])
1993     
1994     def __del__( self ):
1995         pass
1996
1997
1998 class PrefWordCloud ( wx.Dialog ):
1999     
2000     def __init__( self, parent, fromcluster = False ):
2001         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Wordcloud settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
2002         
2003         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2004         
2005         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2006         fgSizer1.SetFlexibleDirection( wx.BOTH )
2007         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2008         
2009         #self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Sélectionner les formes", wx.DefaultPosition, wx.DefaultSize, 0 )
2010         #self.m_staticText1.Wrap( -1 )
2011         #fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2012         
2013         #self.but_selectcol = wx.Button( self, wx.ID_ANY, u"Sélectionner", wx.DefaultPosition, wx.DefaultSize, 0 )
2014         #fgSizer1.Add( self.but_selectcol, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2015         
2016         #self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2017         #fgSizer1.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )
2018         
2019         #self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2020         #fgSizer1.Add( self.m_staticline2, 0, wx.EXPAND |wx.ALL, 5 )
2021         
2022         bSizer1 = wx.BoxSizer( wx.HORIZONTAL )
2023         
2024         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"height").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2025         self.m_staticText3.Wrap( -1 )
2026         bSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2027         
2028         self.spin_H = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 100,30 ), wx.SP_ARROW_KEYS, 0, 10000, 600 )
2029         self.spin_H.SetValue( 800 )
2030         bSizer1.Add( self.spin_H, 0, wx.ALL, 5 )
2031         
2032         fgSizer1.Add( bSizer1, 1, wx.EXPAND, 5 )
2033         
2034         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
2035         
2036         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"width").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2037         self.m_staticText4.Wrap( -1 )
2038         bSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2039         
2040         self.spin_L = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 100,30 ), wx.SP_ARROW_KEYS, 0, 10000, 600 )
2041         self.spin_L.SetValue( 800 )
2042         bSizer3.Add( self.spin_L, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2043         
2044         fgSizer1.Add( bSizer3, 1, wx.EXPAND, 5 )
2045         
2046         self.m_staticline3 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2047         fgSizer1.Add( self.m_staticline3, 0, wx.EXPAND |wx.ALL, 5 )
2048         
2049         self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2050         fgSizer1.Add( self.m_staticline4, 0, wx.EXPAND |wx.ALL, 5 )
2051         
2052         self.m_staticText11 = wx.StaticText( self, wx.ID_ANY, _(u"Picture format").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2053         self.m_staticText11.Wrap( -1 )
2054         fgSizer1.Add( self.m_staticText11, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2055         
2056         formatChoices = [ u"png", u"svg" ]
2057         self.format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, formatChoices, 0 )
2058         self.format.SetSelection( 0 )
2059         fgSizer1.Add( self.format, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2060
2061         if fromcluster :
2062             self.m_staticText111 = wx.StaticText( self, wx.ID_ANY, _(u"Word size proportional to ...").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2063             self.m_staticText11.Wrap( -1 )
2064             fgSizer1.Add( self.m_staticText111, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2065         
2066             IndiceChoices = [ _(u"chi2").decode('utf8'), _(u"frequency").decode('utf8') ]
2067             self.indice = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, IndiceChoices, 0 )
2068             self.indice.SetSelection( 0 )
2069             fgSizer1.Add( self.indice, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2070
2071         self.m_staticline13 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2072         fgSizer1.Add( self.m_staticline13, 0, wx.EXPAND |wx.ALL, 5 )
2073         
2074         self.m_staticline14 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2075         fgSizer1.Add( self.m_staticline14, 0, wx.EXPAND |wx.ALL, 5 )
2076
2077         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Maximum number of forms").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2078         self.m_staticText5.Wrap( -1 )
2079         fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2080         
2081         self.spin_maxword = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 10000, 600 )
2082         self.spin_maxword.SetValue( 600 )
2083         fgSizer1.Add( self.spin_maxword, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2084         
2085         self.m_staticline5 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2086         fgSizer1.Add( self.m_staticline5, 0, wx.EXPAND |wx.ALL, 5 )
2087         
2088         self.m_staticline6 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2089         fgSizer1.Add( self.m_staticline6, 0, wx.EXPAND |wx.ALL, 5 )
2090         
2091         self.typeformes = wx.StaticText( self, wx.ID_ANY, _(u"Used forms").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2092         self.typeformes.Wrap( -1 )
2093         fgSizer1.Add( self.typeformes, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2094         
2095         typeformeschoiceChoices = [ _(u"actives").decode('utf8'), _(u"supplementaries").decode('utf8'), _(u"actives and supplementaries").decode('utf8') ]
2096         self.typeformeschoice = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, typeformeschoiceChoices, 0 )
2097         self.typeformeschoice.SetSelection( 0 )
2098         fgSizer1.Add( self.typeformeschoice, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2099         
2100         self.m_staticline11 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2101         fgSizer1.Add( self.m_staticline11, 0, wx.EXPAND |wx.ALL, 5 )
2102         
2103         self.m_staticline12 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2104         fgSizer1.Add( self.m_staticline12, 0, wx.EXPAND |wx.ALL, 5 )        
2105         
2106         self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, _(u"Text size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2107         self.m_staticText6.Wrap( -1 )
2108         fgSizer1.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2109         
2110         bSizer4 = wx.BoxSizer( wx.VERTICAL )
2111         
2112         bSizer5 = wx.BoxSizer( wx.HORIZONTAL )
2113         
2114         self.m_staticText7 = wx.StaticText( self, wx.ID_ANY, u"Min", wx.DefaultPosition, wx.DefaultSize, 0 )
2115         self.m_staticText7.Wrap( -1 )
2116         bSizer5.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2117         
2118         self.spin_mincex = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 5 )
2119         self.spin_mincex.SetValue( 5 )
2120         bSizer5.Add( self.spin_mincex, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
2121         
2122         bSizer4.Add( bSizer5, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
2123         
2124         bSizer6 = wx.BoxSizer( wx.HORIZONTAL )
2125         
2126         self.m_staticText8 = wx.StaticText( self, wx.ID_ANY, u"Max", wx.DefaultPosition, wx.DefaultSize, 0 )
2127         self.m_staticText8.Wrap( -1 )
2128         bSizer6.Add( self.m_staticText8, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2129         
2130         self.spin_maxcex = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 50 )
2131         self.spin_maxcex.SetValue( 50 )
2132         bSizer6.Add( self.spin_maxcex, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2133         
2134         bSizer4.Add( bSizer6, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
2135         
2136         fgSizer1.Add( bSizer4, 1, wx.EXPAND, 5 )
2137         
2138         self.m_staticline7 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2139         fgSizer1.Add( self.m_staticline7, 0, wx.EXPAND |wx.ALL, 5 )
2140         
2141         self.m_staticline8 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2142         fgSizer1.Add( self.m_staticline8, 0, wx.EXPAND |wx.ALL, 5 )
2143         
2144         bSizer61 = wx.BoxSizer( wx.HORIZONTAL )
2145         
2146         self.m_staticText81 = wx.StaticText( self, wx.ID_ANY, _(u"Text color").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2147         self.m_staticText81.Wrap( -1 )
2148         bSizer61.Add( self.m_staticText81, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2149         
2150         self.color_text = wx.ColourPickerCtrl( self, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE )
2151         bSizer61.Add( self.color_text, 0, wx.ALL, 5 )
2152         
2153         fgSizer1.Add( bSizer61, 1, wx.EXPAND, 5 )
2154         
2155         bSizer7 = wx.BoxSizer( wx.HORIZONTAL )
2156         
2157         self.m_staticText9 = wx.StaticText( self, wx.ID_ANY, _(u"Background color").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2158         self.m_staticText9.Wrap( -1 )
2159         bSizer7.Add( self.m_staticText9, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2160         
2161         self.color_bg = wx.ColourPickerCtrl( self, wx.ID_ANY, (255,255,255), wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE )
2162         bSizer7.Add( self.color_bg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2163         
2164         fgSizer1.Add( bSizer7, 1, wx.EXPAND, 5 )
2165         
2166         self.m_staticline9 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2167         fgSizer1.Add( self.m_staticline9, 0, wx.EXPAND |wx.ALL, 5 )
2168         
2169         self.m_staticline10 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2170         fgSizer1.Add( self.m_staticline10, 0, wx.EXPAND |wx.ALL, 5 )
2171
2172         fgSizer1.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
2173         
2174         m_sdbSizer1 = wx.StdDialogButtonSizer()
2175         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2176         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2177         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2178         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2179         m_sdbSizer1.Realize();
2180         fgSizer1.Add( m_sdbSizer1, 1, wx.EXPAND, 5 )
2181         
2182         self.SetSizer( fgSizer1 )
2183         self.Layout()
2184         fgSizer1.Fit( self )
2185         
2186         self.Centre( wx.BOTH )
2187     
2188     def __del__( self ):
2189         pass
2190     
2191 class PrefChi(sc.SizedDialog):
2192     def __init__(self, parent, ID, optionchi, title):
2193
2194         sc.SizedDialog.__init__(self, None, -1, _(u"Settings").decode('utf8'), 
2195                         style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
2196         pane = self.GetContentsPane()
2197         pane.SetSizerType("form")
2198         pane.SetSizerProps(border=("all",5))
2199         self.parent = parent
2200         self.optionchi = optionchi
2201         
2202
2203         self.label_obs = wx.StaticText(pane, -1, _(u"observed values").decode('utf8'))
2204         self.check1 = wx.CheckBox(pane, -1)
2205  
2206         self.label_theo = wx.StaticText(pane, -1, _(u"expected values").decode('utf8'))
2207         self.check2 = wx.CheckBox(pane, -1)
2208
2209         self.label_resi = wx.StaticText(pane, -1, _(u"residuals").decode('utf8'))
2210         self.check3 = wx.CheckBox(pane, -1)
2211
2212         self.label_contrib = wx.StaticText(pane, -1, _(u"standardized residuals").decode('utf8'))
2213         self.check4 = wx.CheckBox(pane, -1)
2214 #        self.label_graph = wx.StaticText(pane, -1, u'graphique')
2215 #        self.check8 = wx.CheckBox(pane, -1)
2216         self.label_pourcent = wx.StaticText(pane, -1, _(u"total percentage").decode('utf8'))
2217         self.check5 = wx.CheckBox(pane, -1)
2218
2219         self.label_prl = wx.StaticText(pane, -1, _(u"row percentage").decode('utf8'))
2220         self.check6 = wx.CheckBox(pane, -1)
2221
2222         self.label_prc = wx.StaticText(pane, -1, _(u"column percentage").decode('utf8'))
2223         self.check7 = wx.CheckBox(pane, -1)
2224
2225         self.label_graph = wx.StaticText(pane, -1, _(u"graphical").decode('utf8'))
2226         self.check8 = wx.CheckBox(pane, -1)
2227         
2228         self.label_graphbw = wx.StaticText(pane, -1, _(u"black and white graphical").decode('utf8'))
2229         self.checkbw = wx.CheckBox(pane, -1)
2230
2231         self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL))
2232
2233         self.__set_properties()
2234         self.Fit()
2235         self.SetMinSize(self.GetSize())
2236
2237     def __set_properties(self):
2238         self.check1.SetValue(self.optionchi['valobs'])
2239         self.check2.SetValue(self.optionchi['valtheo'])
2240         self.check3.SetValue(self.optionchi['resi'])
2241         self.check4.SetValue(self.optionchi['contrib'])
2242         self.check5.SetValue(self.optionchi['pourcent'])
2243         self.check6.SetValue(self.optionchi['pourcentl'])
2244         self.check7.SetValue(self.optionchi['pourcentc'])
2245         self.check8.SetValue(self.optionchi['graph'])
2246         self.checkbw.SetValue(self.optionchi['bw'])
2247
2248 class ChiDialog(wx.Dialog):
2249     def __init__(
2250             self, parent, ID, title, optionchi, tableau, size=wx.DefaultSize, pos=wx.DefaultPosition, 
2251             style=wx.DEFAULT_DIALOG_STYLE
2252             ):
2253
2254         pre = wx.PreDialog()
2255         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
2256         pre.Create(parent, ID, title, pos, size, style)
2257
2258         self.PostCreate(pre)
2259         self.parent = parent 
2260         self.optionchi = optionchi
2261         self.chiopt = False
2262         self.tableau = tableau
2263         #self.Filename=parent.filename
2264         #self.content=parent.content[:]
2265         self.headers=self.tableau.get_colnames()
2266         LABELLIST=[]
2267         
2268         for i in self.headers:
2269             if len(i)>60 :
2270                 LABELLIST.append(i[0:60])
2271             else:
2272                 LABELLIST.append(i)
2273         
2274         self.ListOK=[]
2275         self.LabelListOK=LABELLIST
2276  
2277         self.list_box_1 = wx.ListBox(self, -1, choices=self.LabelListOK, style=wx.LB_EXTENDED|wx.LB_HSCROLL)
2278         self.list_box_2 = wx.ListBox(self, -1, choices=self.LabelListOK, style=wx.LB_EXTENDED|wx.LB_HSCROLL)
2279         self.button_1 = wx.Button(self, wx.ID_OK)
2280         self.button_cancel = wx.Button(self, wx.ID_CANCEL)
2281         self.button_pref = wx.Button(self, wx.ID_PREFERENCES)
2282         self.__set_properties()
2283         self.__do_layout()
2284
2285         self.Bind(wx.EVT_LISTBOX, self.selchange, self.list_box_1)
2286         self.Bind(wx.EVT_LISTBOX, self.selchange, self.list_box_2)
2287         self.Bind(wx.EVT_BUTTON, self.onparam, self.button_pref)
2288         self.button_1.Enable(False)
2289         # end wxGlade
2290 #-------------------------------
2291     def __set_properties(self):
2292         # begin wxGlade: ConfChi2.__set_properties
2293         self.SetTitle(_(u"Variables selection").decode('utf8'))
2294
2295     def __do_layout(self):
2296         # begin wxGlade: ConfChi2.__do_layout
2297         sizer_1 = wx.BoxSizer(wx.VERTICAL)
2298         sizer_2 = wx.BoxSizer(wx.VERTICAL)
2299         sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
2300         sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
2301         sizer_3.Add(self.list_box_1, 0, wx.EXPAND, 0)
2302         sizer_3.Add(self.list_box_2, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 0)
2303         sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
2304         sizer_4.Add(self.button_cancel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 0)
2305         sizer_4.Add(self.button_pref, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 0)
2306         sizer_4.Add(self.button_1, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 0)
2307         sizer_2.Add(sizer_4, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
2308         sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
2309         self.SetSizer(sizer_1)
2310         sizer_1.Fit(self)
2311         self.Layout()
2312         # end wxGlade
2313
2314     def selchange(self, event): # wxGlade: ConfChi2.<event_handler>
2315         if (len(self.list_box_1.GetSelections()) == 0) or (len(self.list_box_2.GetSelections()) == 0) :
2316             self.button_1.Enable(False)
2317         else :
2318             self.button_1.Enable(True)
2319     
2320     
2321     def onparam(self,event):
2322         self.dial = PrefChi(self.parent, -1, self.optionchi, '')
2323         self.dial.CenterOnParent()
2324         self.chiopt = self.dial.ShowModal()
2325
2326 class CorpusPref ( wx.Dialog ):
2327     
2328     def __init__( self, parent, parametres ):
2329         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE | wx.STAY_ON_TOP )
2330         self.parent = parent 
2331         langues_n = [u'français', u'english', u'german (expérimentale)', u'italian', u'swedish (expérimentale)', u'portuguese', u'spanish', u'greek (expériementale)', u'galician (expérimentale)', u'autre...']
2332         self.langues = [u'french', u'english', u'german', u'italian', u'swedish', u'portuguese', u'spanish', u'greek', u'galician', u'other']
2333         self.encodages = [enc[0].lower() for enc in encodages]
2334
2335         ucimark = [u'****', u'0000']
2336         ucemethod = [_(u"characters").decode('utf8'), _(u"occurrences").decode('utf8'), _(u"paragraphs").decode('utf8')]
2337
2338         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2339         
2340         bSizer1 = wx.BoxSizer( wx.VERTICAL )
2341         
2342         self.m_notebook1 = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
2343         self.m_panel1 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
2344         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2345         fgSizer1.SetFlexibleDirection( wx.BOTH )
2346         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2347         
2348         self.m_staticText7 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"corpus").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2349         self.m_staticText7.Wrap( -1 )
2350         fgSizer1.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2351         
2352         self.txtpath = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Path").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2353         self.txtpath.Wrap( -1 )
2354         fgSizer1.Add( self.txtpath, 0, wx.ALL, 5 )
2355
2356         self.m_staticText18 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Corpus' name").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2357         self.m_staticText18.Wrap( -1 )
2358         fgSizer1.Add( self.m_staticText18, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2359         
2360         self.corpusname = wx.TextCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 200,-1 ), 0 )
2361         fgSizer1.Add( self.corpusname, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2362              
2363         self.m_staticText1 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Characters set").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2364         self.m_staticText1.Wrap( -1 )
2365         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2366         
2367         encodage_choicesChoices = [' - '.join(encodage) for encodage in encodages]
2368         self.encodage_choices = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, encodage_choicesChoices, 0 )
2369         self.encodage_choices.SetSelection( 0 )
2370         fgSizer1.Add( self.encodage_choices, 0, wx.ALL, 5 )
2371         
2372         self.m_staticText2 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Language").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2373         self.m_staticText2.Wrap( -1 )
2374         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2375         
2376         lang_choicesChoices = langues_n
2377         self.lang_choices = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, lang_choicesChoices, 0 )
2378         self.lang_choices.SetSelection( 0 )
2379         fgSizer1.Add( self.lang_choices, 0, wx.ALL, 5 )
2380
2381         self.m_staticText19 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Dictionary").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2382         self.m_staticText19.Wrap( -1 )
2383         fgSizer1.Add( self.m_staticText19, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2384         
2385         bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
2386         
2387         fgSizer5 = wx.FlexGridSizer( 2, 2, 0, 0 )
2388         fgSizer5.SetFlexibleDirection( wx.BOTH )
2389         fgSizer5.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2390         
2391         self.radio_default_dict = wx.RadioButton( self.m_panel1, wx.ID_ANY, _(u"Default").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2392         fgSizer5.Add( self.radio_default_dict, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2393         
2394         self.defaultdictpath = wx.TextCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 300,-1 ), wx.TE_READONLY )
2395         self.defaultdictpath.Enable( False )
2396         
2397         fgSizer5.Add( self.defaultdictpath, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2398         
2399         self.radio_other_dict = wx.RadioButton( self.m_panel1, wx.ID_ANY, _(u"Other").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2400         fgSizer5.Add( self.radio_other_dict, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2401         
2402         self.otherdictpath = wx.FilePickerCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, _(u"Select a file").decode('utf8'), u"*.*", wx.DefaultPosition, wx.Size( 300,-1 ), wx.FLP_DEFAULT_STYLE )
2403         self.otherdictpath.SetMinSize(wx.Size(300, -1))
2404         fgSizer5.Add( self.otherdictpath, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2405         self.otherdictpath.Enable( False )
2406         
2407         
2408         bSizer2.Add( fgSizer5, 1, wx.EXPAND, 5 )
2409         
2410         
2411         fgSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
2412
2413         self.m_staticText3 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Output folder").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2414         self.m_staticText3.Wrap( -1 )
2415         fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2416         
2417         
2418         fgSizer41 = wx.FlexGridSizer( 0, 2, 0, 0 )
2419         fgSizer41.SetFlexibleDirection( wx.BOTH )
2420         fgSizer41.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2421         
2422         self.repout_choices = wx.TextCtrl( self.m_panel1, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0 )
2423         self.repout_choices.SetMinSize( wx.Size( 400,-1 ) )
2424         fgSizer41.Add( self.repout_choices, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2425         
2426         self.m_button1 = wx.Button( self.m_panel1, wx.ID_ANY, _(u"Change ...").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2427         fgSizer41.Add( self.m_button1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2428         
2429         fgSizer1.Add( fgSizer41, 1, wx.EXPAND, 5 )        
2430
2431         self.m_staticText12 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Text mark").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2432         self.m_staticText12.Wrap( -1 )
2433         fgSizer1.Add( self.m_staticText12, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2434         
2435         ucimark_choicesChoices = ucimark
2436         self.ucimark_choices = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ucimark_choicesChoices, 0 )
2437         self.ucimark_choices.SetSelection( 0 )
2438         fgSizer1.Add( self.ucimark_choices, 0, wx.ALL, 5 )
2439         
2440         self.m_staticText6 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Use the expression dictionary").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2441         self.m_staticText6.Wrap( -1 )
2442         fgSizer1.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2443         
2444         self.check_expressions = wx.CheckBox( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2445         self.check_expressions.SetValue(True) 
2446         fgSizer1.Add( self.check_expressions, 0, wx.ALL, 5 )
2447         
2448         self.m_staticText9 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Make text segments").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2449         self.m_staticText9.Wrap( -1 )
2450         fgSizer1.Add( self.m_staticText9, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2451         
2452         self.check_makeuce = wx.CheckBox( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2453         self.check_makeuce.SetValue(True) 
2454         fgSizer1.Add( self.check_makeuce, 0, wx.ALL, 5 )
2455         
2456         self.m_staticText10 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Text segments build process").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2457         self.m_staticText10.Wrap( -1 )
2458         fgSizer1.Add( self.m_staticText10, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2459         
2460         uce_modeChoices = ucemethod
2461         self.uce_mode = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, uce_modeChoices, 0 )
2462         self.uce_mode.SetSelection( 0 )
2463         fgSizer1.Add( self.uce_mode, 0, wx.ALL, 5 )
2464         
2465         self.m_staticText13 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Text segments size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2466         self.m_staticText13.Wrap( -1 )
2467         fgSizer1.Add( self.m_staticText13, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2468         
2469         self.uce_size = wx.SpinCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 1000000, 40 )
2470         fgSizer1.Add( self.uce_size, 0, wx.ALL, 5 )
2471         
2472         
2473         self.m_panel1.SetSizer( fgSizer1 )
2474         self.m_panel1.Layout()
2475         fgSizer1.Fit( self.m_panel1 )
2476         self.m_notebook1.AddPage( self.m_panel1, _(u"General").decode('utf8'), True )
2477         self.m_panel2 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
2478         fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
2479         fgSizer3.SetFlexibleDirection( wx.BOTH )
2480         fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2481         
2482         self.m_staticText4 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Put text in lowercase").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2483         self.m_staticText4.Wrap( -1 )
2484         fgSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2485         
2486         self.check_lower = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2487         self.check_lower.SetValue(True) 
2488         fgSizer3.Add( self.check_lower, 0, wx.ALL, 5 )
2489         
2490         self.m_staticText5 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Delete characters not in this list").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2491         self.m_staticText5.Wrap( -1 )
2492         fgSizer3.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2493         
2494         fgSizer4 = wx.FlexGridSizer( 0, 2, 0, 0 )
2495         fgSizer4.SetFlexibleDirection( wx.BOTH )
2496         fgSizer4.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2497         
2498         self.check_charact = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2499         self.check_charact.SetValue(True) 
2500         fgSizer4.Add( self.check_charact, 0, wx.ALL, 5 )
2501         
2502         self.txt_charact = wx.TextCtrl( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2503         self.txt_charact.SetMinSize( wx.Size( 400,-1 ) )
2504         
2505         fgSizer4.Add( self.txt_charact, 0, wx.ALL|wx.EXPAND, 5 )
2506         
2507         
2508         fgSizer3.Add( fgSizer4, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
2509         
2510         self.m_staticText14 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Replace apostrophe by space").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2511         self.m_staticText14.Wrap( -1 )
2512         fgSizer3.Add( self.m_staticText14, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2513         
2514         self.check_apos = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2515         self.check_apos.SetValue(True) 
2516         fgSizer3.Add( self.check_apos, 0, wx.ALL, 5 )
2517         
2518         self.m_staticText15 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Replace dash by space").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2519         self.m_staticText15.Wrap( -1 )
2520         fgSizer3.Add( self.m_staticText15, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2521         
2522         self.check_tirets = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2523         self.check_tirets.SetValue(True) 
2524         fgSizer3.Add( self.check_tirets, 0, wx.ALL, 5 )
2525         
2526         self.m_staticText17 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Keep punctuation").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2527         self.m_staticText17.Wrap( -1 )
2528         fgSizer3.Add( self.m_staticText17, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2529         
2530         self.check_ponct = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2531         fgSizer3.Add( self.check_ponct, 0, wx.ALL, 5 )
2532
2533         self.m_staticText16 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"No space between two forms").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2534         self.m_staticText16.Wrap( -1 )
2535         fgSizer3.Add( self.m_staticText16, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2536         
2537         self.check_tolist = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2538         fgSizer3.Add( self.check_tolist, 0, wx.ALL, 5 )
2539         
2540         
2541         self.m_panel2.SetSizer( fgSizer3 )
2542         self.m_panel2.Layout()
2543         fgSizer3.Fit( self.m_panel2 )
2544         self.m_notebook1.AddPage( self.m_panel2, _(u"Cleaning").decode('utf8'), False )
2545         
2546         bSizer1.Add( self.m_notebook1, 1, wx.EXPAND |wx.ALL, 5 )
2547         
2548         m_sdbSizer1 = wx.StdDialogButtonSizer()
2549         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2550         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2551         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2552         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2553         m_sdbSizer1.Realize();
2554         
2555         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
2556        
2557
2558         # Connect Events
2559         self.Bind(wx.EVT_BUTTON, self.OnChangeDir, self.m_button1)
2560         self.lang_choices.Bind( wx.EVT_CHOICE, self.OnChangeLangage )
2561         self.radio_other_dict.Bind( wx.EVT_RADIOBUTTON, self.changedictchoice )
2562         self.radio_default_dict.Bind( wx.EVT_RADIOBUTTON, self.changedictchoice )
2563         self.otherdictpath.Bind( wx.EVT_FILEPICKER_CHANGED, self.selectdict) 
2564
2565         self.setparametres(parametres) 
2566         self.SetSizer( bSizer1 )
2567         self.Layout()
2568         bSizer1.Fit( self )
2569         
2570         self.Centre( wx.BOTH )
2571
2572     def OnChangeDir(self, evt) :
2573         sdlg = wx.DirDialog(self.parent, _(u"Choose a folder").decode('utf8'), style = wx.DD_DEFAULT_STYLE)
2574         if sdlg.ShowModal() == wx.ID_OK :
2575             self.repout_choices.SetValue(dlg.GetPath())
2576         sdlg.Destroy()
2577     
2578     def __del__( self ):
2579         pass
2580
2581     def setparametres(self, parametres) :
2582         if  locale.getpreferredencoding().lower() == 'mac-roman' :
2583             enc = self.encodages.index('macroman')
2584         else :
2585             try :
2586                 enc = self.encodages.index(locale.getpreferredencoding().lower())
2587             except ValueError :
2588                 enc = self.encodages.index('utf-8')
2589         self.encodage_choices.SetSelection(enc)
2590         self.lang_choices.SetSelection(0)
2591         self.repout_choices.SetValue(parametres['pathout'])
2592         self.corpusname.SetValue(parametres['corpus_name'])
2593         self.ucimark_choices.SetSelection(parametres['ucimark'])
2594         self.check_expressions.SetValue(parametres['expressions'])
2595         self.check_makeuce.SetValue(parametres['douce'])
2596         self.uce_mode.SetSelection(parametres['ucemethod'])
2597         self.uce_size.SetValue(parametres['ucesize'])
2598         self.check_lower.SetValue(parametres['lower'])
2599         #self.check_charact.SetValue(parametres['charact'])
2600         self.txt_charact.SetValue(parametres['keep_caract'])
2601         self.check_apos.SetValue(parametres['apos'])
2602         self.check_tirets.SetValue(parametres['tiret'])
2603         self.check_tolist.SetValue(parametres['tolist'])
2604         self.check_ponct.SetValue(parametres['keep_ponct'])
2605         self.defaultdictpath.SetValue(self.langues[0])
2606
2607     def doparametres(self) :
2608         parametres = {}
2609         parametres['encoding'] = encodages[self.encodage_choices.GetSelection()][0]
2610         parametres['lang'] = self.langues[self.lang_choices.GetSelection()]
2611         parametres['pathout'] = self.repout_choices.GetValue()
2612         parametres['corpus_name'] = self.corpusname.GetValue()
2613         parametres['ucimark'] = self.ucimark_choices.GetSelection()
2614         parametres['expressions'] = self.check_expressions.GetValue()
2615         parametres['douce'] =  self.check_makeuce.GetValue()
2616         parametres['ucemethod'] = self.uce_mode.GetSelection()
2617         parametres['ucesize'] = self.uce_size.GetValue()
2618         parametres['lower'] = self.check_lower.GetValue()
2619         parametres['charact'] = self.check_charact.GetValue()
2620         parametres['keep_caract'] = self.txt_charact.GetValue()
2621         parametres['apos'] = self.check_apos.GetValue()
2622         parametres['tiret'] = self.check_tirets.GetValue()
2623         parametres['tolist'] = self.check_tolist.GetValue()
2624         parametres['keep_ponct'] = self.check_ponct.GetValue()
2625         if self.radio_other_dict.GetValue() :
2626             parametres['dictionary'] = self.otherdictpath.GetPath()
2627         for val in parametres :
2628             if isinstance(parametres[val], bool) :
2629                 if parametres[val] :
2630                     parametres[val] = 1
2631                 else :
2632                     parametres[val] = 0
2633         return parametres
2634     
2635     def OnChangeLangage(self, evt):
2636         self.defaultdictpath.SetValue(self.langues[self.lang_choices.GetSelection()])
2637     
2638     def changedictchoice(self, evt):
2639         if self.radio_default_dict.GetValue() :
2640             self.otherdictpath.Enable( False )
2641             self.m_sdbSizer1OK.Enable( True )
2642         else :
2643             self.otherdictpath.Enable( True )
2644             if self.otherdictpath.GetPath() == '' :
2645                 self.m_sdbSizer1OK.Enable( False )
2646     
2647     def selectdict(self, evt):
2648         if self.otherdictpath.GetPath() != '' :
2649             self.m_sdbSizer1OK.Enable( True )
2650         
2651
2652
2653 class ConcordList(wx.HtmlListBox):
2654     def __init__(self, parent, concord):
2655         self.concord = concord
2656         #self.script_status = dict()
2657         wx.HtmlListBox.__init__(self, parent, -1, size = (900, 600))
2658         self.SetItemCount(len(concord))
2659         #self.Bind(wx.EVT_LISTBOX, self.RefreshMe)
2660         #self.Bind(wx.EVT_LISTBOX_DCLICK, self.Download)
2661   
2662     def OnGetItem(self, index):
2663         return self.concord[index] #+ '<br>'
2664
2665 class message(wx.Frame):
2666     def __init__(self, parent, items, title, size, save = True, uceids = None):
2667         wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.CLOSE_BOX|wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.TAB_TRAVERSAL )
2668         self.save = save
2669         self.uceids = uceids
2670         self.ira = wx.GetApp().GetTopWindow()
2671         self.SetIcon(self.ira._icon)
2672         #self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2673         self.items = items
2674         self.html = ""
2675         #self.HtmlPage=wx.html.HtmlWindow(self, -1)
2676         self.panel = wx.Panel(self, wx.ID_ANY)
2677         self.HtmlPage = ConcordList(self.panel, items)
2678         #self.HtmlPage.SetMinSize( size )
2679         #if "gtk2" in wx.PlatformInfo:
2680         #    self.HtmlPage.SetStandardFonts()
2681         #self.HtmlPage.SetFonts('Courier','Courier')
2682
2683         self.button_1 = wx.Button(self.panel, wx.ID_CANCEL)
2684
2685         self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
2686         if self.save :
2687             self.button_2 = wx.Button(self.panel, wx.ID_SAVE)
2688             self.Bind(wx.EVT_BUTTON, self.OnSavePage, self.button_2)
2689         if self.uceids is not None :
2690             self.butsub = wx.Button(self.panel, -1, _(u"Build sub corpus").decode('utf8'))
2691             self.Bind(wx.EVT_BUTTON, self.OnSub, self.butsub)
2692         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
2693         self.__do_layout()
2694
2695     def __do_layout(self):
2696         sizer_2 = wx.BoxSizer(wx.VERTICAL)
2697         sizer_2.Add(self.HtmlPage, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
2698         #m_sdbSizer1 = wx.StdDialogButtonSizer()
2699         m_sdbSizer1 = wx.BoxSizer(wx.HORIZONTAL)
2700         m_sdbSizer1.Add(  self.button_1 , 0, wx.ALIGN_RIGHT | wx.EXPAND)
2701         if self.save :
2702             m_sdbSizer1.Add(  self.button_2 , 0, wx.ALIGN_RIGHT | wx.EXPAND)
2703         if self.uceids is not None :
2704             m_sdbSizer1.Add(  self.butsub , 0, wx.ALIGN_RIGHT | wx.EXPAND)
2705         #m_sdbSizer1.Realize()
2706         #self.panel.SetSizer( m_sdbSizer1 )
2707         sizer_2.Add( m_sdbSizer1, 0, wx.ALIGN_RIGHT, 5)
2708         self.panel.SetSizer(sizer_2)
2709         self.panel.Layout()
2710         sizer_2.Fit( self )
2711
2712     def OnSavePage(self, evt) :
2713         dlg = wx.FileDialog(
2714             self, message=_(u"Save as ...").decode('utf8'), defaultDir=os.getcwd(),
2715             defaultFile="concordancier.html", wildcard="html|*.html", style=wx.SAVE | wx.OVERWRITE_PROMPT
2716             )
2717         #dlg.SetFilterIndex(2)
2718         dlg.CenterOnParent()
2719         self.html = '<br>'.join([self.items[i] for i in range(0,len(self.items))])
2720         if dlg.ShowModal() == wx.ID_OK:
2721             path = dlg.GetPath()
2722             with open(path, 'w') as f :
2723                 f.write(self.html)
2724
2725     def OnCloseMe(self, event):
2726         self.Close(True)
2727
2728     def OnCloseWindow(self, event):
2729         self.Destroy()
2730     
2731     def OnSub(self ,evt):
2732         parametres = {'fromuceids' : True, 'uceids' : self.uceids, 'isempty' : True}
2733         self.ira.OnSubText(wx.MenuEvent(), None, parametres)
2734
2735
2736 class ExtractDialog ( wx.Dialog ):
2737     
2738     def __init__( self, parent, option ):
2739         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
2740
2741         self.option = option
2742         
2743         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2744         
2745         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2746         fgSizer1.SetFlexibleDirection( wx.BOTH )
2747         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2748         
2749         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"corpus").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2750         self.m_staticText1.Wrap( -1 )
2751         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2752         
2753         self.corpusfile = wx.FilePickerCtrl( self, wx.ID_ANY, wx.EmptyString, _(u"Select a file").decode('utf8'), u"*.txt", wx.DefaultPosition, wx.Size( -1,-1 ), wx.FLP_DEFAULT_STYLE|wx.FLP_FILE_MUST_EXIST|wx.FLP_OPEN )
2754         self.corpusfile.SetMinSize( wx.Size( 500,-1 ) )
2755         
2756         fgSizer1.Add( self.corpusfile, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2757         
2758         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Characters set").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2759         self.m_staticText2.Wrap( -1 )
2760         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2761         
2762         encodageChoices = [' - '.join(encodage) for encodage in encodages]
2763         self.encodage = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, encodageChoices, 0 )
2764         self.encodage.SetSelection( 0 )
2765         self.encodage.SetMinSize( wx.Size( 200,-1 ) )
2766         
2767         fgSizer1.Add( self.encodage, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2768         
2769         if option == 'splitvar' :
2770             self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Variables (with the * but without the _)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2771             self.m_staticText3.Wrap( -1 )
2772             fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2773             
2774             self.txtvar = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2775             self.txtvar.SetMinSize( wx.Size( 200,-1 ) )
2776             
2777             fgSizer1.Add( self.txtvar, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2778         
2779         if option == 'mods' :
2780             self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Modalities (one by line, with the *)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2781             self.m_staticText4.Wrap( -1 )
2782             fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2783             
2784             self.txtmods = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE )
2785             self.txtmods.SetMinSize( wx.Size( 200,150 ) )
2786             
2787             fgSizer1.Add( self.txtmods, 0, wx.ALL|wx.EXPAND, 5 )
2788             
2789             self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Extraction type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2790             self.m_staticText5.Wrap( -1 )
2791             fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2792             
2793             extractformatChoices = [ _(u"Only one file").decode('utf8'), _(u"One file by modality").decode('utf8') ]
2794             self.extractformat = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, extractformatChoices, 1, wx.RA_SPECIFY_COLS )
2795             self.extractformat.SetSelection( 0 )
2796             fgSizer1.Add( self.extractformat, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2797         
2798         if option == 'them' :
2799             self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"thematics (one by line, with the -*)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2800             self.m_staticText4.Wrap( -1 )
2801             fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2802             
2803             self.txtmods = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE )
2804             self.txtmods.SetMinSize( wx.Size( 200,150 ) )
2805             
2806             fgSizer1.Add( self.txtmods, 0, wx.ALL|wx.EXPAND, 5 )
2807             
2808             #self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Extraction type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2809             #self.m_staticText5.Wrap( -1 )
2810             #fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2811             
2812             #extractformatChoices = [ _(u"Only one file").decode('utf8'), _(u"One file by thematic").decode('utf8') ]
2813             #self.extractformat = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, extractformatChoices, 1, wx.RA_SPECIFY_COLS )
2814             #self.extractformat.SetSelection( 0 )
2815             #fgSizer1.Add( self.extractformat, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )        
2816             
2817         
2818         fgSizer1.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
2819         
2820         m_sdbSizer1 = wx.StdDialogButtonSizer()
2821         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2822         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2823         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2824         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2825         m_sdbSizer1.Realize()
2826         
2827         fgSizer1.Add( m_sdbSizer1, 1, wx.EXPAND, 5 )
2828         
2829         
2830         self.SetSizer( fgSizer1 )
2831         self.Layout()
2832         fgSizer1.Fit( self )
2833         
2834         self.Centre( wx.BOTH )
2835
2836     def make_param(self) :
2837         parametres = {}
2838         le = [enc[0].lower() for enc in encodages]
2839         parametres['filein'] = self.corpusfile.GetPath()
2840         encodage = le[self.encodage.GetSelection()]
2841         parametres['encodein'] = encodage
2842         if self.option == 'splitvar' :
2843             parametres['var'] = self.txtvar.GetValue()
2844         if self.option == 'mods' :
2845             parametres['mods'] = self.txtmods.GetValue().splitlines()
2846             if self.extractformat.GetSelection() == 0 :
2847                 parametres['onefile'] = True
2848             else :
2849                 parametres['onefile'] = False
2850         if self.option == 'them' :
2851             parametres['them'] = self.txtmods.GetValue().splitlines()
2852         #    if self.extractformat.GetSelection() == 0 :
2853         #        parametres['onefile'] = True
2854         #    else :
2855         #        parametres['onefile'] = False        
2856         parametres['encodeout'] = le[self.encodage.GetSelection()]
2857         return parametres
2858     
2859     def __del__( self ):
2860         pass
2861
2862 class FreqDialog ( wx.Dialog ):
2863     
2864     def __init__( self, parent, listcol, title, size =  wx.Size( -1,-1 ), showNA = True):
2865         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.DEFAULT_DIALOG_STYLE )
2866         
2867         self.header = listcol
2868         
2869         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2870         
2871         bSizer1 = wx.BoxSizer( wx.VERTICAL )
2872         
2873         m_listBox1Choices = self.header
2874         self.m_listBox1 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox1Choices, wx.LB_EXTENDED|wx.LB_HSCROLL )
2875         self.m_listBox1.SetMinSize( wx.Size( 500,-1 ) )
2876         bSizer1.Add( self.m_listBox1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2877         
2878         if showNA :
2879             fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2880             fgSizer1.SetFlexibleDirection( wx.BOTH )
2881             fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2882         
2883             self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Include empty cells (NA)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2884             self.m_staticText1.Wrap( -1 )
2885             fgSizer1.Add( self.m_staticText1, 0, wx.ALL, 5 )
2886         
2887             self.includeNA = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2888             fgSizer1.Add( self.includeNA, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2889         
2890             bSizer1.Add( fgSizer1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5 )
2891         
2892         m_sdbSizer1 = wx.StdDialogButtonSizer()
2893         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2894         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2895         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2896         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2897         m_sdbSizer1.Realize();
2898         
2899         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
2900         
2901         
2902         self.SetSizer( bSizer1 )
2903         self.Layout()
2904         bSizer1.Fit( self )
2905         
2906         self.Centre( wx.BOTH )
2907         self.Bind(wx.EVT_LISTBOX, self.selchange, self.m_listBox1)
2908         self.m_sdbSizer1OK.Enable(False)
2909     
2910     def __del__( self ):
2911         pass
2912     
2913     def selchange(self, evt):
2914         if len(self.m_listBox1.GetSelections()) == 0 :
2915             self.m_sdbSizer1OK.Enable(False)
2916         else :
2917             self.m_sdbSizer1OK.Enable(True)
2918
2919 class ProtoDial ( wx.Dialog ):
2920     
2921     def __init__( self, parent, headers ):
2922         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
2923         
2924         self.SetSizeHintsSz( wx.Size( -1,-1 ), wx.DefaultSize )
2925         
2926         bSizer1 = wx.BoxSizer( wx.VERTICAL )
2927         
2928         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2929         fgSizer1.SetFlexibleDirection( wx.BOTH )
2930         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2931         
2932         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Variables").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2933         self.m_staticText1.Wrap( -1 )
2934         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
2935         
2936         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Ranks").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2937         self.m_staticText2.Wrap( -1 )
2938         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
2939         
2940         variablesChoices = headers
2941         self.variables = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, variablesChoices, wx.LB_HSCROLL|wx.LB_MULTIPLE )
2942         self.variables.SetMinSize( wx.Size( 350,-1 ) )
2943         
2944         fgSizer1.Add( self.variables, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2945         
2946         rangsChoices = headers
2947         self.rangs = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, rangsChoices, wx.LB_HSCROLL|wx.LB_MULTIPLE )
2948         self.rangs.SetMinSize( wx.Size( 350,-1 ) )
2949         
2950         fgSizer1.Add( self.rangs, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2951         
2952         
2953         bSizer1.Add( fgSizer1, 1, wx.ALIGN_CENTER_HORIZONTAL, 5 )
2954         
2955         fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
2956         fgSizer3.SetFlexibleDirection( wx.BOTH )
2957         fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2958         
2959         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Limit frequency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2960         self.m_staticText3.Wrap( -1 )
2961         fgSizer3.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2962         
2963         bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
2964         
2965         choix_freqChoices = [ _(u"automatic (mean)").decode('utf8'), _(u"manual").decode('utf8') ]
2966         self.choix_freq = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choix_freqChoices, 0 )
2967         self.choix_freq.SetSelection( 0 )
2968         bSizer2.Add( self.choix_freq, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2969         
2970         self.freqlim = wx.TextCtrl( self, wx.ID_ANY, u"0", wx.DefaultPosition, wx.DefaultSize, wx.TE_CENTRE )
2971         self.freqlim.Enable( False )
2972         self.freqlim.SetMinSize( wx.Size( 100,-1 ) )
2973         
2974         bSizer2.Add( self.freqlim, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2975         
2976         
2977         fgSizer3.Add( bSizer2, 1, wx.EXPAND, 5 )
2978         
2979         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Limit rank").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2980         self.m_staticText4.Wrap( -1 )
2981         fgSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2982         
2983         bSizer21 = wx.BoxSizer( wx.HORIZONTAL )
2984         
2985         choix_rangChoices = [ _(u"automatic (mean)").decode('utf8'), _(u"manual").decode('utf8')]
2986         self.choix_rang = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choix_rangChoices, 0 )
2987         self.choix_rang.SetSelection( 0 )
2988         bSizer21.Add( self.choix_rang, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2989         
2990         self.ranglim = wx.TextCtrl( self, wx.ID_ANY, u"0", wx.DefaultPosition, wx.DefaultSize, wx.TE_CENTRE )
2991         self.ranglim.Enable( False )
2992         self.ranglim.SetMinSize( wx.Size( 100,-1 ) )
2993         
2994         bSizer21.Add( self.ranglim, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2995         
2996         
2997         fgSizer3.Add( bSizer21, 1, wx.EXPAND, 5 )
2998         
2999         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Minimum frequency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
3000         self.m_staticText5.Wrap( -1 )
3001         fgSizer3.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3002         
3003         self.m_textCtrl4 = wx.TextCtrl( self, wx.ID_ANY, u"2", wx.DefaultPosition, wx.DefaultSize, wx.TE_CENTRE )
3004         fgSizer3.Add( self.m_textCtrl4, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
3005         
3006         self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, u"Type de représentation", wx.DefaultPosition, wx.DefaultSize, 0 )
3007         self.m_staticText6.Wrap( -1 )
3008         fgSizer3.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3009         
3010         m_choice3Choices = [ u"Classical - List", u"Classical - Cloud", u"Plan" ]
3011         self.typegraph = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice3Choices, 0 )
3012         self.typegraph.SetSelection( 0 )
3013         fgSizer3.Add( self.typegraph, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
3014         
3015         bSizer1.Add( fgSizer3, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 )
3016         
3017         m_sdbSizer1 = wx.StdDialogButtonSizer()
3018         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
3019         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
3020         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
3021         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
3022         m_sdbSizer1.Realize();
3023         
3024         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
3025         
3026         self.SetSizer( bSizer1 )
3027         self.Layout()
3028         bSizer1.Fit( self )
3029         
3030         self.Centre( wx.BOTH )
3031         
3032         # Connect Events
3033         self.choix_freq.Bind( wx.EVT_CHOICE, self.UpdateText )
3034         self.choix_rang.Bind( wx.EVT_CHOICE, self.UpdateText )
3035         self.Bind(wx.EVT_LISTBOX, self.selchange, self.variables)
3036         self.Bind(wx.EVT_LISTBOX, self.selchange, self.rangs)
3037         
3038         self.m_sdbSizer1OK.Enable(False)
3039     
3040     def __del__( self ):
3041         pass
3042     
3043     def selchange(self, evt):
3044         if (len(self.variables.GetSelections()) == 0) or (len(self.rangs.GetSelections()) == 0) or (len(self.variables.GetSelections()) != len(self.rangs.GetSelections())) :
3045             self.m_sdbSizer1OK.Enable(False)
3046         else :
3047             self.m_sdbSizer1OK.Enable(True)
3048     
3049     
3050     # Virtual event handlers, overide them in your derived class
3051     def UpdateText( self, event ):
3052         event.Skip()
3053
3054 class SimpleDialog ( wx.Dialog ):
3055     
3056     def __init__( self, parent ):
3057         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
3058         
3059         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
3060         
3061         bSizer1 = wx.BoxSizer( wx.VERTICAL )
3062         
3063         self.m_panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
3064         bSizer2 = wx.BoxSizer( wx.VERTICAL )
3065         
3066         self.m_staticText1 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Export finished. Open in a web browser :").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
3067         self.m_staticText1.Wrap( -1 )
3068         bSizer2.Add( self.m_staticText1, 0, wx.ALL, 5 )
3069         
3070         self.link = wx.HyperlinkCtrl( self.m_panel1, wx.ID_ANY, u"wxFB Website", u"http://www.wxformbuilder.org", wx.DefaultPosition, wx.DefaultSize, wx.HL_DEFAULT_STYLE )
3071         bSizer2.Add( self.link, 0, wx.ALL, 5 )
3072         
3073         
3074         self.m_panel1.SetSizer( bSizer2 )
3075         self.m_panel1.Layout()
3076         bSizer2.Fit( self.m_panel1 )
3077         bSizer1.Add( self.m_panel1, 1, wx.EXPAND |wx.ALL, 5 )
3078         
3079         m_sdbSizer1 = wx.StdDialogButtonSizer()
3080         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
3081         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
3082         m_sdbSizer1.Realize();
3083         
3084         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
3085         
3086         
3087         self.SetSizer( bSizer1 )
3088         self.Layout()
3089         bSizer1.Fit( self )
3090         
3091         self.Centre( wx.BOTH )
3092     
3093     def __del__( self ):
3094         pass
3095
3096
3097 class SubTextFromMetaDial ( wx.Dialog ):
3098     
3099     def __init__( self, parent, parametres ):
3100         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Subcorpus").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
3101         
3102         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
3103         
3104         bSizer1 = wx.BoxSizer( wx.VERTICAL )
3105         
3106         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
3107         fgSizer1.SetFlexibleDirection( wx.BOTH )
3108         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
3109         
3110         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Name").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
3111         self.m_staticText1.Wrap( -1 )
3112         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3113         
3114         self.subcorpusname = wx.TextCtrl( self, wx.ID_ANY, parametres['corpus_name'], wx.DefaultPosition, wx.Size( 300,-1 ), 0 )
3115         fgSizer1.Add( self.subcorpusname, 0, wx.ALL, 5 )
3116         
3117         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Select one or more metadata").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
3118         self.m_staticText2.Wrap( -1 )
3119         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3120         
3121         m_listBox1Choices = parametres['meta']
3122         self.m_listBox1 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( -1,-1 ), m_listBox1Choices, wx.LB_HSCROLL|wx.LB_MULTIPLE )
3123         self.m_listBox1.SetMinSize( wx.Size( -1,200 ) )
3124         self.m_listBox1.SetMaxSize( wx.Size( -1,500 ) )
3125         
3126         fgSizer1.Add( self.m_listBox1, 0, wx.ALL|wx.EXPAND, 5 )
3127         
3128         
3129         bSizer1.Add( fgSizer1, 1, wx.EXPAND, 5 )
3130         
3131         m_sdbSizer1 = wx.StdDialogButtonSizer()
3132         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
3133         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
3134         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
3135         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
3136         m_sdbSizer1.Realize();
3137         
3138         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
3139         
3140         
3141         self.SetSizer( bSizer1 )
3142         self.Layout()
3143         bSizer1.Fit( self )
3144         
3145         self.Centre( wx.BOTH )
3146         self.Bind(wx.EVT_LISTBOX, self.onchoose, self.m_listBox1)
3147         if not parametres.get('isempty', False) :
3148             self.m_sdbSizer1OK.Enable(False)
3149     
3150     def __del__( self ):
3151         pass
3152     
3153     def onchoose(self, evt):
3154         if len(self.m_listBox1.GetSelections()) > 0 :
3155             self.m_sdbSizer1OK.Enable(True)
3156         else :
3157             self.m_sdbSizer1OK.Enable(False)
3158
3159 class BarGraphDialog ( wx.Dialog ):
3160     
3161     def __init__( self, parent, width, height ):
3162         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"Preferences").decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
3163         
3164         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
3165         
3166         bSizer1 = wx.BoxSizer( wx.VERTICAL )
3167         
3168         bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
3169         
3170         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
3171         self.m_staticText1.Wrap( -1 )
3172         bSizer2.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3173         
3174         sizeradioChoices = [ _(u"automatic").decode('utf8'), _(u"manual").decode('utf8') ]
3175         self.sizeradio = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, sizeradioChoices, 1, wx.RA_SPECIFY_COLS )
3176         self.sizeradio.SetSelection( 0 )
3177         bSizer2.Add( self.sizeradio, 0, wx.ALIGN_TOP|wx.ALL, 5 )
3178         
3179         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
3180         fgSizer1.SetFlexibleDirection( wx.BOTH )
3181         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
3182         
3183         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"width").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
3184         self.m_staticText2.Wrap( -1 )
3185         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3186         
3187         self.widthsp = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000000, 600 )
3188         fgSizer1.Add( self.widthsp, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3189         
3190         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"height").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
3191         self.m_staticText3.Wrap( -1 )
3192         fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3193         
3194         self.heightsp = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000000, 400 )
3195         fgSizer1.Add( self.heightsp, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3196         
3197         
3198         bSizer2.Add( fgSizer1, 1, wx.EXPAND, 5 )
3199         
3200         
3201         bSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
3202         
3203         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
3204         
3205         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Image format").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
3206         self.m_staticText4.Wrap( -1 )
3207         bSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3208         
3209         formatChoices = [ u"png", u"svg" ]
3210         self.format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, formatChoices, 0 )
3211         self.format.SetSelection( 0 )
3212         bSizer3.Add( self.format, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3213         
3214         
3215         bSizer1.Add( bSizer3, 1, wx.EXPAND, 5 )
3216         
3217         m_sdbSizer1 = wx.StdDialogButtonSizer()
3218         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
3219         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
3220         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
3221         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
3222         m_sdbSizer1.Realize();
3223         
3224         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
3225         
3226         
3227         self.SetSizer( bSizer1 )
3228         self.Layout()
3229         bSizer1.Fit( self )
3230         
3231         self.Centre( wx.BOTH )
3232         
3233         # Connect Events
3234         self.sizeradio.Bind( wx.EVT_RADIOBOX, self.OnSizeRadio )
3235         
3236         self.widthsp.SetValue(width)
3237         self.heightsp.SetValue(height)
3238         self.widthsp.Enable(False)
3239         self.heightsp.Enable(False)
3240         self.m_sdbSizer1OK.SetFocus()
3241     
3242     def __del__( self ):
3243         pass
3244     
3245     
3246     # Virtual event handlers, overide them in your derived class
3247     def OnSizeRadio( self, event ):
3248         if self.sizeradio.GetSelection() == 0 :
3249             self.widthsp.Enable(False)
3250             self.heightsp.Enable(False)
3251         else :
3252             self.widthsp.Enable(True)
3253             self.heightsp.Enable(True)         
3254         event.Skip()
3255
3256 class ImageViewer ( wx.Frame ):
3257     
3258     def __init__( self, parent, parametres, title, size ):
3259         wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.DEFAULT_FRAME_STYLE|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX|wx.STAY_ON_TOP|wx.TAB_TRAVERSAL )
3260         
3261         self.ira = wx.GetApp().GetTopWindow()
3262         self.SetIcon(self.ira._icon)
3263         self.parametres = parametres
3264         self.imageFile = self.parametres['tmpgraph']
3265         if parametres['svg'] == 'TRUE' :
3266             self.imagename = u"image.svg"
3267         else :
3268             self.imagename = u"image.png"
3269         
3270         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
3271         
3272         bSizer1 = wx.BoxSizer( wx.VERTICAL )
3273         
3274         self.m_panel1 = wx.ScrolledWindow(self, -1)# wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL|wx.TAB_TRAVERSAL|wx.VSCROLL )
3275         self.m_panel1.SetScrollbars(1, 1, 200, 300)
3276         bSizer2 = wx.BoxSizer( wx.VERTICAL )
3277         
3278         if parametres['svg'] == 'FALSE' :
3279             image = wx.Image(self.imageFile, wx.BITMAP_TYPE_PNG)
3280             W = image.GetWidth()
3281             H = image.GetHeight()
3282             if W > 1000 :
3283                 W = 1000
3284             if H > 800 :
3285                 H = 800
3286             image = image.ConvertToBitmap()
3287             self.m_bitmap1 = wx.StaticBitmap( self.m_panel1, wx.ID_ANY, image, wx.DefaultPosition, wx.DefaultSize, 0 )
3288             bSizer2.Add( self.m_bitmap1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3289         else :
3290             link = hl.HyperLinkCtrl(self.m_panel1, wx.ID_ANY, u"Click on this link", URL=self.imageFile )
3291             bSizer2.Add( link, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3292         
3293         self.m_panel1.SetSizer( bSizer2 )
3294         self.m_panel1.Layout()
3295         bSizer2.Fit( self.m_panel1 )
3296         bSizer1.Add( self.m_panel1, 1, wx.EXPAND |wx.ALL, 5 )
3297         
3298         panel = wx.Panel(self, -1)
3299         m_sdbSizer1 = wx.StdDialogButtonSizer()
3300         self.m_sdbSizer1Save = wx.Button( panel, wx.ID_SAVE )
3301         m_sdbSizer1.AddButton( self.m_sdbSizer1Save )
3302         self.m_sdbSizer1Cancel = wx.Button( panel, wx.ID_CANCEL )
3303         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
3304         m_sdbSizer1.Realize();
3305         
3306         panel.SetSizer( m_sdbSizer1 )
3307         
3308         bSizer1.Add( panel, 0, wx.EXPAND, 5 )
3309         
3310         
3311         self.SetSizer( bSizer1 )
3312         self.Layout()
3313         
3314         self.Centre( wx.BOTH )
3315         
3316         if parametres['svg'] == 'FALSE' :
3317             self.SetSize((W + 30,H + 30))
3318         
3319         self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.m_sdbSizer1Cancel)
3320         self.Bind(wx.EVT_BUTTON, self.OnSaveImage, self.m_sdbSizer1Save)
3321     
3322     def __del__( self ):
3323         pass
3324     
3325     def OnCloseMe(self, event):
3326         self.Destroy()    
3327
3328     def OnSaveImage(self, event) :
3329         dlg = wx.FileDialog(
3330             self, message=_(u"Save as...").decode('utf8'), defaultDir=os.getcwd(),
3331             defaultFile= self.imagename, wildcard=self.parametres['wildcard'], style=wx.SAVE | wx.OVERWRITE_PROMPT
3332             )
3333         dlg.SetFilterIndex(0)
3334         dlg.CenterOnParent()
3335         if dlg.ShowModal() == wx.ID_OK:
3336             path = dlg.GetPath()
3337             copyfile(self.imageFile, path)
3338
3339 class BarFrame :
3340     def __init__(self, ira, table, colnames, rownames, tree = False):
3341         if not tree :
3342             width = 100 + (10*len(rownames)) + (100 * len(colnames))
3343             height = len(rownames) * 15
3344             if height < 400 : 
3345                 height = 400
3346         else :
3347             width = 500
3348             height = (35 * len(colnames)) + (15 * len(rownames))
3349         dial = BarGraphDialog(ira, width, height)
3350         val = dial.ShowModal()
3351         if val == wx.ID_OK :
3352             tmpgraph = tempfile.mktemp(dir=ira.TEMPDIR)        
3353             if dial.format.GetSelection() == 0 :
3354                 svg = 'FALSE'
3355                 wildcard = "png|*.png"
3356             else :
3357                 svg = 'TRUE'
3358                 wildcard = "svg|*.svg"
3359             parametres = {'width' : dial.widthsp.GetValue(),
3360                           'height': dial.heightsp.GetValue(),
3361                           'colnames' : colnames,
3362                           'rownames' : rownames,
3363                           'tmpgraph' : tmpgraph,
3364                           'rgraph' : ira.RscriptsPath['Rgraph'],
3365                           'svg' : svg,
3366                           'wildcard' : wildcard}
3367             if tree :
3368                 parametres['tree'] = tree
3369             txt = barplot(table, parametres)
3370             tmpscript = tempfile.mktemp(dir=ira.TEMPDIR)
3371             with open(tmpscript,'w') as f :
3372                 f.write(txt)
3373             exec_rcode(ira.RPath, tmpscript, wait = True)
3374             win = ImageViewer(ira, parametres, _(u"Graphic").decode('utf8'), size=(700, 500))
3375             win.Show(True)
3376         dial.Destroy()           
3377
3378 class MergeDialog ( wx.Dialog ):
3379     
3380     def __init__( self, parent ):
3381         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE|wx.MINIMIZE_BOX )
3382         
3383         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
3384         
3385         bSizer1 = wx.BoxSizer( wx.VERTICAL )
3386         
3387         self.m_scrolledWindow1 = wx.ScrolledWindow( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 600,200 ), wx.HSCROLL|wx.VSCROLL )
3388         self.m_scrolledWindow1.SetScrollRate( 5, 5 )
3389         #self.m_scrolledWindow1.SetMinSize( wx.Size( 500,200 ) )
3390         
3391         fgSizer2 = wx.FlexGridSizer( 0, 2, 0, 0 )
3392         fgSizer2.AddGrowableCol( 1 )
3393         fgSizer2.SetFlexibleDirection( wx.BOTH )
3394         fgSizer2.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_ALL )
3395         
3396         self.m_staticText3 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"graphe 1", wx.DefaultPosition, wx.DefaultSize, 0 )
3397         self.m_staticText3.Wrap( -1 )
3398         fgSizer2.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3399         
3400         self.m_filePicker3 = wx.FilePickerCtrl( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, u"Select a file", u"*.*", wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE|wx.FLP_FILE_MUST_EXIST|wx.FLP_USE_TEXTCTRL )
3401         self.m_filePicker3.SetMinSize( wx.Size( 400,-1 ) )
3402         
3403         fgSizer2.Add( self.m_filePicker3, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
3404         
3405         self.m_staticText4 = wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, u"graphe 2", wx.DefaultPosition, wx.DefaultSize, 0 )
3406         self.m_staticText4.Wrap( -1 )
3407         fgSizer2.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3408         
3409         self.m_filePicker4 = wx.FilePickerCtrl( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, u"Select a file", u"*.*", wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE|wx.FLP_FILE_MUST_EXIST|wx.FLP_USE_TEXTCTRL )
3410         self.m_filePicker4.SetMinSize( wx.Size( 400,-1 ) )
3411         
3412         fgSizer2.Add( self.m_filePicker4, 1, wx.ALL|wx.EXPAND, 5 )
3413         
3414         
3415         self.m_scrolledWindow1.SetSizer( fgSizer2 )
3416         self.m_scrolledWindow1.Layout()
3417         bSizer1.Add( self.m_scrolledWindow1, 0, wx.ALL, 5 )
3418         
3419         self.button_add = wx.Button( self, wx.ID_ANY, u"Add graphe", wx.DefaultPosition, wx.DefaultSize, 0 )
3420         bSizer1.Add( self.button_add, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3421         
3422         m_sdbSizer1 = wx.StdDialogButtonSizer()
3423         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
3424         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
3425         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
3426         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
3427         m_sdbSizer1.Realize();
3428         
3429         bSizer1.Add( m_sdbSizer1, 1, wx.EXPAND, 5 )
3430         
3431         
3432         self.SetSizer( bSizer1 )
3433         self.Layout()
3434         bSizer1.Fit( self )
3435         
3436         self.Centre( wx.BOTH )
3437         
3438         # Connect Events
3439         self.button_add.Bind( wx.EVT_BUTTON, self.OnAddGraphe )
3440         self.m_filePicker3.Bind(wx.EVT_FILEPICKER_CHANGED, self.OnFileChange)
3441         self.m_filePicker4.Bind(wx.EVT_FILEPICKER_CHANGED, self.OnFileChange)
3442         self.finish(fgSizer2, bSizer1)
3443     
3444     def __del__( self ):
3445         pass
3446     
3447     def finish(self, fgSizer2, bSizer1):
3448         self.graphs = [self.m_filePicker3, self.m_filePicker4]
3449         self.fgSizer2 = fgSizer2
3450         self.bSizer1 = bSizer1
3451     
3452     def OnFileChange(self, evt):
3453         obj = evt.GetEventObject()
3454         if obj.GetPath() != '' :
3455             for graph in self.graphs :
3456                 graph.SetInitialDirectory(os.path.dirname(obj.GetPath()))
3457     
3458     # Virtual event handlers, overide them in your derived class
3459     def OnAddGraphe( self, event ):
3460         lab =  wx.StaticText( self.m_scrolledWindow1, wx.ID_ANY, ' '.join(['graphe', `len(self.graphs) + 1`]), wx.DefaultPosition, wx.DefaultSize, 0 )
3461         lab.Wrap(-1)
3462         self.graphs.append( wx.FilePickerCtrl( self.m_scrolledWindow1, wx.ID_ANY, wx.EmptyString, u"Select a file", u"*.*", wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE|wx.FLP_FILE_MUST_EXIST|wx.FLP_USE_TEXTCTRL ) )
3463         self.graphs[-1].SetMinSize( wx.Size( 400, -1))
3464         if self.graphs[-2].GetPath() != '' :
3465             self.graphs[-1].SetInitialDirectory(os.path.dirname(self.graphs[-2].GetPath()))
3466         self.graphs[-1].Bind(wx.EVT_FILEPICKER_CHANGED, self.OnFileChange)
3467         self.fgSizer2.Add( lab, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3468         self.fgSizer2.Add( self.graphs[-1], 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
3469         self.m_scrolledWindow1.Layout()
3470         self.m_scrolledWindow1.SetSizer( self.fgSizer2 )
3471         #self.fgSizer2.Fit( self.m_scrolledWindow1 )
3472         self.Layout()
3473         #self.bSizer1.Fit(self)
3474         event.Skip()
3475     
3476     def RemoveGraphe(self, evt ):
3477         pass