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