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