...
[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").decode('utf8'), 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").decode('utf8'), 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").decode('utf8'), 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").decode('utf8'), 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").decode('utf8'), 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").decode('utf8'), _(u"other").decode('utf8') ]
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 | wx.STAY_ON_TOP )
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.Bind(wx.EVT_LISTBOX, self.onchoose, self.list_box_1)
1743         self.__set_properties()
1744         self.__do_layout()
1745         # end wxGlade
1746
1747     def __set_properties(self):
1748         # begin wxGlade: MyDialog.__set_properties
1749         self.SetTitle(_(u"Variables choice").decode('utf8'))
1750         if not self.force_chi :
1751             self.spin.SetValue(10)
1752         self.choice.SetSelection(0)
1753         self.choice_indice.SetSelection(0)
1754         self.button_1.Enable(False)
1755         #self.SetMinSize(wx.Size(300, 400))
1756         # end wxGlade
1757
1758     def __do_layout(self):
1759         # begin wxGlade: MyDialog.__do_layout
1760         sizer_1 = wx.BoxSizer(wx.VERTICAL)
1761         sizer_2 = wx.FlexGridSizer(0,2,0,0)
1762         sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
1763         #sizer_2.Add(self.labellem, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1764         #sizer_2.Add(self.checklem, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1765         if not self.force_chi :
1766             sizer_2.Add(self.label_typeformes, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1767             sizer_2.Add(self.typeformes, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1768         sizer_2.Add(self.label_var, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1769         sizer_2.Add(self.choice, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1770         sizer_2.Add(self.label1, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1771         sizer_2.Add(self.list_box_1, 0, wx.ALIGN_RIGHT, 3)
1772         sizer_3.Add(self.button_2, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1773         sizer_3.Add(self.button_1, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1774         sizer_2.Add(self.label_indice, 0, wx.ALIGN_CENTER_VERTICAL, 3)
1775         sizer_2.Add(self.choice_indice, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1776         if not self.force_chi :
1777             sizer_2.Add(self.label, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 3)
1778             sizer_2.Add(self.spin, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 3)
1779         sizer_1.Add(sizer_2, 0, wx.ALIGN_CENTER_HORIZONTAL, 3)
1780         sizer_1.Add(sizer_3, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_RIGHT, 3)
1781         self.SetSizer(sizer_1)
1782         sizer_1.Fit(self)
1783         self.Layout()
1784         self.Centre()
1785
1786     def onselect(self, evt):
1787         self.list_box_1.Clear()
1788         if self.choice.GetSelection() == 0 :
1789             for var in self.variables :
1790                 self.list_box_1.Append(var)
1791         else :
1792             for et in self.listet :
1793                 self.list_box_1.Append(et)
1794     
1795     def onchoose(self, evt):
1796         if self.choice.GetSelection()== 0 :
1797             if len(self.list_box_1.GetSelections()) > 0 :
1798                 self.button_1.Enable(True)
1799             else :
1800                 self.button_1.Enable(False)
1801         elif self.choice.GetSelection() == 1 :
1802             if len(self.list_box_1.GetSelections()) > 1 :
1803                 self.button_1.Enable(True)
1804             else :
1805                 self.button_1.Enable(False)    
1806
1807 class PrefDendro ( wx.Dialog ):
1808     
1809     def __init__( self, parent, param ):
1810         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 )
1811         self.param = param
1812         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1813         
1814         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
1815         fgSizer1.SetFlexibleDirection( wx.BOTH )
1816         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1817         
1818         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Picture size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1819         self.m_staticText1.Wrap( -1 )
1820         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1821         
1822         bSizer2 = wx.BoxSizer( wx.VERTICAL )
1823         
1824         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
1825         
1826         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"height").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1827         self.m_staticText2.Wrap( -1 )
1828         bSizer3.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1829         
1830         self.m_spinCtrl1 = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 50, 10000, 600 )
1831         bSizer3.Add( self.m_spinCtrl1, 0, wx.ALL, 5 )
1832         
1833         bSizer2.Add( bSizer3, 1, wx.EXPAND, 5 )
1834         
1835         bSizer31 = wx.BoxSizer( wx.HORIZONTAL )
1836         
1837         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"width").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1838         self.m_staticText3.Wrap( -1 )
1839         bSizer31.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1840         
1841         self.m_spinCtrl2 = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 50, 10000, 600 )
1842         bSizer31.Add( self.m_spinCtrl2, 0, wx.ALL, 5 )
1843         
1844         bSizer2.Add( bSizer31, 1, wx.EXPAND, 5 )
1845         
1846         fgSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
1847         
1848         self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1849         fgSizer1.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )
1850         
1851         self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1852         fgSizer1.Add( self.m_staticline2, 0, wx.EXPAND |wx.ALL, 5 )
1853         
1854         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Dendrogram type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1855         self.m_staticText4.Wrap( -1 )
1856         fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1857         
1858         m_choice1Choices = [ u"phylogram", u"cladogram", u"fan", u"unrooted", u"radial" ]
1859         self.m_choice1 = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice1Choices, 0 )
1860         self.m_choice1.SetSelection( 0 )
1861         fgSizer1.Add( self.m_choice1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1862         
1863         self.m_staticline3 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1864         fgSizer1.Add( self.m_staticline3, 0, wx.EXPAND |wx.ALL, 5 )
1865         
1866         self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1867         fgSizer1.Add( self.m_staticline4, 0, wx.EXPAND |wx.ALL, 5 )
1868     
1869         self.text_format_image = wx.StaticText( self, wx.ID_ANY, _(u"Image format").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1870         self.text_format_image.Wrap( -1 )
1871         fgSizer1.Add( self.text_format_image, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1872         
1873         self.choice_format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ['png', 'svg'], 0 )
1874         self.choice_format.SetSelection( 0 )
1875         fgSizer1.Add( self.choice_format, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1876         
1877         self.m_staticline31 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1878         fgSizer1.Add( self.m_staticline31, 0, wx.EXPAND |wx.ALL, 5 )
1879         
1880         self.m_staticline41 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1881         fgSizer1.Add( self.m_staticline41, 0, wx.EXPAND |wx.ALL, 5 )        
1882         
1883         
1884         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Color or black and white").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1885         self.m_staticText5.Wrap( -1 )
1886         fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1887         
1888         m_radioBox1Choices = [ _(u"color").decode('utf8'), _(u"black and white").decode('utf8') ]
1889         self.m_radioBox1 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox1Choices, 1, wx.RA_SPECIFY_COLS )
1890         self.m_radioBox1.SetSelection( 0 )
1891         fgSizer1.Add( self.m_radioBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1892         
1893         self.m_staticline5 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1894         fgSizer1.Add( self.m_staticline5, 0, wx.EXPAND |wx.ALL, 5 )
1895         
1896         self.m_staticline6 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1897         fgSizer1.Add( self.m_staticline6, 0, wx.EXPAND |wx.ALL, 5 )
1898         
1899         bSizer4 = wx.BoxSizer( wx.HORIZONTAL )
1900         
1901         self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, _(u"Add cluster size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1902         self.m_staticText6.Wrap( -1 )
1903         bSizer4.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1904         
1905         self.m_checkBox1 = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
1906         self.m_checkBox1.SetValue(True) 
1907         bSizer4.Add( self.m_checkBox1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1908         
1909         fgSizer1.Add( bSizer4, 1, wx.EXPAND, 5 )
1910         
1911         m_radioBox2Choices = [ _(u"circular diagram").decode('utf8'), _(u"bar").decode('utf8') ]
1912         self.m_radioBox2 = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, m_radioBox2Choices, 1, wx.RA_SPECIFY_COLS )
1913         self.m_radioBox2.SetSelection( 0 )
1914         fgSizer1.Add( self.m_radioBox2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
1915         
1916         self.m_staticline7 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1917         fgSizer1.Add( self.m_staticline7, 0, wx.EXPAND |wx.ALL, 5 )
1918         
1919         self.m_staticline8 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1920         fgSizer1.Add( self.m_staticline8, 0, wx.EXPAND |wx.ALL, 5 )
1921         
1922         
1923         fgSizer1.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
1924         
1925         m_sdbSizer2 = wx.StdDialogButtonSizer()
1926         self.m_sdbSizer2OK = wx.Button( self, wx.ID_OK )
1927         m_sdbSizer2.AddButton( self.m_sdbSizer2OK )
1928         self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL )
1929         m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel )
1930         m_sdbSizer2.Realize();
1931         fgSizer1.Add( m_sdbSizer2, 1, wx.EXPAND, 5 )
1932         
1933         self.__set_properties()
1934         self.SetSizer( fgSizer1 )
1935         self.Layout()
1936         fgSizer1.Fit( self )
1937         
1938         self.Centre( wx.BOTH )
1939
1940     def __set_properties(self):
1941         self.m_spinCtrl2.SetValue(self.param['width'])
1942         self.m_spinCtrl1.SetValue(self.param['height'])
1943         self.m_choice1.SetSelection(self.param['type_dendro'])
1944         self.m_radioBox1.SetSelection(self.param['color_nb'])
1945         self.m_checkBox1.SetValue(self.param['taille_classe'])
1946         self.m_radioBox2.SetSelection(self.param['type_tclasse'])
1947         self.choice_format.SetSelection(self.param['svg'])
1948     
1949     def __del__( self ):
1950         pass
1951
1952
1953 class PrefWordCloud ( wx.Dialog ):
1954     
1955     def __init__( self, parent, fromcluster = False ):
1956         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 )
1957         
1958         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1959         
1960         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
1961         fgSizer1.SetFlexibleDirection( wx.BOTH )
1962         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1963         
1964         #self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Sélectionner les formes", wx.DefaultPosition, wx.DefaultSize, 0 )
1965         #self.m_staticText1.Wrap( -1 )
1966         #fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1967         
1968         #self.but_selectcol = wx.Button( self, wx.ID_ANY, u"Sélectionner", wx.DefaultPosition, wx.DefaultSize, 0 )
1969         #fgSizer1.Add( self.but_selectcol, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1970         
1971         #self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1972         #fgSizer1.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )
1973         
1974         #self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
1975         #fgSizer1.Add( self.m_staticline2, 0, wx.EXPAND |wx.ALL, 5 )
1976         
1977         bSizer1 = wx.BoxSizer( wx.HORIZONTAL )
1978         
1979         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"height").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1980         self.m_staticText3.Wrap( -1 )
1981         bSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1982         
1983         self.spin_H = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 100,30 ), wx.SP_ARROW_KEYS, 0, 10000, 600 )
1984         self.spin_H.SetValue( 800 )
1985         bSizer1.Add( self.spin_H, 0, wx.ALL, 5 )
1986         
1987         fgSizer1.Add( bSizer1, 1, wx.EXPAND, 5 )
1988         
1989         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
1990         
1991         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"width").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1992         self.m_staticText4.Wrap( -1 )
1993         bSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1994         
1995         self.spin_L = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 100,30 ), wx.SP_ARROW_KEYS, 0, 10000, 600 )
1996         self.spin_L.SetValue( 800 )
1997         bSizer3.Add( self.spin_L, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1998         
1999         fgSizer1.Add( bSizer3, 1, wx.EXPAND, 5 )
2000         
2001         self.m_staticline3 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2002         fgSizer1.Add( self.m_staticline3, 0, wx.EXPAND |wx.ALL, 5 )
2003         
2004         self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2005         fgSizer1.Add( self.m_staticline4, 0, wx.EXPAND |wx.ALL, 5 )
2006         
2007         self.m_staticText11 = wx.StaticText( self, wx.ID_ANY, _(u"Picture format").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2008         self.m_staticText11.Wrap( -1 )
2009         fgSizer1.Add( self.m_staticText11, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2010         
2011         formatChoices = [ u"png", u"svg" ]
2012         self.format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, formatChoices, 0 )
2013         self.format.SetSelection( 0 )
2014         fgSizer1.Add( self.format, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2015
2016         if fromcluster :
2017             self.m_staticText111 = wx.StaticText( self, wx.ID_ANY, _(u"Word size proportional to ...").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2018             self.m_staticText11.Wrap( -1 )
2019             fgSizer1.Add( self.m_staticText111, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2020         
2021             IndiceChoices = [ _(u"chi2").decode('utf8'), _(u"frequency").decode('utf8') ]
2022             self.indice = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, IndiceChoices, 0 )
2023             self.indice.SetSelection( 0 )
2024             fgSizer1.Add( self.indice, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2025
2026         self.m_staticline13 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2027         fgSizer1.Add( self.m_staticline13, 0, wx.EXPAND |wx.ALL, 5 )
2028         
2029         self.m_staticline14 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2030         fgSizer1.Add( self.m_staticline14, 0, wx.EXPAND |wx.ALL, 5 )
2031
2032         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Maximum number of forms").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2033         self.m_staticText5.Wrap( -1 )
2034         fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2035         
2036         self.spin_maxword = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 10000, 600 )
2037         self.spin_maxword.SetValue( 600 )
2038         fgSizer1.Add( self.spin_maxword, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2039         
2040         self.m_staticline5 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2041         fgSizer1.Add( self.m_staticline5, 0, wx.EXPAND |wx.ALL, 5 )
2042         
2043         self.m_staticline6 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2044         fgSizer1.Add( self.m_staticline6, 0, wx.EXPAND |wx.ALL, 5 )
2045         
2046         self.typeformes = wx.StaticText( self, wx.ID_ANY, _(u"Used forms").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2047         self.typeformes.Wrap( -1 )
2048         fgSizer1.Add( self.typeformes, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2049         
2050         typeformeschoiceChoices = [ _(u"actives").decode('utf8'), _(u"supplementaries").decode('utf8'), _(u"actives and supplementaries").decode('utf8') ]
2051         self.typeformeschoice = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, typeformeschoiceChoices, 0 )
2052         self.typeformeschoice.SetSelection( 0 )
2053         fgSizer1.Add( self.typeformeschoice, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2054         
2055         self.m_staticline11 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2056         fgSizer1.Add( self.m_staticline11, 0, wx.EXPAND |wx.ALL, 5 )
2057         
2058         self.m_staticline12 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2059         fgSizer1.Add( self.m_staticline12, 0, wx.EXPAND |wx.ALL, 5 )        
2060         
2061         self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, _(u"Text size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2062         self.m_staticText6.Wrap( -1 )
2063         fgSizer1.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2064         
2065         bSizer4 = wx.BoxSizer( wx.VERTICAL )
2066         
2067         bSizer5 = wx.BoxSizer( wx.HORIZONTAL )
2068         
2069         self.m_staticText7 = wx.StaticText( self, wx.ID_ANY, u"Min", wx.DefaultPosition, wx.DefaultSize, 0 )
2070         self.m_staticText7.Wrap( -1 )
2071         bSizer5.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2072         
2073         self.spin_mincex = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 5 )
2074         self.spin_mincex.SetValue( 5 )
2075         bSizer5.Add( self.spin_mincex, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
2076         
2077         bSizer4.Add( bSizer5, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
2078         
2079         bSizer6 = wx.BoxSizer( wx.HORIZONTAL )
2080         
2081         self.m_staticText8 = wx.StaticText( self, wx.ID_ANY, u"Max", wx.DefaultPosition, wx.DefaultSize, 0 )
2082         self.m_staticText8.Wrap( -1 )
2083         bSizer6.Add( self.m_staticText8, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2084         
2085         self.spin_maxcex = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000, 50 )
2086         self.spin_maxcex.SetValue( 50 )
2087         bSizer6.Add( self.spin_maxcex, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2088         
2089         bSizer4.Add( bSizer6, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
2090         
2091         fgSizer1.Add( bSizer4, 1, wx.EXPAND, 5 )
2092         
2093         self.m_staticline7 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2094         fgSizer1.Add( self.m_staticline7, 0, wx.EXPAND |wx.ALL, 5 )
2095         
2096         self.m_staticline8 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2097         fgSizer1.Add( self.m_staticline8, 0, wx.EXPAND |wx.ALL, 5 )
2098         
2099         bSizer61 = wx.BoxSizer( wx.HORIZONTAL )
2100         
2101         self.m_staticText81 = wx.StaticText( self, wx.ID_ANY, _(u"Text color").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2102         self.m_staticText81.Wrap( -1 )
2103         bSizer61.Add( self.m_staticText81, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2104         
2105         self.color_text = wx.ColourPickerCtrl( self, wx.ID_ANY, wx.BLACK, wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE )
2106         bSizer61.Add( self.color_text, 0, wx.ALL, 5 )
2107         
2108         fgSizer1.Add( bSizer61, 1, wx.EXPAND, 5 )
2109         
2110         bSizer7 = wx.BoxSizer( wx.HORIZONTAL )
2111         
2112         self.m_staticText9 = wx.StaticText( self, wx.ID_ANY, _(u"Background color").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2113         self.m_staticText9.Wrap( -1 )
2114         bSizer7.Add( self.m_staticText9, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2115         
2116         self.color_bg = wx.ColourPickerCtrl( self, wx.ID_ANY, (255,255,255), wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE )
2117         bSizer7.Add( self.color_bg, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2118         
2119         fgSizer1.Add( bSizer7, 1, wx.EXPAND, 5 )
2120         
2121         self.m_staticline9 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2122         fgSizer1.Add( self.m_staticline9, 0, wx.EXPAND |wx.ALL, 5 )
2123         
2124         self.m_staticline10 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
2125         fgSizer1.Add( self.m_staticline10, 0, wx.EXPAND |wx.ALL, 5 )
2126
2127         fgSizer1.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
2128         
2129         m_sdbSizer1 = wx.StdDialogButtonSizer()
2130         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2131         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2132         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2133         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2134         m_sdbSizer1.Realize();
2135         fgSizer1.Add( m_sdbSizer1, 1, wx.EXPAND, 5 )
2136         
2137         self.SetSizer( fgSizer1 )
2138         self.Layout()
2139         fgSizer1.Fit( self )
2140         
2141         self.Centre( wx.BOTH )
2142     
2143     def __del__( self ):
2144         pass
2145     
2146 class PrefChi(sc.SizedDialog):
2147     def __init__(self, parent, ID, optionchi, title):
2148
2149         sc.SizedDialog.__init__(self, None, -1, _(u"Settings").decode('utf8'), 
2150                         style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
2151         pane = self.GetContentsPane()
2152         pane.SetSizerType("form")
2153         pane.SetSizerProps(border=("all",5))
2154         self.parent = parent
2155         self.optionchi = optionchi
2156         
2157
2158         self.label_obs = wx.StaticText(pane, -1, _(u"observed values").decode('utf8'))
2159         self.check1 = wx.CheckBox(pane, -1)
2160  
2161         self.label_theo = wx.StaticText(pane, -1, _(u"expected values").decode('utf8'))
2162         self.check2 = wx.CheckBox(pane, -1)
2163
2164         self.label_resi = wx.StaticText(pane, -1, _(u"residuals").decode('utf8'))
2165         self.check3 = wx.CheckBox(pane, -1)
2166
2167         self.label_contrib = wx.StaticText(pane, -1, _(u"standardized residuals").decode('utf8'))
2168         self.check4 = wx.CheckBox(pane, -1)
2169 #        self.label_graph = wx.StaticText(pane, -1, u'graphique')
2170 #        self.check8 = wx.CheckBox(pane, -1)
2171         self.label_pourcent = wx.StaticText(pane, -1, _(u"total percentage").decode('utf8'))
2172         self.check5 = wx.CheckBox(pane, -1)
2173
2174         self.label_prl = wx.StaticText(pane, -1, _(u"row percentage").decode('utf8'))
2175         self.check6 = wx.CheckBox(pane, -1)
2176
2177         self.label_prc = wx.StaticText(pane, -1, _(u"column percentage").decode('utf8'))
2178         self.check7 = wx.CheckBox(pane, -1)
2179
2180         self.label_graph = wx.StaticText(pane, -1, _(u"graphical").decode('utf8'))
2181         self.check8 = wx.CheckBox(pane, -1)
2182         
2183         self.label_graphbw = wx.StaticText(pane, -1, _(u"black and white graphical").decode('utf8'))
2184         self.checkbw = wx.CheckBox(pane, -1)
2185
2186         self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL))
2187
2188         self.__set_properties()
2189         self.Fit()
2190         self.SetMinSize(self.GetSize())
2191
2192     def __set_properties(self):
2193         self.check1.SetValue(self.optionchi['valobs'])
2194         self.check2.SetValue(self.optionchi['valtheo'])
2195         self.check3.SetValue(self.optionchi['resi'])
2196         self.check4.SetValue(self.optionchi['contrib'])
2197         self.check5.SetValue(self.optionchi['pourcent'])
2198         self.check6.SetValue(self.optionchi['pourcentl'])
2199         self.check7.SetValue(self.optionchi['pourcentc'])
2200         self.check8.SetValue(self.optionchi['graph'])
2201         self.checkbw.SetValue(self.optionchi['bw'])
2202
2203 class ChiDialog(wx.Dialog):
2204     def __init__(
2205             self, parent, ID, title, optionchi, tableau, size=wx.DefaultSize, pos=wx.DefaultPosition, 
2206             style=wx.DEFAULT_DIALOG_STYLE
2207             ):
2208
2209         pre = wx.PreDialog()
2210         pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
2211         pre.Create(parent, ID, title, pos, size, style)
2212
2213         self.PostCreate(pre)
2214         self.parent = parent 
2215         self.optionchi = optionchi
2216         self.chiopt = False
2217         self.tableau = tableau
2218         #self.Filename=parent.filename
2219         #self.content=parent.content[:]
2220         self.headers=self.tableau.get_colnames()
2221         LABELLIST=[]
2222         
2223         for i in self.headers:
2224             if len(i)>60 :
2225                 LABELLIST.append(i[0:60])
2226             else:
2227                 LABELLIST.append(i)
2228         
2229         self.ListOK=[]
2230         self.LabelListOK=LABELLIST
2231  
2232         self.list_box_1 = wx.ListBox(self, -1, choices=self.LabelListOK, style=wx.LB_EXTENDED|wx.LB_HSCROLL)
2233         self.list_box_2 = wx.ListBox(self, -1, choices=self.LabelListOK, style=wx.LB_EXTENDED|wx.LB_HSCROLL)
2234         self.button_1 = wx.Button(self, wx.ID_OK)
2235         self.button_cancel = wx.Button(self, wx.ID_CANCEL)
2236         self.button_pref = wx.Button(self, wx.ID_PREFERENCES)
2237         self.__set_properties()
2238         self.__do_layout()
2239
2240         self.Bind(wx.EVT_LISTBOX, self.Select1, self.list_box_1)
2241         self.Bind(wx.EVT_BUTTON, self.onparam, self.button_pref)
2242         # end wxGlade
2243 #-------------------------------
2244     def __set_properties(self):
2245         # begin wxGlade: ConfChi2.__set_properties
2246         self.SetTitle(_(u"Variables selection").decode('utf8'))
2247
2248     def __do_layout(self):
2249         # begin wxGlade: ConfChi2.__do_layout
2250         sizer_1 = wx.BoxSizer(wx.VERTICAL)
2251         sizer_2 = wx.BoxSizer(wx.VERTICAL)
2252         sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
2253         sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
2254         sizer_3.Add(self.list_box_1, 0, wx.EXPAND, 0)
2255         sizer_3.Add(self.list_box_2, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 0)
2256         sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
2257         sizer_4.Add(self.button_cancel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 0)
2258         sizer_4.Add(self.button_pref, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 0)
2259         sizer_4.Add(self.button_1, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 0)
2260         sizer_2.Add(sizer_4, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
2261         sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
2262         self.SetSizer(sizer_1)
2263         sizer_1.Fit(self)
2264         self.Layout()
2265         # end wxGlade
2266
2267     def Select1(self, event): # wxGlade: ConfChi2.<event_handler>
2268         event.Skip()
2269     
2270     
2271     def onparam(self,event):
2272         self.dial = PrefChi(self.parent, -1, self.optionchi, '')
2273         self.dial.CenterOnParent()
2274         self.chiopt = self.dial.ShowModal()
2275
2276 class CorpusPref ( wx.Dialog ):
2277     
2278     def __init__( self, parent, parametres ):
2279         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 )
2280         self.parent = parent 
2281         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...']
2282         self.langues = [u'french', u'english', u'german', u'italian', u'swedish', u'portuguese', u'spanish', u'greek', u'galician', u'other']
2283         self.encodages = [enc[0].lower() for enc in encodages]
2284
2285         ucimark = [u'****', u'0000']
2286         ucemethod = [_(u"characters").decode('utf8'), _(u"occurrences").decode('utf8'), _(u"paragraphs").decode('utf8')]
2287
2288         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2289         
2290         bSizer1 = wx.BoxSizer( wx.VERTICAL )
2291         
2292         self.m_notebook1 = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
2293         self.m_panel1 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
2294         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2295         fgSizer1.SetFlexibleDirection( wx.BOTH )
2296         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2297         
2298         self.m_staticText7 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"corpus").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2299         self.m_staticText7.Wrap( -1 )
2300         fgSizer1.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2301         
2302         self.txtpath = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Path").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2303         self.txtpath.Wrap( -1 )
2304         fgSizer1.Add( self.txtpath, 0, wx.ALL, 5 )
2305
2306         self.m_staticText18 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Corpus' name").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2307         self.m_staticText18.Wrap( -1 )
2308         fgSizer1.Add( self.m_staticText18, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2309         
2310         self.corpusname = wx.TextCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 200,-1 ), 0 )
2311         fgSizer1.Add( self.corpusname, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2312              
2313         self.m_staticText1 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Characters set").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2314         self.m_staticText1.Wrap( -1 )
2315         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2316         
2317         encodage_choicesChoices = [' - '.join(encodage) for encodage in encodages]
2318         self.encodage_choices = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, encodage_choicesChoices, 0 )
2319         self.encodage_choices.SetSelection( 0 )
2320         fgSizer1.Add( self.encodage_choices, 0, wx.ALL, 5 )
2321         
2322         self.m_staticText2 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Language").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2323         self.m_staticText2.Wrap( -1 )
2324         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2325         
2326         lang_choicesChoices = langues_n
2327         self.lang_choices = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, lang_choicesChoices, 0 )
2328         self.lang_choices.SetSelection( 0 )
2329         fgSizer1.Add( self.lang_choices, 0, wx.ALL, 5 )
2330
2331         self.m_staticText19 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Dictionary").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2332         self.m_staticText19.Wrap( -1 )
2333         fgSizer1.Add( self.m_staticText19, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2334         
2335         bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
2336         
2337         fgSizer5 = wx.FlexGridSizer( 2, 2, 0, 0 )
2338         fgSizer5.SetFlexibleDirection( wx.BOTH )
2339         fgSizer5.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2340         
2341         self.radio_default_dict = wx.RadioButton( self.m_panel1, wx.ID_ANY, _(u"Default").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2342         fgSizer5.Add( self.radio_default_dict, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2343         
2344         self.defaultdictpath = wx.TextCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 300,-1 ), wx.TE_READONLY )
2345         self.defaultdictpath.Enable( False )
2346         
2347         fgSizer5.Add( self.defaultdictpath, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2348         
2349         self.radio_other_dict = wx.RadioButton( self.m_panel1, wx.ID_ANY, _(u"Other").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2350         fgSizer5.Add( self.radio_other_dict, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2351         
2352         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 )
2353         self.otherdictpath.SetMinSize(wx.Size(300, -1))
2354         fgSizer5.Add( self.otherdictpath, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2355         self.otherdictpath.Enable( False )
2356         
2357         
2358         bSizer2.Add( fgSizer5, 1, wx.EXPAND, 5 )
2359         
2360         
2361         fgSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
2362
2363         self.m_staticText3 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Output folder").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2364         self.m_staticText3.Wrap( -1 )
2365         fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2366         
2367         
2368         fgSizer41 = wx.FlexGridSizer( 0, 2, 0, 0 )
2369         fgSizer41.SetFlexibleDirection( wx.BOTH )
2370         fgSizer41.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2371         
2372         self.repout_choices = wx.TextCtrl( self.m_panel1, wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0 )
2373         self.repout_choices.SetMinSize( wx.Size( 400,-1 ) )
2374         fgSizer41.Add( self.repout_choices, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2375         
2376         self.m_button1 = wx.Button( self.m_panel1, wx.ID_ANY, _(u"Change ...").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2377         fgSizer41.Add( self.m_button1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2378         
2379         fgSizer1.Add( fgSizer41, 1, wx.EXPAND, 5 )        
2380
2381         self.m_staticText12 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Text mark").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2382         self.m_staticText12.Wrap( -1 )
2383         fgSizer1.Add( self.m_staticText12, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2384         
2385         ucimark_choicesChoices = ucimark
2386         self.ucimark_choices = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ucimark_choicesChoices, 0 )
2387         self.ucimark_choices.SetSelection( 0 )
2388         fgSizer1.Add( self.ucimark_choices, 0, wx.ALL, 5 )
2389         
2390         self.m_staticText6 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Use the expression dictionary").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2391         self.m_staticText6.Wrap( -1 )
2392         fgSizer1.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2393         
2394         self.check_expressions = wx.CheckBox( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2395         self.check_expressions.SetValue(True) 
2396         fgSizer1.Add( self.check_expressions, 0, wx.ALL, 5 )
2397         
2398         self.m_staticText9 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Make text segments").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2399         self.m_staticText9.Wrap( -1 )
2400         fgSizer1.Add( self.m_staticText9, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2401         
2402         self.check_makeuce = wx.CheckBox( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2403         self.check_makeuce.SetValue(True) 
2404         fgSizer1.Add( self.check_makeuce, 0, wx.ALL, 5 )
2405         
2406         self.m_staticText10 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Text segments build process").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2407         self.m_staticText10.Wrap( -1 )
2408         fgSizer1.Add( self.m_staticText10, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2409         
2410         uce_modeChoices = ucemethod
2411         self.uce_mode = wx.Choice( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, uce_modeChoices, 0 )
2412         self.uce_mode.SetSelection( 0 )
2413         fgSizer1.Add( self.uce_mode, 0, wx.ALL, 5 )
2414         
2415         self.m_staticText13 = wx.StaticText( self.m_panel1, wx.ID_ANY, _(u"Text segments size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2416         self.m_staticText13.Wrap( -1 )
2417         fgSizer1.Add( self.m_staticText13, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2418         
2419         self.uce_size = wx.SpinCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 1000000, 40 )
2420         fgSizer1.Add( self.uce_size, 0, wx.ALL, 5 )
2421         
2422         
2423         self.m_panel1.SetSizer( fgSizer1 )
2424         self.m_panel1.Layout()
2425         fgSizer1.Fit( self.m_panel1 )
2426         self.m_notebook1.AddPage( self.m_panel1, _(u"General").decode('utf8'), True )
2427         self.m_panel2 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
2428         fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
2429         fgSizer3.SetFlexibleDirection( wx.BOTH )
2430         fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2431         
2432         self.m_staticText4 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Put text in lowercase").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2433         self.m_staticText4.Wrap( -1 )
2434         fgSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2435         
2436         self.check_lower = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2437         self.check_lower.SetValue(True) 
2438         fgSizer3.Add( self.check_lower, 0, wx.ALL, 5 )
2439         
2440         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 )
2441         self.m_staticText5.Wrap( -1 )
2442         fgSizer3.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2443         
2444         fgSizer4 = wx.FlexGridSizer( 0, 2, 0, 0 )
2445         fgSizer4.SetFlexibleDirection( wx.BOTH )
2446         fgSizer4.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2447         
2448         self.check_charact = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2449         self.check_charact.SetValue(True) 
2450         fgSizer4.Add( self.check_charact, 0, wx.ALL, 5 )
2451         
2452         self.txt_charact = wx.TextCtrl( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2453         self.txt_charact.SetMinSize( wx.Size( 400,-1 ) )
2454         
2455         fgSizer4.Add( self.txt_charact, 0, wx.ALL|wx.EXPAND, 5 )
2456         
2457         
2458         fgSizer3.Add( fgSizer4, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
2459         
2460         self.m_staticText14 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Replace apostrophe by space").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2461         self.m_staticText14.Wrap( -1 )
2462         fgSizer3.Add( self.m_staticText14, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2463         
2464         self.check_apos = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2465         self.check_apos.SetValue(True) 
2466         fgSizer3.Add( self.check_apos, 0, wx.ALL, 5 )
2467         
2468         self.m_staticText15 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Replace dash by space").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2469         self.m_staticText15.Wrap( -1 )
2470         fgSizer3.Add( self.m_staticText15, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2471         
2472         self.check_tirets = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2473         self.check_tirets.SetValue(True) 
2474         fgSizer3.Add( self.check_tirets, 0, wx.ALL, 5 )
2475         
2476         self.m_staticText17 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Keep punctuation").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2477         self.m_staticText17.Wrap( -1 )
2478         fgSizer3.Add( self.m_staticText17, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2479         
2480         self.check_ponct = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2481         fgSizer3.Add( self.check_ponct, 0, wx.ALL, 5 )
2482
2483         self.m_staticText16 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"No space between two forms").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2484         self.m_staticText16.Wrap( -1 )
2485         fgSizer3.Add( self.m_staticText16, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2486         
2487         self.check_tolist = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2488         fgSizer3.Add( self.check_tolist, 0, wx.ALL, 5 )
2489         
2490         
2491         self.m_panel2.SetSizer( fgSizer3 )
2492         self.m_panel2.Layout()
2493         fgSizer3.Fit( self.m_panel2 )
2494         self.m_notebook1.AddPage( self.m_panel2, _(u"Cleaning").decode('utf8'), False )
2495         
2496         bSizer1.Add( self.m_notebook1, 1, wx.EXPAND |wx.ALL, 5 )
2497         
2498         m_sdbSizer1 = wx.StdDialogButtonSizer()
2499         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2500         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2501         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2502         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2503         m_sdbSizer1.Realize();
2504         
2505         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
2506        
2507
2508         # Connect Events
2509         self.Bind(wx.EVT_BUTTON, self.OnChangeDir, self.m_button1)
2510         self.lang_choices.Bind( wx.EVT_CHOICE, self.OnChangeLangage )
2511         self.radio_other_dict.Bind( wx.EVT_RADIOBUTTON, self.changedictchoice )
2512         self.radio_default_dict.Bind( wx.EVT_RADIOBUTTON, self.changedictchoice )
2513         self.otherdictpath.Bind( wx.EVT_FILEPICKER_CHANGED, self.selectdict) 
2514
2515         self.setparametres(parametres) 
2516         self.SetSizer( bSizer1 )
2517         self.Layout()
2518         bSizer1.Fit( self )
2519         
2520         self.Centre( wx.BOTH )
2521
2522     def OnChangeDir(self, evt) :
2523         dlg = wx.DirDialog(self.parent, _(u"Choose a folder").decode('utf8'), style = wx.DD_DEFAULT_STYLE)
2524         if dlg.ShowModal() == wx.ID_OK :
2525             self.repout_choices.SetValue(dlg.GetPath())
2526     
2527     def __del__( self ):
2528         pass
2529
2530     def setparametres(self, parametres) :
2531         if  locale.getpreferredencoding().lower() == 'mac-roman' :
2532             enc = self.encodages.index('macroman')
2533         else :
2534             try :
2535                 enc = self.encodages.index(locale.getpreferredencoding().lower())
2536             except ValueError :
2537                 enc = self.encodages.index('utf-8')
2538         self.encodage_choices.SetSelection(enc)
2539         self.lang_choices.SetSelection(0)
2540         self.repout_choices.SetValue(parametres['pathout'])
2541         self.corpusname.SetValue(parametres['corpus_name'])
2542         self.ucimark_choices.SetSelection(parametres['ucimark'])
2543         self.check_expressions.SetValue(parametres['expressions'])
2544         self.check_makeuce.SetValue(parametres['douce'])
2545         self.uce_mode.SetSelection(parametres['ucemethod'])
2546         self.uce_size.SetValue(parametres['ucesize'])
2547         self.check_lower.SetValue(parametres['lower'])
2548         #self.check_charact.SetValue(parametres['charact'])
2549         self.txt_charact.SetValue(parametres['keep_caract'])
2550         self.check_apos.SetValue(parametres['apos'])
2551         self.check_tirets.SetValue(parametres['tiret'])
2552         self.check_tolist.SetValue(parametres['tolist'])
2553         self.check_ponct.SetValue(parametres['keep_ponct'])
2554         self.defaultdictpath.SetValue(self.langues[0])
2555
2556     def doparametres(self) :
2557         parametres = {}
2558         parametres['encoding'] = encodages[self.encodage_choices.GetSelection()][0]
2559         parametres['lang'] = self.langues[self.lang_choices.GetSelection()]
2560         parametres['pathout'] = self.repout_choices.GetValue()
2561         parametres['corpus_name'] = self.corpusname.GetValue()
2562         parametres['ucimark'] = self.ucimark_choices.GetSelection()
2563         parametres['expressions'] = self.check_expressions.GetValue()
2564         parametres['douce'] =  self.check_makeuce.GetValue()
2565         parametres['ucemethod'] = self.uce_mode.GetSelection()
2566         parametres['ucesize'] = self.uce_size.GetValue()
2567         parametres['lower'] = self.check_lower.GetValue()
2568         parametres['charact'] = self.check_charact.GetValue()
2569         parametres['keep_caract'] = self.txt_charact.GetValue()
2570         parametres['apos'] = self.check_apos.GetValue()
2571         parametres['tiret'] = self.check_tirets.GetValue()
2572         parametres['tolist'] = self.check_tolist.GetValue()
2573         parametres['keep_ponct'] = self.check_ponct.GetValue()
2574         if self.radio_other_dict.GetValue() :
2575             parametres['dictionary'] = self.otherdictpath.GetPath()
2576         for val in parametres :
2577             if isinstance(parametres[val], bool) :
2578                 if parametres[val] :
2579                     parametres[val] = 1
2580                 else :
2581                     parametres[val] = 0
2582         return parametres
2583     
2584     def OnChangeLangage(self, evt):
2585         self.defaultdictpath.SetValue(self.langues[self.lang_choices.GetSelection()])
2586     
2587     def changedictchoice(self, evt):
2588         if self.radio_default_dict.GetValue() :
2589             self.otherdictpath.Enable( False )
2590             self.m_sdbSizer1OK.Enable( True )
2591         else :
2592             self.otherdictpath.Enable( True )
2593             if self.otherdictpath.GetPath() == '' :
2594                 self.m_sdbSizer1OK.Enable( False )
2595     
2596     def selectdict(self, evt):
2597         if self.otherdictpath.GetPath() != '' :
2598             self.m_sdbSizer1OK.Enable( True )
2599         
2600
2601
2602 class ConcordList(wx.HtmlListBox):
2603     def __init__(self, parent, concord):
2604         self.concord = concord
2605         #self.script_status = dict()
2606         wx.HtmlListBox.__init__(self, parent, -1, size = (900, 600))
2607         self.SetItemCount(len(concord))
2608         #self.Bind(wx.EVT_LISTBOX, self.RefreshMe)
2609         #self.Bind(wx.EVT_LISTBOX_DCLICK, self.Download)
2610   
2611     def OnGetItem(self, index):
2612         return self.concord[index] #+ '<br>'
2613
2614 class message(wx.Frame):
2615     def __init__(self, parent, items, title, size, save = True, uceids = None):
2616         wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.CLOSE_BOX|wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.TAB_TRAVERSAL )
2617         self.save = save
2618         self.uceids = uceids
2619         self.ira = wx.GetApp().GetTopWindow()
2620         self.SetIcon(self.ira._icon)
2621         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2622         self.items = items
2623         self.html = ""
2624         #self.HtmlPage=wx.html.HtmlWindow(self, -1)
2625         self.HtmlPage = ConcordList(self, items)
2626         #self.HtmlPage.SetMinSize( size )
2627         #if "gtk2" in wx.PlatformInfo:
2628         #    self.HtmlPage.SetStandardFonts()
2629         #self.HtmlPage.SetFonts('Courier','Courier')
2630
2631         self.button_1 = wx.Button(self, wx.ID_CANCEL)
2632
2633         self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
2634         if self.save :
2635             self.button_2 = wx.Button(self, wx.ID_SAVE)
2636             self.Bind(wx.EVT_BUTTON, self.OnSavePage, self.button_2)
2637         if self.uceids is not None :
2638             self.butsub = wx.Button(self, -1, _(u"Build sub corpus").decode('utf8'))
2639             self.Bind(wx.EVT_BUTTON, self.OnSub, self.butsub)
2640         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
2641         self.__do_layout()
2642
2643     def __do_layout(self):
2644         sizer_2 = wx.BoxSizer(wx.VERTICAL)
2645         sizer_2.Add(self.HtmlPage, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
2646         #m_sdbSizer1 = wx.StdDialogButtonSizer()
2647         m_sdbSizer1 = wx.BoxSizer(wx.HORIZONTAL)
2648         m_sdbSizer1.Add(  self.button_1 , 0, wx.RIGHT | wx.EXPAND)
2649         if self.save :
2650             m_sdbSizer1.Add(  self.button_2 , 0, wx.RIGHT | wx.EXPAND)
2651         if self.uceids is not None :
2652             m_sdbSizer1.Add(  self.butsub , 0, wx.RIGHT | wx.EXPAND)
2653         #m_sdbSizer1.Realize()
2654         sizer_2.Add(m_sdbSizer1, 0, wx.RIGHT | wx.EXPAND, 5)
2655         self.SetSizer(sizer_2)
2656         self.Layout()
2657         sizer_2.Fit( self )
2658
2659     def OnSavePage(self, evt) :
2660         dlg = wx.FileDialog(
2661             self, message=_(u"Save as ...").decode('utf8'), defaultDir=os.getcwd(),
2662             defaultFile="concordancier.html", wildcard="html|*.html", style=wx.SAVE | wx.OVERWRITE_PROMPT
2663             )
2664         dlg.SetFilterIndex(2)
2665         dlg.CenterOnParent()
2666         self.html = '<br>'.join([self.items[i] for i in range(0,len(self.items))])
2667         if dlg.ShowModal() == wx.ID_OK:
2668             path = dlg.GetPath()
2669             with open(path, 'w') as f :
2670                 f.write(self.html)
2671
2672     def OnCloseMe(self, event):
2673         self.Close(True)
2674
2675     def OnCloseWindow(self, event):
2676         self.Destroy()
2677     
2678     def OnSub(self ,evt):
2679         parametres = {'fromuceids' : True, 'uceids' : self.uceids}
2680         self.ira.OnSubText(None, parametres)
2681
2682
2683
2684 class ExtractDialog ( wx.Dialog ):
2685     
2686     def __init__( self, parent, option ):
2687         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
2688
2689         self.option = option
2690         
2691         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2692         
2693         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2694         fgSizer1.SetFlexibleDirection( wx.BOTH )
2695         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2696         
2697         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"corpus").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2698         self.m_staticText1.Wrap( -1 )
2699         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
2700         
2701         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 )
2702         self.corpusfile.SetMinSize( wx.Size( 500,-1 ) )
2703         
2704         fgSizer1.Add( self.corpusfile, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2705         
2706         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Characters set").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2707         self.m_staticText2.Wrap( -1 )
2708         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2709         
2710         encodageChoices = [' - '.join(encodage) for encodage in encodages]
2711         self.encodage = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, encodageChoices, 0 )
2712         self.encodage.SetSelection( 0 )
2713         self.encodage.SetMinSize( wx.Size( 200,-1 ) )
2714         
2715         fgSizer1.Add( self.encodage, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2716         
2717         if option == 'splitvar' :
2718             self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Variables (with the * but without the _)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2719             self.m_staticText3.Wrap( -1 )
2720             fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2721             
2722             self.txtvar = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2723             self.txtvar.SetMinSize( wx.Size( 200,-1 ) )
2724             
2725             fgSizer1.Add( self.txtvar, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2726         
2727         if option == 'mods' :
2728             self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Modalities (one by line, with the *)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2729             self.m_staticText4.Wrap( -1 )
2730             fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2731             
2732             self.txtmods = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE )
2733             self.txtmods.SetMinSize( wx.Size( 200,150 ) )
2734             
2735             fgSizer1.Add( self.txtmods, 0, wx.ALL|wx.EXPAND, 5 )
2736             
2737             self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Extraction type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2738             self.m_staticText5.Wrap( -1 )
2739             fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2740             
2741             extractformatChoices = [ _(u"Only one file").decode('utf8'), _(u"One file by modality").decode('utf8') ]
2742             self.extractformat = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, extractformatChoices, 1, wx.RA_SPECIFY_COLS )
2743             self.extractformat.SetSelection( 0 )
2744             fgSizer1.Add( self.extractformat, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2745         
2746         if option == 'them' :
2747             self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"thematics (one by line, with the -*)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2748             self.m_staticText4.Wrap( -1 )
2749             fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2750             
2751             self.txtmods = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE )
2752             self.txtmods.SetMinSize( wx.Size( 200,150 ) )
2753             
2754             fgSizer1.Add( self.txtmods, 0, wx.ALL|wx.EXPAND, 5 )
2755             
2756             #self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Extraction type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2757             #self.m_staticText5.Wrap( -1 )
2758             #fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2759             
2760             #extractformatChoices = [ _(u"Only one file").decode('utf8'), _(u"One file by thematic").decode('utf8') ]
2761             #self.extractformat = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, extractformatChoices, 1, wx.RA_SPECIFY_COLS )
2762             #self.extractformat.SetSelection( 0 )
2763             #fgSizer1.Add( self.extractformat, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )        
2764             
2765         
2766         fgSizer1.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
2767         
2768         m_sdbSizer1 = wx.StdDialogButtonSizer()
2769         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2770         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2771         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2772         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2773         m_sdbSizer1.Realize()
2774         
2775         fgSizer1.Add( m_sdbSizer1, 1, wx.EXPAND, 5 )
2776         
2777         
2778         self.SetSizer( fgSizer1 )
2779         self.Layout()
2780         fgSizer1.Fit( self )
2781         
2782         self.Centre( wx.BOTH )
2783
2784     def make_param(self) :
2785         parametres = {}
2786         le = [enc[0].lower() for enc in encodages]
2787         parametres['filein'] = self.corpusfile.GetPath()
2788         encodage = le[self.encodage.GetSelection()]
2789         parametres['encodein'] = encodage
2790         if self.option == 'splitvar' :
2791             parametres['var'] = self.txtvar.GetValue()
2792         if self.option == 'mods' :
2793             parametres['mods'] = self.txtmods.GetValue().splitlines()
2794             if self.extractformat.GetSelection() == 0 :
2795                 parametres['onefile'] = True
2796             else :
2797                 parametres['onefile'] = False
2798         if self.option == 'them' :
2799             parametres['them'] = self.txtmods.GetValue().splitlines()
2800         #    if self.extractformat.GetSelection() == 0 :
2801         #        parametres['onefile'] = True
2802         #    else :
2803         #        parametres['onefile'] = False        
2804         parametres['encodeout'] = le[self.encodage.GetSelection()]
2805         return parametres
2806     
2807     def __del__( self ):
2808         pass
2809
2810 class FreqDialog ( wx.Dialog ):
2811     
2812     def __init__( self, parent, listcol, title, size =  wx.Size( -1,-1 ), showNA = True):
2813         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 )
2814         
2815         self.header = listcol
2816         
2817         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2818         
2819         bSizer1 = wx.BoxSizer( wx.VERTICAL )
2820         
2821         m_listBox1Choices = self.header
2822         self.m_listBox1 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox1Choices, wx.LB_EXTENDED|wx.LB_HSCROLL )
2823         self.m_listBox1.SetMinSize( wx.Size( 500,-1 ) )
2824         bSizer1.Add( self.m_listBox1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2825         
2826         if showNA :
2827             fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2828             fgSizer1.SetFlexibleDirection( wx.BOTH )
2829             fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2830         
2831             self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Include empty cells (NA)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2832             self.m_staticText1.Wrap( -1 )
2833             fgSizer1.Add( self.m_staticText1, 0, wx.ALL, 5 )
2834         
2835             self.includeNA = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
2836             fgSizer1.Add( self.includeNA, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2837         
2838             bSizer1.Add( fgSizer1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5 )
2839         
2840         m_sdbSizer1 = wx.StdDialogButtonSizer()
2841         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2842         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2843         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2844         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2845         m_sdbSizer1.Realize();
2846         
2847         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
2848         
2849         
2850         self.SetSizer( bSizer1 )
2851         self.Layout()
2852         bSizer1.Fit( self )
2853         
2854         self.Centre( wx.BOTH )
2855     
2856     def __del__( self ):
2857         pass
2858     
2859
2860
2861 class ProtoDial ( wx.Dialog ):
2862     
2863     def __init__( self, parent, headers ):
2864         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 )
2865         
2866         self.SetSizeHintsSz( wx.Size( -1,-1 ), wx.DefaultSize )
2867         
2868         bSizer1 = wx.BoxSizer( wx.VERTICAL )
2869         
2870         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
2871         fgSizer1.SetFlexibleDirection( wx.BOTH )
2872         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2873         
2874         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, _(u"Variables").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2875         self.m_staticText1.Wrap( -1 )
2876         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
2877         
2878         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, _(u"Ranks").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2879         self.m_staticText2.Wrap( -1 )
2880         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
2881         
2882         variablesChoices = headers
2883         self.variables = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, variablesChoices, wx.LB_HSCROLL|wx.LB_MULTIPLE )
2884         self.variables.SetMinSize( wx.Size( 350,-1 ) )
2885         
2886         fgSizer1.Add( self.variables, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2887         
2888         rangsChoices = headers
2889         self.rangs = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, rangsChoices, wx.LB_HSCROLL|wx.LB_MULTIPLE )
2890         self.rangs.SetMinSize( wx.Size( 350,-1 ) )
2891         
2892         fgSizer1.Add( self.rangs, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
2893         
2894         
2895         bSizer1.Add( fgSizer1, 1, wx.ALIGN_CENTER_HORIZONTAL, 5 )
2896         
2897         fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
2898         fgSizer3.SetFlexibleDirection( wx.BOTH )
2899         fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
2900         
2901         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, _(u"Limit frequency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2902         self.m_staticText3.Wrap( -1 )
2903         fgSizer3.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2904         
2905         bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
2906         
2907         choix_freqChoices = [ _(u"automatic (mean)").decode('utf8'), _(u"manual").decode('utf8') ]
2908         self.choix_freq = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choix_freqChoices, 0 )
2909         self.choix_freq.SetSelection( 0 )
2910         bSizer2.Add( self.choix_freq, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2911         
2912         self.freqlim = wx.TextCtrl( self, wx.ID_ANY, u"0", wx.DefaultPosition, wx.DefaultSize, wx.TE_CENTRE )
2913         self.freqlim.Enable( False )
2914         self.freqlim.SetMinSize( wx.Size( 100,-1 ) )
2915         
2916         bSizer2.Add( self.freqlim, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2917         
2918         
2919         fgSizer3.Add( bSizer2, 1, wx.EXPAND, 5 )
2920         
2921         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, _(u"Limit rank").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2922         self.m_staticText4.Wrap( -1 )
2923         fgSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2924         
2925         bSizer21 = wx.BoxSizer( wx.HORIZONTAL )
2926         
2927         choix_rangChoices = [ _(u"automatic (mean)").decode('utf8'), _(u"manual").decode('utf8')]
2928         self.choix_rang = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choix_rangChoices, 0 )
2929         self.choix_rang.SetSelection( 0 )
2930         bSizer21.Add( self.choix_rang, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2931         
2932         self.ranglim = wx.TextCtrl( self, wx.ID_ANY, u"0", wx.DefaultPosition, wx.DefaultSize, wx.TE_CENTRE )
2933         self.ranglim.Enable( False )
2934         self.ranglim.SetMinSize( wx.Size( 100,-1 ) )
2935         
2936         bSizer21.Add( self.ranglim, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2937         
2938         
2939         fgSizer3.Add( bSizer21, 1, wx.EXPAND, 5 )
2940         
2941         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Minimum frequency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
2942         self.m_staticText5.Wrap( -1 )
2943         fgSizer3.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2944         
2945         self.m_textCtrl4 = wx.TextCtrl( self, wx.ID_ANY, u"2", wx.DefaultPosition, wx.DefaultSize, wx.TE_CENTRE )
2946         fgSizer3.Add( self.m_textCtrl4, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
2947         
2948         self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, u"Type de représentation", wx.DefaultPosition, wx.DefaultSize, 0 )
2949         self.m_staticText6.Wrap( -1 )
2950         fgSizer3.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
2951         
2952         m_choice3Choices = [ u"Classical - List", u"Classical - Cloud", u"Plan" ]
2953         self.typegraph = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_choice3Choices, 0 )
2954         self.typegraph.SetSelection( 0 )
2955         fgSizer3.Add( self.typegraph, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
2956         
2957         bSizer1.Add( fgSizer3, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 )
2958         
2959         m_sdbSizer1 = wx.StdDialogButtonSizer()
2960         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
2961         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
2962         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
2963         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
2964         m_sdbSizer1.Realize();
2965         
2966         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
2967         
2968         self.SetSizer( bSizer1 )
2969         self.Layout()
2970         bSizer1.Fit( self )
2971         
2972         self.Centre( wx.BOTH )
2973         
2974         # Connect Events
2975         self.choix_freq.Bind( wx.EVT_CHOICE, self.UpdateText )
2976         self.choix_rang.Bind( wx.EVT_CHOICE, self.UpdateText )
2977     
2978     def __del__( self ):
2979         pass
2980     
2981     
2982     # Virtual event handlers, overide them in your derived class
2983     def UpdateText( self, event ):
2984         event.Skip()
2985
2986 class SimpleDialog ( wx.Dialog ):
2987     
2988     def __init__( self, parent ):
2989         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
2990         
2991         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
2992         
2993         bSizer1 = wx.BoxSizer( wx.VERTICAL )
2994         
2995         self.m_panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
2996         bSizer2 = wx.BoxSizer( wx.VERTICAL )
2997         
2998         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 )
2999         self.m_staticText1.Wrap( -1 )
3000         bSizer2.Add( self.m_staticText1, 0, wx.ALL, 5 )
3001         
3002         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 )
3003         bSizer2.Add( self.link, 0, wx.ALL, 5 )
3004         
3005         
3006         self.m_panel1.SetSizer( bSizer2 )
3007         self.m_panel1.Layout()
3008         bSizer2.Fit( self.m_panel1 )
3009         bSizer1.Add( self.m_panel1, 1, wx.EXPAND |wx.ALL, 5 )
3010         
3011         m_sdbSizer1 = wx.StdDialogButtonSizer()
3012         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
3013         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
3014         m_sdbSizer1.Realize();
3015         
3016         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
3017         
3018         
3019         self.SetSizer( bSizer1 )
3020         self.Layout()
3021         bSizer1.Fit( self )
3022         
3023         self.Centre( wx.BOTH )
3024     
3025     def __del__( self ):
3026         pass
3027
3028
3029 class SubTextFromMetaDial ( wx.Dialog ):
3030     
3031     def __init__( self, parent, parametres ):
3032         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 )
3033         
3034         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
3035         
3036         bSizer1 = wx.BoxSizer( wx.VERTICAL )
3037         
3038         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
3039         fgSizer1.SetFlexibleDirection( wx.BOTH )
3040         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
3041         
3042         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"SubCorpus Name", wx.DefaultPosition, wx.DefaultSize, 0 )
3043         self.m_staticText1.Wrap( -1 )
3044         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3045         
3046         self.subcorpusname = wx.TextCtrl( self, wx.ID_ANY, parametres['corpus_name'], wx.DefaultPosition, wx.Size( 300,-1 ), 0 )
3047         fgSizer1.Add( self.subcorpusname, 0, wx.ALL, 5 )
3048         
3049         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"Select one or more metadata", wx.DefaultPosition, wx.DefaultSize, 0 )
3050         self.m_staticText2.Wrap( -1 )
3051         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3052         
3053         m_listBox1Choices = parametres['meta']
3054         self.m_listBox1 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( -1,-1 ), m_listBox1Choices, wx.LB_HSCROLL|wx.LB_MULTIPLE )
3055         self.m_listBox1.SetMinSize( wx.Size( -1,200 ) )
3056         self.m_listBox1.SetMaxSize( wx.Size( -1,500 ) )
3057         
3058         fgSizer1.Add( self.m_listBox1, 0, wx.ALL|wx.EXPAND, 5 )
3059         
3060         
3061         bSizer1.Add( fgSizer1, 1, wx.EXPAND, 5 )
3062         
3063         m_sdbSizer1 = wx.StdDialogButtonSizer()
3064         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
3065         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
3066         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
3067         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
3068         m_sdbSizer1.Realize();
3069         
3070         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
3071         
3072         
3073         self.SetSizer( bSizer1 )
3074         self.Layout()
3075         bSizer1.Fit( self )
3076         
3077         self.Centre( wx.BOTH )
3078     
3079     def __del__( self ):
3080         pass
3081
3082 class BarGraphDialog ( wx.Dialog ):
3083     
3084     def __init__( self, parent, width, height ):
3085         wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Preferences", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
3086         
3087         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
3088         
3089         bSizer1 = wx.BoxSizer( wx.VERTICAL )
3090         
3091         bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
3092         
3093         self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Size", wx.DefaultPosition, wx.DefaultSize, 0 )
3094         self.m_staticText1.Wrap( -1 )
3095         bSizer2.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3096         
3097         sizeradioChoices = [ u"automatic", u"manual" ]
3098         self.sizeradio = wx.RadioBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, sizeradioChoices, 1, wx.RA_SPECIFY_COLS )
3099         self.sizeradio.SetSelection( 0 )
3100         bSizer2.Add( self.sizeradio, 0, wx.ALIGN_TOP|wx.ALL, 5 )
3101         
3102         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
3103         fgSizer1.SetFlexibleDirection( wx.BOTH )
3104         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
3105         
3106         self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"width", wx.DefaultPosition, wx.DefaultSize, 0 )
3107         self.m_staticText2.Wrap( -1 )
3108         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3109         
3110         self.widthsp = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 1000000, 600 )
3111         fgSizer1.Add( self.widthsp, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3112         
3113         self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"height", wx.DefaultPosition, wx.DefaultSize, 0 )
3114         self.m_staticText3.Wrap( -1 )
3115         fgSizer1.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3116         
3117         self.heightsp = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000000, 400 )
3118         fgSizer1.Add( self.heightsp, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3119         
3120         
3121         bSizer2.Add( fgSizer1, 1, wx.EXPAND, 5 )
3122         
3123         
3124         bSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )
3125         
3126         bSizer3 = wx.BoxSizer( wx.HORIZONTAL )
3127         
3128         self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, u"Image format", wx.DefaultPosition, wx.DefaultSize, 0 )
3129         self.m_staticText4.Wrap( -1 )
3130         bSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3131         
3132         formatChoices = [ u"png", u"svg" ]
3133         self.format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, formatChoices, 0 )
3134         self.format.SetSelection( 0 )
3135         bSizer3.Add( self.format, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
3136         
3137         
3138         bSizer1.Add( bSizer3, 1, wx.EXPAND, 5 )
3139         
3140         m_sdbSizer1 = wx.StdDialogButtonSizer()
3141         self.m_sdbSizer1OK = wx.Button( self, wx.ID_OK )
3142         m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
3143         self.m_sdbSizer1Cancel = wx.Button( self, wx.ID_CANCEL )
3144         m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
3145         m_sdbSizer1.Realize();
3146         
3147         bSizer1.Add( m_sdbSizer1, 0, wx.EXPAND, 5 )
3148         
3149         
3150         self.SetSizer( bSizer1 )
3151         self.Layout()
3152         bSizer1.Fit( self )
3153         
3154         self.Centre( wx.BOTH )
3155         
3156         # Connect Events
3157         self.sizeradio.Bind( wx.EVT_RADIOBOX, self.OnSizeRadio )
3158         
3159         self.widthsp.SetValue(width)
3160         self.heightsp.SetValue(height)
3161         self.widthsp.Enable(False)
3162         self.heightsp.Enable(False)
3163         self.m_sdbSizer1OK.SetFocus()
3164     
3165     def __del__( self ):
3166         pass
3167     
3168     
3169     # Virtual event handlers, overide them in your derived class
3170     def OnSizeRadio( self, event ):
3171         if self.sizeradio.GetSelection() == 0 :
3172             self.widthsp.Enable(False)
3173             self.heightsp.Enable(False)
3174         else :
3175             self.widthsp.Enable(True)
3176             self.heightsp.Enable(True)         
3177         event.Skip()
3178
3179 class MessageImage(wx.Frame):
3180     def __init__(self, parent, parametres, title, size):
3181         wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = size, style = wx.CLOSE_BOX|wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.TAB_TRAVERSAL )
3182         self.ira = wx.GetApp().GetTopWindow()
3183         self.SetIcon(self.ira._icon)
3184         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
3185         self.parametres = parametres
3186         self.imageFile = self.parametres['tmpgraph']
3187         if parametres['svg'] == 'TRUE' :
3188             self.imagename = u"image.svg"
3189         else :
3190             self.imagename = u"image.png"
3191         self.HtmlPage = wx.html.HtmlWindow(self, -1)
3192         self.HtmlPage.SetMinSize(size)
3193         if "gtk2" in wx.PlatformInfo:
3194             self.HtmlPage.SetStandardFonts()
3195         self.HtmlPage.SetFonts('Courier', 'Courier')
3196         
3197         self.button_1 = wx.Button(self, wx.ID_CANCEL)
3198         self.button_2 = wx.Button(self, wx.ID_SAVE)
3199         self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button_1)
3200         self.Bind(wx.EVT_BUTTON, self.OnSaveImage, self.button_2)
3201         self.do_layout()
3202
3203     def do_layout(self):
3204         self.sizer_1 = wx.BoxSizer(wx.VERTICAL)
3205         self.sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
3206         self.sizer_1.Add(self.HtmlPage, 2, wx.EXPAND, 0)
3207
3208         self.m_sdbSizer1 = wx.StdDialogButtonSizer()
3209         self.m_sdbSizer1.AddButton(  self.button_2 )
3210         self.m_sdbSizer1.AddButton(  self.button_1 )
3211         self.m_sdbSizer1.Realize()
3212         self.sizer_1.Add(self.m_sdbSizer1, 0, wx.EXPAND, 5)
3213         self.SetSizer(self.sizer_1)
3214         self.Layout()
3215         self.sizer_1.Fit( self )
3216
3217     def OnCloseMe(self, event):
3218         self.Destroy()
3219
3220     def OnSaveImage(self, event) :
3221         dlg = wx.FileDialog(
3222             self, message="Enregistrer sous...", defaultDir=os.getcwd(),
3223             defaultFile= self.imagename, wildcard=self.parametres['wildcard'], style=wx.SAVE | wx.OVERWRITE_PROMPT
3224             )
3225         dlg.SetFilterIndex(2)
3226         dlg.CenterOnParent()
3227         if dlg.ShowModal() == wx.ID_OK:
3228             path = dlg.GetPath()
3229             copyfile(self.imageFile, path)
3230
3231 class BarFrame :
3232     def __init__(self, ira, table, colnames, rownames, tree = False):
3233         if not tree :
3234             width = 100 + (10*len(rownames)) + (100 * len(colnames))
3235             height = len(rownames) * 15
3236             if height < 400 : 
3237                 height = 400
3238         else :
3239             width = 500
3240             height = (35 * len(colnames)) + (15 * len(rownames))
3241         dial = BarGraphDialog(ira, width, height)
3242         val = dial.ShowModal()
3243         if val == wx.ID_OK :
3244             tmpgraph = tempfile.mktemp(dir=ira.TEMPDIR)        
3245             if dial.format.GetSelection() == 0 :
3246                 svg = 'FALSE'
3247                 wildcard = "png|*.png"
3248             else :
3249                 svg = 'TRUE'
3250                 wildcard = "svg|*.svg"
3251             parametres = {'width' : dial.widthsp.GetValue(),
3252                           'height': dial.heightsp.GetValue(),
3253                           'colnames' : colnames,
3254                           'rownames' : rownames,
3255                           'tmpgraph' : tmpgraph,
3256                           'rgraph' : ira.RscriptsPath['Rgraph'],
3257                           'svg' : svg,
3258                           'wildcard' : wildcard}
3259             if tree :
3260                 parametres['tree'] = tree
3261             txt = barplot(table, parametres)
3262             tmpscript = tempfile.mktemp(dir=ira.TEMPDIR)
3263             with open(tmpscript,'w') as f :
3264                 f.write(txt)
3265             exec_rcode(ira.RPath, tmpscript, wait = True)
3266             win = MessageImage(ira, parametres, u"Graphique", size=(700, 500))
3267             if svg == 'FALSE' :
3268                 txt = "<img src='%s'>" % tmpgraph
3269             else :
3270                 txt = """Copiez ce lien dans votre navigateur : <br>
3271                         <a href="%s">%s</a>""" % (tmpgraph, tmpgraph)
3272             win.HtmlPage.SetPage(txt)
3273             win.Show(True)
3274         dial.Destroy()