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