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