profile translations
[iramuteq] / guifunct.py
1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2011 Pierre Ratinaud
4 #License: GNU/GPL
5
6 import wx
7 import os
8 import sys
9 from copy import copy
10 from dialog import FileOptionDialog, SelectColDial, OptLexi, PrefSimpleFile
11 from listlex import *
12 from vitemspicker import VItemsPicker, EVT_IP_SELECTION_CHANGED, IP_SORT_CHOICES, IP_SORT_SELECTED, IP_REMOVE_FROM_CHOICES
13 from functions import treat_var_mod, print_liste, exec_rcode, check_Rresult, DoConf, read_list_file, indices_simi
14 import codecs
15 import wx.lib.hyperlink as hl
16 from webexport import WebExport
17 from PrintRScript import PrintSimiScript
18 #from wx import GetTopLevelWindows
19
20
21 def OnOpen(self, type):
22         if type == "Data":
23             wildcard = u"Fichiers supportés|*.ods;*.xls;*.csv;*.txt|Openoffice Calc|*.ods|Excel 97/2000/XP/2003|*.xls|Fichier csv|*.csv|Fichier texte|*.txt|Tous les fichiers|*"
24         elif type == "Texte":
25             wildcard = "Fichier texte|*.txt|Tous les fichiers|*"
26         elif type == "Analyse":
27             wildcard = "Fichier analyse/Corpus|*.ira;*.cira"
28         defaultDir = self.PathPath.get('PATHS', 'lastpath')
29         if defaultDir.strip() == '':
30             defaultDir = self.UserConfigPath.replace('.iramuteq','')
31         dlg = wx.FileDialog(
32         self, message=_(u"Choose a file").decode('utf8'), defaultDir=defaultDir,
33         defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.CHANGE_DIR)
34         dlg.CenterOnParent()
35         if dlg.ShowModal() == wx.ID_OK :
36             fileName = dlg.GetFilename()
37             path = dlg.GetPaths()
38             dlg.Destroy()
39             self.PathPath.set('PATHS', 'lastpath', os.path.dirname(path[0]))
40             self.type = type
41             return fileName, path
42         else:
43             dlg.Destroy()
44             if type == "Data":
45                 return False, [False]
46             elif type == "Texte":
47                 return False, [False]
48             elif type == "Analyse":
49                 return False
50
51 def getfileextension(file) :
52     return os.path.splitext(file)[1]
53
54 def get_table_param(self, filename) :
55     if getfileextension(filename) == '.csv':
56         dlg = FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=True, size=(350, 200),
57                      style=wx.DEFAULT_DIALOG_STYLE)
58         dlg.CenterOnParent()
59         val = dlg.ShowModal()
60         if val == wx.ID_OK:
61             self.tableau.parametres['colsep'] = dlg.colsep[dlg.choice3.GetSelection()]
62             self.tableau.parametres['txtsep'] = dlg.txtsep[dlg.choice4.GetSelection()]
63             if self.tableau.parametres['colsep'] == 'tabulation' :
64                 self.tableau.parametres['colsep'] = '\t'
65             self.tableau.parametres['filetype'] = 'csv'
66             self.tableau.parametres['encodage'] = dlg.le[dlg.list_encodages.GetSelection()]
67     elif  getfileextension(filename) == '.xls' :
68         dlg = FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, sheet = True, size=(350, 200),
69                      style=wx.DEFAULT_DIALOG_STYLE)
70         dlg.CenterOnParent()
71         val = dlg.ShowModal()
72         if val == wx.ID_OK:
73             self.tableau.parametres['colsep'] = ';'
74             self.tableau.parametres['txtsep'] = '\"'
75             self.tableau.parametres['encodage'] = sys.getdefaultencoding()
76             self.tableau.parametres['sheetnb'] = dlg.spin1.GetValue()
77             self.tableau.parametres['filetype'] = 'xls'
78     elif getfileextension(filename) == '.ods':
79         dlg = FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, size=(350, 200),
80                      style=wx.DEFAULT_DIALOG_STYLE)
81         dlg.CenterOnParent()
82         val = dlg.ShowModal()
83         if val == wx.ID_OK:
84             self.tableau.parametres['colsep'] = ';'
85             self.tableau.parametres['txtsep'] = '\"'
86             self.tableau.parametres['filetype'] = 'ods'
87     else :
88         val = False
89     if val == wx.ID_OK:
90         if dlg.radio_box_1.GetSelection() == 0:
91             self.tableau.firstrowiscolnames = True
92         else:
93             self.tableau.firstrowiscolnames = False
94         if dlg.radio_box_2.GetSelection() == 0:
95             self.tableau.firstcolisrownames = True
96         else:
97             self.tableau.firstcolisrownames = False
98     dlg.Destroy()
99     return val
100
101 def getPage(ira) :
102     if '_mgr' in dir(ira) :
103         if not ira._mgr.GetPane('Text').IsShown() :
104             if ira.nb.GetPageCount() >= 1:
105                 return ira.nb.GetPage(ira.nb.GetSelection())
106             else :
107                 return None
108         else :
109             return None
110     else :
111         return None
112
113 def getCorpus(page) :
114     if 'corpus' in page.__dict__:
115         return copy(page.corpus)
116     else :
117         return None
118
119 class SelectColumn :
120     def __init__(self, parent, dictcol, actives, pathout, selected = None, dlg = False) :
121         self.ira = parent
122         if dlg :
123             dial = SelectColDial(self.ira)
124             listcol = ListForSpec(dial, self, dictcol, ['eff'])
125             dial.bSizer2.Add( listcol, 2, wx.ALL|wx.EXPAND, 5 )
126             dial.m_sdbSizer2.AddButton( dial.m_sdbSizer2OK )
127             dial.m_sdbSizer2.AddButton( dial.butok)
128             dial.m_sdbSizer2.Realize()
129             dial.bSizer2.Add( dial.m_sdbSizer2, 0, wx.EXPAND, 5 )
130             dial.Layout()
131             if selected is None :
132                 for row in xrange(listcol.GetItemCount()):
133                     listcol.Select(row)
134             else :
135                 orderlex = dict([[listcol.getColumnText(i,0),i] for i in range(0,listcol.GetItemCount())])
136                 for row in selected :
137                     listcol.Select(orderlex[actives[row]])
138             dial.CenterOnParent()
139             val = dial.ShowModal()
140             if val == wx.ID_OK :
141                 last = listcol.GetFirstSelected()
142                 lastl = [listcol.GetFirstSelected()]
143                 indexes = [listcol.getColumnText(listcol.GetFirstSelected(),0)]
144                 while listcol.GetNextSelected(last) != -1:
145                     last = listcol.GetNextSelected(last)
146                     lastl.append(last)
147                     indexes.append(listcol.getColumnText(last,0))
148                 dial.Destroy()
149                 column = [actives.index(val) for val in indexes]
150                 column.sort()
151                 with open(pathout, 'w') as f :
152                     f.write('\n'.join([`val` for val in column]))
153                 self.ok = True
154             else :
155                 self.ok = False
156         else :
157             self.ok = True
158             if selected is None :
159                 selected = [i for i in range(0, len(actives))]
160             with open(pathout, 'w') as f :
161                 f.write('\n'.join([`i` for i in selected]))
162
163
164 class PrefSimi ( wx.Dialog ):
165
166     def __init__( self, parent, ID, paramsimi, indices, wordlist = None, selected = None, actives = None):
167         wx.Dialog.__init__ ( self, None, id = wx.ID_ANY, title = _(u"Settings").decode('utf8'), pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.DEFAULT_DIALOG_STYLE )
168         self.parent = parent
169         self.ira = parent
170         self.paramsimi=paramsimi
171         self.indices = indices
172
173         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
174
175         bSizer16 = wx.BoxSizer( wx.HORIZONTAL )
176         if wordlist is not None :
177             self.listcol = ListForSpec(self, self, wordlist, ['eff'])
178             self.listcol.SetMinSize( wx.Size( 270,-1 ) )
179             listsizer = wx.BoxSizer( wx.VERTICAL )
180             countsizer = wx.BoxSizer( wx.HORIZONTAL )
181             self.butcount = wx.Button(self, -1, _(u"count").decode('utf8'))
182             self.textcount = wx.TextCtrl(self, -1, "", wx.DefaultPosition, wx.Size( 100,-1 ), wx.TE_READONLY )
183             countsizer.Add(self.butcount, 0, wx.ALL, 5)
184             countsizer.Add(self.textcount, 0, wx.ALL, 5 )
185             listsizer.Add(countsizer, 0, wx.ALL, 5)
186             listsizer.Add(self.listcol, 2, wx.ALL|wx.EXPAND, 5 )
187             #bSizer16.Add( self.listcol, 0, wx.ALL|wx.EXPAND, 5 )
188             bSizer16.Add( listsizer, 0, wx.ALL|wx.EXPAND, 5)
189             if selected is None :
190                 for row in xrange(self.listcol.GetItemCount()):
191                     self.listcol.Select(row)
192             else :
193                 self.orderlex = dict([[self.listcol.getColumnText(i,0),i] for i in range(0,self.listcol.GetItemCount())])
194                 for row in selected :
195                     self.listcol.Select(self.orderlex[actives[row]])
196
197
198         fgSizer10 = wx.FlexGridSizer( 2, 1, 0, 0 )
199         fgSizer10.SetFlexibleDirection( wx.BOTH )
200         fgSizer10.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
201
202         self.m_notebook1 = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
203         self.m_panel2 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
204         bSizer18 = wx.BoxSizer( wx.VERTICAL )
205
206         fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
207         fgSizer3.SetFlexibleDirection( wx.BOTH )
208         fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
209
210         if not self.paramsimi['first'] :
211
212             self.m_staticText271 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Use previous coordinates").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
213             self.m_staticText271.Wrap( -1 )
214             fgSizer3.Add( self.m_staticText271, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
215
216             self.check_coord = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
217             fgSizer3.Add( self.check_coord, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
218
219             self.m_staticline36 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
220             fgSizer3.Add( self.m_staticline36, 0, wx.EXPAND, 5 )
221
222             self.m_staticline37 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
223             fgSizer3.Add( self.m_staticline37, 0, wx.EXPAND, 5 )
224
225         self.m_staticText3 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Score").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
226         self.m_staticText3.Wrap( -1 )
227         fgSizer3.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
228
229         choice1Choices = []
230         self.choice1 = wx.Choice( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.indices, 0 )
231         self.choice1.SetSelection( 0 )
232         fgSizer3.Add( self.choice1, 0, wx.ALL, 5 )
233
234         self.m_staticline293 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
235         fgSizer3.Add( self.m_staticline293, 0, wx.EXPAND, 5 )
236
237         self.m_staticline292 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
238         fgSizer3.Add( self.m_staticline292, 0, wx.EXPAND, 5 )
239
240         self.m_staticText4 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Layout").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
241         self.m_staticText4.Wrap( -1 )
242         fgSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
243
244         choice2Choices = [ u"random", u"cercle", u"fruchterman reingold", u"kamada kawai", u"graphopt" ]
245         if 'word' in self.paramsimi :
246             choice2Choices += [u"spirale", u'spirale3D']
247         self.choice2 = wx.Choice( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choice2Choices, 0 )
248         self.choice2.SetSelection( 0 )
249         fgSizer3.Add( self.choice2, 0, wx.ALL, 5 )
250
251         self.m_staticline294 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
252         fgSizer3.Add( self.m_staticline294, 0, wx.EXPAND, 5 )
253
254         self.m_staticline295 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
255         fgSizer3.Add( self.m_staticline295, 0, wx.EXPAND, 5 )
256
257         self.m_staticText5 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Graphic type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
258         self.m_staticText5.Wrap( -1 )
259         fgSizer3.Add( self.m_staticText5, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
260
261         choice3Choices = [ u"dynamique", u"statique", u"3D", u'web2D', u"web3D" ]
262         self.choice3 = wx.Choice( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choice3Choices, 0 )
263         self.choice3.SetSelection( 0 )
264
265         label_format = wx.StaticText(self.m_panel2, -1, _(u"Picture format").decode('utf8'))
266         self.choix_format =  wx.Choice(self.m_panel2, -1, (100,50), choices = ['png', 'svg'])
267         self.choix_format.SetSelection( 0 )
268         hsizer = wx.BoxSizer(wx.HORIZONTAL)
269         hsizer.Add(self.choice3, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
270         hsizer.Add(label_format, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
271         hsizer.Add(self.choix_format, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
272         fgSizer3.Add( hsizer, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
273
274         self.m_staticline296 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
275         fgSizer3.Add( self.m_staticline296, 0, wx.EXPAND, 5 )
276
277         self.m_staticline297 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
278         fgSizer3.Add( self.m_staticline297, 0, wx.EXPAND, 5 )
279
280         self.m_staticText8 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Maximum tree").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
281         self.m_staticText8.Wrap( -1 )
282         fgSizer3.Add( self.m_staticText8, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
283
284         self.check1 = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
285         fgSizer3.Add( self.check1, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
286
287         self.m_staticline298 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
288         fgSizer3.Add( self.m_staticline298, 0, wx.EXPAND, 5 )
289
290         self.m_staticline299 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
291         fgSizer3.Add( self.m_staticline299, 0, wx.EXPAND, 5 )
292
293         self.m_staticText91 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Edges threshold").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
294         self.m_staticText91.Wrap( -1 )
295         fgSizer3.Add( self.m_staticText91, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
296
297         bSizer21 = wx.BoxSizer( wx.HORIZONTAL )
298
299         self.check_seuil = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
300         bSizer21.Add( self.check_seuil, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
301
302         self.spin_seuil = wx.SpinCtrl( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 1 )
303         bSizer21.Add( self.spin_seuil, 0, wx.ALL, 5 )
304
305
306         fgSizer3.Add( bSizer21, 1, wx.EXPAND, 5 )
307
308         self.m_staticline2910 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
309         fgSizer3.Add( self.m_staticline2910, 0, wx.EXPAND, 5 )
310
311         self.m_staticline2911 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
312         fgSizer3.Add( self.m_staticline2911, 0, wx.EXPAND, 5 )
313
314         self.m_staticText19 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Text on vertex").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
315         self.m_staticText19.Wrap( -1 )
316         fgSizer3.Add( self.m_staticText19, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
317
318         self.check_vlab = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
319         fgSizer3.Add( self.check_vlab, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
320
321         self.m_staticline2912 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
322         fgSizer3.Add( self.m_staticline2912, 0, wx.EXPAND, 5 )
323
324         self.m_staticline2913 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
325         fgSizer3.Add( self.m_staticline2913, 0, wx.EXPAND, 5 )
326
327         self.m_staticText20 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Score on edges").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
328         self.m_staticText20.Wrap( -1 )
329         fgSizer3.Add( self.m_staticText20, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
330
331         self.check_elab = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
332         fgSizer3.Add( self.check_elab, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
333
334         self.m_staticline39 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
335         fgSizer3.Add( self.m_staticline39, 0, wx.EXPAND |wx.ALL, 5 )
336
337         self.m_staticline40 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
338         fgSizer3.Add( self.m_staticline40, 0, wx.EXPAND |wx.ALL, 5 )
339
340         self.m_staticText321 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Edge curved").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
341         self.m_staticText321.Wrap( -1 )
342         fgSizer3.Add( self.m_staticText321, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
343
344         self.check_curved = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
345         fgSizer3.Add( self.check_curved, 0, wx.ALL, 5 )
346
347         self.m_staticline2914 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
348         fgSizer3.Add( self.m_staticline2914, 0, wx.EXPAND, 5 )
349
350         self.m_staticline2915 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
351         fgSizer3.Add( self.m_staticline2915, 0, wx.EXPAND, 5 )
352
353         self.m_staticText27 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Text size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
354         self.m_staticText27.Wrap( -1 )
355         fgSizer3.Add( self.m_staticText27, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
356
357         self.spin_cex = wx.SpinCtrl( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 10 )
358         fgSizer3.Add( self.spin_cex, 0, wx.ALL, 5 )
359
360         self.m_staticline2916 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
361         fgSizer3.Add( self.m_staticline2916, 0, wx.EXPAND, 5 )
362
363         self.m_staticline2917 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
364         fgSizer3.Add( self.m_staticline2917, 0, wx.EXPAND, 5 )
365
366         bsizer34 = wx.BoxSizer(wx.HORIZONTAL)
367
368         comtext =  wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Communities").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
369         comtext.Wrap( -1 )
370         bsizer34.Add(comtext, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
371
372         self.comcheck = wx.CheckBox(self.m_panel2, -1)
373         bsizer34.Add(self.comcheck, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
374
375         fgSizer3.Add(bsizer34 , 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
376
377         sizer54 = wx.BoxSizer(wx.HORIZONTAL)
378         self.comlist = ['edge.betweenness.community','fastgreedy.community','label.propagation.community','leading.eigenvector.community','multilevel.community','optimal.community', 'spinglass.community', 'walktrap.community']
379         self.choix_com = wx.Choice( self.m_panel2, wx.ID_ANY, choices = self.comlist)
380         self.choix_com.SetSelection( 0 )
381         self.halo = wx.CheckBox(self.m_panel2, wx.ID_ANY, u'halo')
382         sizer54.Add(self.choix_com , 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
383         sizer54.Add(self.halo , 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
384         fgSizer3.Add( sizer54, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
385
386         if 'bystar' in self.paramsimi :
387             self.m_staticText40 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Select a variable").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
388             self.m_staticText40.Wrap( -1 )
389             fgSizer3.Add( self.m_staticText40, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
390
391             self.check_bystar = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
392             fgSizer3.Add( self.check_bystar, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
393
394             self.m_staticline3200 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
395             fgSizer3.Add( self.m_staticline3200, 0, wx.EXPAND, 5 )
396             self.m_staticline3201 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
397             fgSizer3.Add( self.m_staticline3201, 0, wx.EXPAND, 5 )
398
399
400         bSizer18.Add( fgSizer3, 0, wx.EXPAND, 5 )
401
402
403         self.m_panel2.SetSizer( bSizer18 )
404         self.m_panel2.Layout()
405         bSizer18.Fit( self.m_panel2 )
406         self.m_notebook1.AddPage( self.m_panel2, _(u"Graph settings").decode('utf8'), True )
407         self.m_panel3 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
408         fgSizer5 = wx.FlexGridSizer( 0, 3, 0, 0 )
409         fgSizer5.SetFlexibleDirection( wx.BOTH )
410         fgSizer5.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
411
412         fgSizer51 = wx.FlexGridSizer( 0, 2, 0, 0 )
413         fgSizer51.SetFlexibleDirection( wx.BOTH )
414         fgSizer51.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
415
416         self.m_staticText6 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Picture size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
417         self.m_staticText6.Wrap( -1 )
418         fgSizer51.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
419
420         fgSizer31 = wx.FlexGridSizer( 0, 2, 0, 0 )
421         fgSizer31.SetFlexibleDirection( wx.BOTH )
422         fgSizer31.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
423
424         self.m_staticText9 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"height").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
425         self.m_staticText9.Wrap( -1 )
426         fgSizer31.Add( self.m_staticText9, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
427
428         self.spin_height = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 10, 100000, 800 )
429         fgSizer31.Add( self.spin_height, 0, wx.ALL, 5 )
430
431         self.m_staticText10 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"width").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
432         self.m_staticText10.Wrap( -1 )
433         fgSizer31.Add( self.m_staticText10, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
434
435         self.spin_width = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 10, 100000, 800 )
436         fgSizer31.Add( self.spin_width, 0, wx.ALL, 5 )
437
438
439         fgSizer51.Add( fgSizer31, 1, wx.EXPAND, 5 )
440
441         self.m_staticline3 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
442         fgSizer51.Add( self.m_staticline3, 0, wx.EXPAND, 5 )
443
444         self.m_staticline4 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
445         fgSizer51.Add( self.m_staticline4, 0, wx.EXPAND, 5 )
446
447         self.m_staticText101 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Vertex size proportional to frequency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
448         self.m_staticText101.Wrap( -1 )
449         fgSizer51.Add( self.m_staticText101, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
450
451         bSizer7 = wx.BoxSizer( wx.HORIZONTAL )
452
453         bSizer9 = wx.BoxSizer( wx.VERTICAL )
454
455         self.check2 = wx.CheckBox( self.m_panel3, wx.ID_ANY, u"eff.", wx.DefaultPosition, wx.DefaultSize, 0 )
456         bSizer9.Add( self.check2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
457
458         self.checki = wx.CheckBox( self.m_panel3, wx.ID_ANY, u"chi2", wx.DefaultPosition, wx.DefaultSize, 0 )
459         bSizer9.Add( self.checki, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
460
461
462         bSizer7.Add( bSizer9, 0, wx.ALIGN_CENTER_VERTICAL, 5 )
463
464         fgSizer7 = wx.FlexGridSizer( 0, 2, 0, 0 )
465         fgSizer7.SetFlexibleDirection( wx.BOTH )
466         fgSizer7.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
467
468         self.m_staticText11 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"min", wx.DefaultPosition, wx.DefaultSize, 0 )
469         self.m_staticText11.Wrap( -1 )
470         fgSizer7.Add( self.m_staticText11, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
471
472         self.spin_tvmin = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 )
473         fgSizer7.Add( self.spin_tvmin, 0, wx.ALL, 5 )
474
475         self.m_staticText12 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"max", wx.DefaultPosition, wx.DefaultSize, 0 )
476         self.m_staticText12.Wrap( -1 )
477         fgSizer7.Add( self.m_staticText12, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
478
479         self.spin_tvmax = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 )
480         fgSizer7.Add( self.spin_tvmax, 0, wx.ALL, 5 )
481
482
483         bSizer7.Add( fgSizer7, 1, wx.EXPAND, 5 )
484
485
486         fgSizer51.Add( bSizer7, 1, wx.EXPAND, 5 )
487
488         self.m_staticline31 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
489         fgSizer51.Add( self.m_staticline31, 0, wx.EXPAND, 5 )
490
491         self.m_staticline32 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
492         fgSizer51.Add( self.m_staticline32, 0, wx.EXPAND, 5 )
493
494         self.m_staticText1011 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Vertex text size proportional to frequency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
495         self.m_staticText1011.Wrap( -1 )
496         fgSizer51.Add( self.m_staticText1011, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
497
498         bSizer71 = wx.BoxSizer( wx.HORIZONTAL )
499
500         bSizer8 = wx.BoxSizer( wx.VERTICAL )
501
502         self.check_vcex = wx.CheckBox( self.m_panel3, wx.ID_ANY, u"eff.", wx.DefaultPosition, wx.DefaultSize, 0 )
503         bSizer8.Add( self.check_vcex, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
504
505         self.checkit = wx.CheckBox( self.m_panel3, wx.ID_ANY, u"chi2", wx.DefaultPosition, wx.DefaultSize, 0 )
506         bSizer8.Add( self.checkit, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
507
508
509         bSizer71.Add( bSizer8, 0, wx.ALIGN_CENTER_VERTICAL, 5 )
510
511         fgSizer71 = wx.FlexGridSizer( 0, 2, 0, 0 )
512         fgSizer71.SetFlexibleDirection( wx.BOTH )
513         fgSizer71.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
514
515         self.m_staticText111 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"min", wx.DefaultPosition, wx.DefaultSize, 0 )
516         self.m_staticText111.Wrap( -1 )
517         fgSizer71.Add( self.m_staticText111, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
518
519         self.spin_vcexmin = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 )
520         fgSizer71.Add( self.spin_vcexmin, 0, wx.ALL, 5 )
521
522         self.m_staticText121 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"max", wx.DefaultPosition, wx.DefaultSize, 0 )
523         self.m_staticText121.Wrap( -1 )
524         fgSizer71.Add( self.m_staticText121, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
525
526         self.spin_vcexmax = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 )
527         fgSizer71.Add( self.spin_vcexmax, 0, wx.ALL, 5 )
528
529
530         bSizer71.Add( fgSizer71, 1, wx.EXPAND, 5 )
531
532
533         fgSizer51.Add( bSizer71, 1, wx.EXPAND, 5 )
534
535         self.m_staticline321 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
536         fgSizer51.Add( self.m_staticline321, 0, wx.EXPAND, 5 )
537
538         self.m_staticline322 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
539         fgSizer51.Add( self.m_staticline322, 0, wx.EXPAND, 5 )
540
541         self.m_staticText10111 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Edges width proportional to score").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
542         self.m_staticText10111.Wrap( -1 )
543         fgSizer51.Add( self.m_staticText10111, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
544
545         bSizer711 = wx.BoxSizer( wx.HORIZONTAL )
546
547         self.check3 = wx.CheckBox( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
548         bSizer711.Add( self.check3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
549
550         fgSizer711 = wx.FlexGridSizer( 0, 2, 0, 0 )
551         fgSizer711.SetFlexibleDirection( wx.BOTH )
552         fgSizer711.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
553
554         self.m_staticText1111 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"min", wx.DefaultPosition, wx.DefaultSize, 0 )
555         self.m_staticText1111.Wrap( -1 )
556         fgSizer711.Add( self.m_staticText1111, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
557
558         self.spin_temin = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 )
559         fgSizer711.Add( self.spin_temin, 0, wx.ALL, 5 )
560
561         self.m_staticText1211 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"max", wx.DefaultPosition, wx.DefaultSize, 0 )
562         self.m_staticText1211.Wrap( -1 )
563         fgSizer711.Add( self.m_staticText1211, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
564
565         self.spin_temax = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 )
566         fgSizer711.Add( self.spin_temax, 0, wx.ALL, 5 )
567
568
569         bSizer711.Add( fgSizer711, 1, wx.EXPAND, 5 )
570
571
572         fgSizer51.Add( bSizer711, 1, wx.EXPAND, 5 )
573
574         self.m_staticline33 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
575         fgSizer51.Add( self.m_staticline33, 0, wx.EXPAND, 5 )
576
577         self.m_staticline34 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
578         fgSizer51.Add( self.m_staticline34, 0, wx.EXPAND, 5 )
579
580         self.m_staticText28 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Gray scale on text proportional to frequency (0=black, 1=white)").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
581         self.m_staticText28.Wrap( -1 )
582         fgSizer51.Add( self.m_staticText28, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
583
584         bSizer10 = wx.BoxSizer( wx.HORIZONTAL )
585
586         self.m_checkBox14 = wx.CheckBox( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
587         bSizer10.Add( self.m_checkBox14, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
588
589         bSizer11 = wx.BoxSizer( wx.VERTICAL )
590
591         bSizer12 = wx.BoxSizer( wx.HORIZONTAL )
592
593         self.m_staticText31 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"min", wx.DefaultPosition, wx.DefaultSize, 0 )
594         self.m_staticText31.Wrap( -1 )
595         bSizer12.Add( self.m_staticText31, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
596
597         self.m_spinCtrl14 = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 0 )
598         bSizer12.Add( self.m_spinCtrl14, 0, wx.ALL, 5 )
599
600
601         bSizer11.Add( bSizer12, 1, wx.EXPAND, 5 )
602
603         bSizer13 = wx.BoxSizer( wx.HORIZONTAL )
604
605         self.m_staticText32 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"max", wx.DefaultPosition, wx.DefaultSize, 0 )
606         self.m_staticText32.Wrap( -1 )
607         bSizer13.Add( self.m_staticText32, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
608
609         self.m_spinCtrl15 = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 10 )
610         bSizer13.Add( self.m_spinCtrl15, 0, wx.ALL, 5 )
611
612
613         bSizer11.Add( bSizer13, 1, wx.EXPAND, 5 )
614
615
616         bSizer10.Add( bSizer11, 1, wx.EXPAND, 5 )
617
618
619         fgSizer51.Add( bSizer10, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
620
621         self.m_staticline3311 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
622         fgSizer51.Add( self.m_staticline3311, 0, wx.EXPAND |wx.ALL, 5 )
623
624         self.m_staticline33111 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
625         fgSizer51.Add( self.m_staticline33111, 0, wx.EXPAND |wx.ALL, 5 )
626
627         bSizer5 = wx.BoxSizer( wx.HORIZONTAL )
628
629         self.m_staticText21 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Vertex color").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
630         self.m_staticText21.Wrap( -1 )
631         bSizer5.Add( self.m_staticText21, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
632
633         self.cols = wx.ColourPickerCtrl( self.m_panel3, wx.ID_ANY, wx.Colour( 255, 0, 0 ), wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE )
634         bSizer5.Add( self.cols, 0, wx.ALL, 5 )
635
636
637         fgSizer51.Add( bSizer5, 1, wx.EXPAND, 5 )
638
639         bSizer6 = wx.BoxSizer( wx.HORIZONTAL )
640
641         self.m_staticText22 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Edges color").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
642         self.m_staticText22.Wrap( -1 )
643         bSizer6.Add( self.m_staticText22, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
644
645         self.cola = wx.ColourPickerCtrl( self.m_panel3, wx.ID_ANY, wx.Colour( 208, 208, 208 ), wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE )
646         bSizer6.Add( self.cola, 0, wx.ALL, 5 )
647
648
649         fgSizer51.Add( bSizer6, 1, wx.EXPAND, 5 )
650
651         self.m_staticline331 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
652         fgSizer51.Add( self.m_staticline331, 0, wx.EXPAND, 5 )
653
654         self.m_staticline332 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
655         fgSizer51.Add( self.m_staticline332, 0, wx.EXPAND, 5 )
656
657         self.m_staticText23 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Vertex size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
658         self.m_staticText23.Wrap( -1 )
659         fgSizer51.Add( self.m_staticText23, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
660
661         bSizer72 = wx.BoxSizer( wx.HORIZONTAL )
662
663         self.check_s_size = wx.CheckBox( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
664         bSizer72.Add( self.check_s_size, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
665
666         self.spin_tv = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 100, 10 )
667         bSizer72.Add( self.spin_tv, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
668
669
670         fgSizer51.Add( bSizer72, 1, wx.EXPAND, 5 )
671
672         self.m_staticline333 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
673         fgSizer51.Add( self.m_staticline333, 0, wx.EXPAND, 5 )
674
675         self.m_staticline334 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
676         fgSizer51.Add( self.m_staticline334, 0, wx.EXPAND, 5 )
677
678         self.m_staticText24 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Spheres transparency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
679         self.m_staticText24.Wrap( -1 )
680         fgSizer51.Add( self.m_staticText24, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
681
682         self.slider_sphere = wx.Slider( self.m_panel3, wx.ID_ANY, 10, 0, 100, wx.DefaultPosition, wx.DefaultSize, wx.SL_HORIZONTAL|wx.SL_LABELS )
683         fgSizer51.Add( self.slider_sphere, 0, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5 )
684
685         self.m_staticline335 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
686         fgSizer51.Add( self.m_staticline335, 0, wx.EXPAND, 5 )
687
688         self.m_staticline336 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
689         fgSizer51.Add( self.m_staticline336, 0, wx.EXPAND, 5 )
690
691         self.m_staticText25 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Make a movie").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
692         self.m_staticText25.Wrap( -1 )
693         fgSizer51.Add( self.m_staticText25, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
694
695         self.film = wx.CheckBox( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
696         fgSizer51.Add( self.film, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
697
698         self.m_staticline2918 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
699         fgSizer51.Add( self.m_staticline2918, 0, wx.EXPAND, 5 )
700
701         self.m_staticline2919 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
702         fgSizer51.Add( self.m_staticline2919, 0, wx.EXPAND, 5 )
703
704
705         fgSizer51.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
706
707
708         fgSizer5.Add( fgSizer51, 1, wx.EXPAND, 5 )
709
710
711         self.m_panel3.SetSizer( fgSizer5 )
712         self.m_panel3.Layout()
713         fgSizer5.Fit( self.m_panel3 )
714         self.m_notebook1.AddPage( self.m_panel3, _(u"Graphical settings").decode('utf8'), False )
715
716         fgSizer10.Add( self.m_notebook1, 1, wx.EXPAND |wx.ALL, 5 )
717
718         m_sdbSizer2 = wx.StdDialogButtonSizer()
719         self.m_sdbSizer2OK = wx.Button( self, wx.ID_OK )
720         m_sdbSizer2.AddButton( self.m_sdbSizer2OK )
721         self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL )
722         m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel )
723         m_sdbSizer2.Realize();
724
725         fgSizer10.Add( m_sdbSizer2, 1, wx.EXPAND, 5 )
726
727
728         bSizer16.Add( fgSizer10, 1, wx.EXPAND, 5 )
729
730
731         self.SetSizer( bSizer16 )
732         self.Layout()
733         bSizer16.Fit( self )
734
735         self.Centre( wx.BOTH )
736         self.__set_properties()
737
738         # Connect Events
739         if not self.paramsimi['first'] :
740             self.check_coord.Bind( wx.EVT_CHECKBOX, self.OnKeepCoords )
741         self.choice3.Bind( wx.EVT_CHOICE, self.OnChangeType )
742         self.check2.Bind( wx.EVT_CHECKBOX, self.OnCheck2 )
743         if 'cexfromchi' in self.paramsimi :
744             self.checkit.Bind( wx.EVT_CHECKBOX, self.OnCheckit )
745         if 'sfromchi' in self.paramsimi :
746             self.checki.Bind( wx.EVT_CHECKBOX, self.OnChecki )
747         self.check_vcex.Bind( wx.EVT_CHECKBOX, self.OnCheck_vcex )
748         self.check_s_size.Bind( wx.EVT_CHECKBOX, self.OnCheck_s_size )
749         self.listcol.Bind( wx.EVT_LIST_ITEM_SELECTED, self.ChangeCount)
750         self.listcol.Bind( wx.EVT_LIST_ITEM_DESELECTED, self.ChangeCount)
751         self.butcount.Bind( wx.EVT_BUTTON, self.ChangeCount)
752         self.ChangeCount(wx.EVT_BUTTON)
753
754
755     def __set_properties(self):
756         self.choice1.SetSelection(self.paramsimi['coeff'])
757         self.choice2.SetSelection(self.paramsimi['layout'])
758         self.choice3.SetSelection(self.paramsimi['type_graph'])
759         if self.paramsimi['type_graph'] not in  [2,3] :
760             self.film.Enable(False)
761             self.slider_sphere.Enable(False)
762         else :
763             self.film.Enable(True)
764             self.slider_sphere.Enable(True)
765         self.check1.SetValue(self.paramsimi['arbremax'])
766         self.check_vlab.SetValue(self.paramsimi['label_v'])
767         self.check_elab.SetValue(self.paramsimi['label_e'])
768         self.check2.SetValue(self.paramsimi['tvprop'])
769         self.spin_tv.SetValue(self.paramsimi['coeff_tv_nb'])
770         self.check_s_size.SetValue(self.paramsimi['coeff_tv'])
771         self.spin_tvmin.SetValue(self.paramsimi['tvmin'])
772         self.spin_tvmax.SetValue(self.paramsimi['tvmax'])
773         self.check3.SetValue(self.paramsimi['coeff_te'])
774         self.spin_temin.SetValue(self.paramsimi['coeff_temin'])
775         self.spin_temax.SetValue(self.paramsimi['coeff_temax'])
776         self.check_vcex.SetValue(self.paramsimi['vcex'])
777         self.spin_vcexmin.SetValue(self.paramsimi['vcexmin'])
778         self.spin_vcexmax.SetValue(self.paramsimi['vcexmax'])
779         self.spin_cex.SetValue(self.paramsimi['cex'])
780         self.check_seuil.SetValue(self.paramsimi['seuil_ok'])
781         self.spin_seuil.SetValue(self.paramsimi['seuil'])
782         self.cols.SetColour(self.paramsimi['cols'])
783         self.cola.SetColour(self.paramsimi['cola'])
784         self.spin_width.SetValue(self.paramsimi['width'])
785         self.spin_height.SetValue(self.paramsimi['height'])
786         if 'cexfromchi' in self.paramsimi :
787             self.checkit.SetValue(self.paramsimi['cexfromchi'])
788         if 'sfromchi' in self.paramsimi :
789             self.checki.SetValue(self.paramsimi['sfromchi'])
790         if not self.paramsimi['first'] :
791             self.check_coord.SetValue(self.paramsimi['keep_coord'])
792             self.OnKeepCoords(wx.EVT_CHECKBOX)
793         if self.paramsimi.get('bystar', False) :
794             self.check_bystar.SetValue(True)
795             self.stars = self.paramsimi['stars']
796         self.slider_sphere.SetValue(self.paramsimi['alpha'])
797         self.film.SetValue(self.paramsimi['film'])
798         self.comcheck.SetValue(self.paramsimi['com'])
799         self.choix_com.SetSelection(self.paramsimi['communities'])
800         self.halo.SetValue(self.paramsimi['halo'])
801         self.check_curved.SetValue(self.paramsimi.get('edgecurved', True))
802         if self.paramsimi.get('word', False) and self.paramsimi['first'] :
803             self.choice2.SetSelection(5)
804
805     def ChangeCount(self, evt) :
806         self.textcount.SetValue('%i' % self.listcol.GetSelectedItemCount())
807
808     def OnCheck_s_size(self, evt):
809         if self.check_s_size.GetValue() :
810             if 'cexfromchi' in self.paramsimi :
811                 self.checki.SetValue(False)
812             self.check2.SetValue(False)
813             self.spin_tvmin.Enable(False)
814             self.spin_tvmax.Enable(False)
815             self.spin_tv.Enable(True)
816         else :
817             self.check2.SetValue(True)
818             self.spin_tvmin.Enable(True)
819             self.spin_tvmax.Enable(True)
820             self.spin_tv.Enable(False)
821
822     def OnCheck2(self, evt):
823         if self.check2.GetValue():
824             self.check_s_size.SetValue(False)
825             if 'cexfromchi' in self.paramsimi :
826                 self.checki.SetValue(False)
827             self.spin_tvmin.Enable(True)
828             self.spin_tvmax.Enable(True)
829             self.spin_tv.Enable(False)
830         else :
831             self.check_s_size.SetValue(True)
832             self.spin_tvmin.Enable(False)
833             self.spin_tvmax.Enable(False)
834             self.spin_tv.Enable(True)
835
836     def OnChecki(self, evt):
837         if 'sfromchi' in self.paramsimi :
838             if self.checki.GetValue() :
839                 self.check_s_size.SetValue(False)
840                 self.check2.SetValue(False)
841                 self.spin_tvmin.Enable(True)
842                 self.spin_tvmax.Enable(True)
843                 self.spin_tv.Enable(False)
844             else :
845                 self.check_s_size.SetValue(True)
846                 #self.check2.SetValue(True)
847                 self.spin_tvmin.Enable(False)
848                 self.spin_tvmax.Enable(False)
849                 self.spin_tv.Enable(True)
850
851     def OnCheckit(self,evt) :
852         if 'cexfromchi' in self.paramsimi :
853             if self.checkit.GetValue() :
854                 if self.check_vcex.GetValue() :
855                     self.check_vcex.SetValue(False)
856
857     def OnCheck_vcex(self, evt):
858         if self.check_vcex.GetValue() :
859             if 'checkit' in dir(self) :
860                 if self.checkit.GetValue() :
861                     self.checkit.SetValue(False)
862
863     def OnChangeType(self, event) :
864         if event.GetInt() != 1 :
865             self.spin_width.Enable(False)
866             self.spin_height.Enable(False)
867         else :
868             self.spin_width.Enable(True)
869             self.spin_height.Enable(True)
870         if event.GetInt() not in [2,3] :
871             self.film.Enable(False)
872             self.slider_sphere.Enable(False)
873         else :
874             self.film.Enable(True)
875             self.slider_sphere.Enable(True)
876
877     def OnKeepCoords(self, event):
878         if self.check_coord.GetValue() :
879             self.choice1.SetSelection(self.paramsimi['coeff'])
880             self.choice2.SetSelection(self.paramsimi['layout'])
881             self.check_seuil.SetValue(self.paramsimi['seuil_ok'])
882             self.spin_seuil.SetValue(self.paramsimi['seuil'])
883             self.choice1.Disable()
884             self.choice2.Disable()
885             self.check_seuil.Disable()
886             self.spin_seuil.Disable()
887             #self.check_colch.SetValue(False)
888             #self.check_colch.Disable()
889         else :
890             self.choice1.Enable(True)
891             self.choice2.Enable(True)
892             self.check_seuil.Enable(True)
893             self.spin_seuil.Enable(True)
894             #self.check_colch.Enable(True)
895
896
897 class PrepSimi :
898     def __init__(self, parent, source, parametres, pathout, actives, indices_simi, wordlist = None, selected = None) :
899         self.parametres = parametres
900         self.etline = []
901         self.dial = PrefSimi(parent, -1, self.parametres, indices_simi, wordlist = wordlist, selected = selected, actives = actives)
902         self.dial.CenterOnParent()
903         self.val = self.dial.ShowModal()
904         if self.val == wx.ID_OK :
905             if 'bystar' in self.parametres :
906                 if self.dial.check_bystar.GetValue() :
907                     variables = treat_var_mod(self.parametres['stars'])
908                     vardial = OptLexi(parent, force_chi = True)
909                     vardial.listet = self.parametres['stars']
910                     vardial.variables = [v for v in variables]
911                     for et in vardial.variables :
912                         vardial.list_box_1.Append(et)
913                     nval = vardial.ShowModal()
914                     if nval == wx.ID_OK :
915                         if vardial.choice.GetSelection() == 1 :
916                             listet = [vardial.listet[i] for i in vardial.list_box_1.GetSelections()]
917                         else :
918                             listet = variables[vardial.variables[vardial.list_box_1.GetSelections()[0]]]
919                         self.dial.Destroy()
920                         vardial.Destroy()
921                         self.etline = source.corpus.make_etline(listet)
922                         self.parametres['selectedstars'] = listet
923                         self.parametres['listet'] = self.etline
924                     else:
925                         vardial.Destroy()
926                         self.val = False
927                         self.dial.Destroy()
928             if self.val :
929                 last = self.dial.listcol.GetFirstSelected()
930                 lastl = [self.dial.listcol.GetFirstSelected()]
931                 indexes = [self.dial.listcol.getColumnText(self.dial.listcol.GetFirstSelected(),0)]
932                 while self.dial.listcol.GetNextSelected(last) != -1:
933                     last = self.dial.listcol.GetNextSelected(last)
934                     lastl.append(last)
935                     indexes.append(self.dial.listcol.getColumnText(last,0))
936                 column = [actives.index(val) for val in indexes]
937                 column.sort()
938                 with open(pathout, 'w') as f :
939                     f.write('\n'.join([`val` for val in column]))
940                 self.make_param()
941                 self.dial.Destroy()
942         else :
943             self.dial.Destroy()
944
945     def make_param(self) :
946         #self.select = self.dial.check_colch.GetValue()
947         if self.parametres.get('first', True) :
948             keep_coord = False
949         else :
950             keep_coord = self.dial.check_coord.GetValue()
951         param = {'coeff' : self.dial.choice1.GetSelection(),
952                           'layout' : self.dial.choice2.GetSelection(),
953                           'type_graph' : self.dial.choice3.GetSelection(),
954                           'arbremax' : self.dial.check1.GetValue(),
955                           'coeff_tv' : self.dial.check_s_size.GetValue(),
956                           'coeff_tv_nb' : self.dial.spin_tv.GetValue(),
957                           'tvprop' : self.dial.check2.GetValue(),
958                           'tvmin' : self.dial.spin_tvmin.GetValue(),
959                           'tvmax' : self.dial.spin_tvmax.GetValue(),
960                           'coeff_te' : self.dial.check3.GetValue(),
961                           'coeff_temin' : self.dial.spin_temin.GetValue(),
962                           'coeff_temax' : self.dial.spin_temax.GetValue(),
963                           'label_e' : self.dial.check_elab.GetValue(),
964                           'label_v' : self.dial.check_vlab.GetValue(),
965                           'vcex' : self.dial.check_vcex.GetValue(),
966                           'vcexmin' : self.dial.spin_vcexmin.GetValue(),
967                           'vcexmax' : self.dial.spin_vcexmax.GetValue(),
968                           'cex' : self.dial.spin_cex.GetValue(),
969                           'seuil_ok' : self.dial.check_seuil.GetValue(),
970                           'seuil' : self.dial.spin_seuil.GetValue(),
971                           'cols' : self.dial.cols.GetColour(),
972                           'cola' : self.dial.cola.GetColour(),
973                           'width' : self.dial.spin_width.GetValue(),
974                           'height' : self.dial.spin_height.GetValue(),
975                           'first' : False,
976                           'keep_coord' : keep_coord,
977                           'alpha' : self.dial.slider_sphere.GetValue(),
978                           'film' : self.dial.film.GetValue(),
979                           'svg' : self.dial.choix_format.GetSelection(),
980                           'com'  :self.dial.comcheck.GetValue(),
981                           'communities' : self.dial.choix_com.GetSelection(),
982                           'halo' : self.dial.halo.GetValue(),
983                           'edgecurved' : self.dial.check_curved.GetValue(),
984                           }
985         if 'cexfromchi' in self.parametres :
986             param['cexfromchi'] = self.dial.checkit.GetValue()
987         if 'sfromchi' in self.parametres :
988             param['sfromchi'] = self.dial.checki.GetValue()
989         if 'vlabcolor' in self.parametres :
990             param['vlabcolor'] = self.parametres['vlabcolor']
991         if 'check_bystar' in dir(self.dial) :
992             param['bystar'] = self.dial.check_bystar.GetValue()
993             param['stars'] = self.parametres.get('stars', 0)
994         self.parametres.update(param)
995
996 class CreateTgenDialog ( wx.Frame ):
997
998     def __init__( self, parent, lemlist, tgen = None, tgens = None ):
999         wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = _(u'Tgen Creator').decode('utf8'), pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP )
1000         self.ira = wx.GetApp().GetTopWindow()
1001         self.SetIcon(self.ira._icon)
1002         self.tgens = tgens
1003         self.edit = False
1004         self.parent = parent
1005
1006         self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1007
1008         bSizer2 = wx.BoxSizer( wx.VERTICAL )
1009
1010         namepan = wx.Panel(self, -1)
1011
1012         fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
1013         fgSizer3.SetFlexibleDirection( wx.BOTH )
1014         fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1015
1016         self.m_staticText3 = wx.StaticText( namepan, wx.ID_ANY, _(u"Name").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1017         self.m_staticText3.Wrap( -1 )
1018
1019         fgSizer3.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
1020
1021         self.m_textCtrl1 = wx.TextCtrl( namepan, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
1022         self.m_textCtrl1.SetMinSize( wx.Size( 250,-1 ) )
1023
1024         fgSizer3.Add( self.m_textCtrl1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1025
1026         namepan.SetSizer( fgSizer3 )
1027
1028         bSizer2.Add( namepan, 1, wx.EXPAND, 5 )
1029
1030         self.ip = VItemsPicker(self,-1, lemlist, _(u'Forms').decode('utf8'), _('Selection').decode('utf8'))
1031         self.ip._source.SetMinSize( wx.Size( 350, 400 ) )
1032
1033         bSizer2.Add( self.ip, 0, wx.ALL, 5 )
1034
1035         butpanel = wx.Panel(self, -1)
1036
1037         m_sdbSizer3 = wx.StdDialogButtonSizer()
1038         self.m_sdbSizer3OK = wx.Button( butpanel, wx.ID_OK )
1039         m_sdbSizer3.AddButton( self.m_sdbSizer3OK )
1040         self.m_sdbSizer3Cancel = wx.Button( butpanel, wx.ID_CANCEL )
1041         m_sdbSizer3.AddButton( self.m_sdbSizer3Cancel )
1042         m_sdbSizer3.Realize();
1043
1044         butpanel.SetSizer( m_sdbSizer3 )
1045
1046         bSizer2.Add( butpanel, 1, wx.EXPAND, 5 )
1047
1048
1049         self.SetSizer( bSizer2 )
1050         self.Layout()
1051         bSizer2.Fit( self )
1052
1053         self.Centre( wx.BOTH )
1054
1055         self.m_textCtrl1.Bind( wx.EVT_TEXT, self.OnTextEnter )
1056         self.ip.Bind(EVT_IP_SELECTION_CHANGED, self.OnSelectionChange)
1057         self.m_sdbSizer3OK.Bind(wx.EVT_BUTTON, self.OnClose)
1058         self.m_sdbSizer3Cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
1059
1060         #self.ip.SetItems(lemlist)
1061         self.m_sdbSizer3OK.Enable(False)
1062
1063         if tgen is not None :
1064             self.m_textCtrl1.SetValue(tgen)
1065             self.ip._destData = dict([[i,[word,'']] for i, word in enumerate(tgens[tgen])])
1066             self.ip._SetDestItems()
1067             #self.ip.SetSelections(tgens[tgen])
1068             self.m_sdbSizer3OK.Enable(True)
1069             self.edit = True
1070         else :
1071             self.edit = False
1072
1073     def __del__( self ):
1074         pass
1075
1076     def OnTextEnter(self, evt):
1077         if self.m_textCtrl1.GetValue() != '' and self.m_textCtrl1.GetValue() not in self.tgens and self.ip.GetSelections() != []:
1078             self.m_sdbSizer3OK.Enable(True)
1079         else :
1080             self.m_sdbSizer3OK.Enable(False)
1081         if self.m_textCtrl1.GetValue() != '' and self.ip.GetSelections() and self.edit:
1082             self.m_sdbSizer3OK.Enable(True)
1083
1084     def OnSelectionChange(self, evt):
1085         if self.ip.GetSelections() != [] and self.m_textCtrl1.GetValue() != '' and self.m_textCtrl1.GetValue() not in self.tgens :
1086             self.m_sdbSizer3OK.Enable(True)
1087         else :
1088             self.m_sdbSizer3OK.Enable(False)
1089         if self.m_textCtrl1.GetValue() != '' and self.ip.GetSelections() and self.edit:
1090             self.m_sdbSizer3OK.Enable(True)
1091
1092     def OnClose(self, evt):
1093         self.Close()
1094
1095     def OnCancel(self, evt):
1096         self.Destroy()
1097
1098 class TGenFrame ( wx.Frame ):
1099
1100     def __init__( self, parent, corpus, Tgen ):
1101         wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Tgen", pos = wx.DefaultPosition, size = wx.Size( -1, -1 ), style = wx.CLOSE_BOX|wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL|wx.STAY_ON_TOP )
1102         self.ira = wx.GetApp().GetTopWindow()
1103         self.SetIcon(self.ira._icon)
1104         self.Tgen = Tgen
1105         self.parent = parent
1106         self.corpus = corpus
1107         self.activetgen = None
1108         self.panel = wx.Panel(self, wx.ID_ANY)
1109
1110         #self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
1111
1112         panelsizer = wx.BoxSizer( wx.VERTICAL )
1113
1114         bSizer1 = wx.BoxSizer( wx.VERTICAL )
1115
1116         fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
1117         fgSizer1.SetFlexibleDirection( wx.BOTH )
1118         fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1119
1120         self.m_staticText1 = wx.StaticText( self.panel, wx.ID_ANY, u"Tgen", wx.DefaultPosition, wx.DefaultSize, 0 )
1121         self.m_staticText1.Wrap( -1 )
1122         fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1123
1124         self.m_staticText2 = wx.StaticText( self.panel, wx.ID_ANY, _(u"Content").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1125         self.m_staticText2.Wrap( -1 )
1126         fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1127
1128         tgensChoices = Tgen.tgen.keys()
1129         self.tgens = wx.ListBox( self.panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, tgensChoices, 0 )
1130         self.tgens.SetMinSize( wx.Size( 250,350 ) )
1131
1132         fgSizer1.Add( self.tgens, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
1133
1134         tgencontentChoices = []
1135         self.tgencontent = wx.ListBox( self.panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, tgencontentChoices, 0|wx.VSCROLL )
1136         self.tgencontent.SetMinSize( wx.Size( 250,350 ) )
1137
1138         fgSizer1.Add( self.tgencontent, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
1139
1140         fgSizer2 = wx.FlexGridSizer( 0, 2, 0, 0 )
1141         fgSizer2.SetFlexibleDirection( wx.BOTH )
1142         fgSizer2.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1143
1144         self.but_new = wx.Button( self.panel, wx.ID_ANY, _(u"New...").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1145         fgSizer2.Add( self.but_new, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1146
1147         self.but_del = wx.Button( self.panel, wx.ID_ANY, _(u"Delete").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1148         fgSizer2.Add( self.but_del, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1149
1150
1151         fgSizer1.Add( fgSizer2, 0, wx.EXPAND, 0 )
1152
1153         fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
1154         fgSizer3.SetFlexibleDirection( wx.BOTH )
1155         fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
1156         self.but_edit = wx.Button( self.panel, wx.ID_ANY, _(u"Edit").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1157         fgSizer3.Add( self.but_edit, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1158
1159         self.but_compute = wx.Button( self.panel, wx.ID_ANY, _(u"Compute").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
1160         fgSizer3.Add( self.but_compute, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
1161
1162         fgSizer1.Add( fgSizer3, 0, wx.EXPAND, 0 )
1163
1164         bSizer1.Add( fgSizer1, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
1165
1166
1167         m_sdbSizer2 = wx.StdDialogButtonSizer()
1168         self.m_sdbSizer2OK = wx.Button( self.panel, wx.ID_OK )
1169         m_sdbSizer2.AddButton( self.m_sdbSizer2OK )
1170         #self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL )
1171         #m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel )
1172         m_sdbSizer2.Realize();
1173
1174         bSizer1.Add( m_sdbSizer2, 0, wx.EXPAND, 5 )
1175
1176         #panelsizer.Add(bSizer1, 0, wx.EXPAND, 5 )
1177
1178         #panel.SetSizer( panelsizer )
1179         self.panel.SetSizer( bSizer1 )
1180         self.panel.Layout()
1181         bSizer1.Fit( self )
1182
1183         self.Centre( wx.BOTH )
1184
1185         # Connect Events
1186         self.tgens.Bind( wx.EVT_LISTBOX, self.GetContent )
1187         self.but_new.Bind( wx.EVT_BUTTON, self.OnNewTgen )
1188         self.but_del.Bind( wx.EVT_BUTTON, self.OnDeleteTgen )
1189         self.but_edit.Bind( wx.EVT_BUTTON, self.OnEditTgen )
1190         self.but_compute.Bind(wx.EVT_BUTTON, self.OnCompute)
1191         self.m_sdbSizer2OK.Bind( wx.EVT_BUTTON, self.OnOK )
1192
1193     def __del__( self ):
1194         pass
1195
1196     def GetContent( self, event ):
1197         tgen = event.GetString()
1198         if tgen != '' :
1199             self.tgencontent.Clear()
1200             for word in self.Tgen[tgen] :
1201                 self.tgencontent.Append(word)
1202
1203     def OnNewTgen( self, event, tgen = None ):
1204         if tgen is None :
1205             self.dial = CreateTgenDialog(self, dict([[i, [lem, self.corpus.lems[lem].freq, self.corpus.lems[lem].gram]] for i, lem in enumerate(self.corpus.lems.keys())]), tgens = self.Tgen.tgen)
1206         else :
1207             self.dial = CreateTgenDialog(self, dict([[i, [lem, self.corpus.lems[lem].freq, self.corpus.lems[lem].gram]] for i, lem in enumerate(self.corpus.lems.keys())]), tgen = tgen, tgens = self.Tgen.tgen)
1208             self.dial.ip._source.selected = dict(zip(self.Tgen.tgen[tgen], self.Tgen.tgen[tgen]))
1209             self.activetgen = tgen
1210         self.dial.Show()
1211         self.dial.Bind(wx.EVT_CLOSE, self.OnDialClose)
1212
1213     def OnDeleteTgen( self, event ):
1214         if self.tgens.GetSelection() != -1 :
1215             tgens = self.tgens.GetItems()
1216             del self.Tgen.tgen[tgens[self.tgens.GetSelection()]]
1217             self.Tgen.write()
1218             self.tgens.Clear()
1219             self.tgencontent.Clear()
1220             for val in self.Tgen.tgen :
1221                 self.tgens.Append(val)
1222         event.Skip()
1223
1224     def OnEditTgen( self, event ):
1225         if self.tgens.GetSelection() != -1 :
1226             tgens = self.tgens.GetItems()
1227             tgen = tgens[self.tgens.GetSelection()]
1228             self.activetgen = tgen
1229             self.dial = CreateTgenDialog(self, dict([[i, [lem, self.corpus.lems[lem].freq, self.corpus.lems[lem].gram]] for i, lem in enumerate(self.corpus.lems.keys())]), tgen = tgen, tgens = self.Tgen.tgen)
1230             self.dial.Bind(wx.EVT_CLOSE, self.OnDialClose)
1231             self.dial.m_textCtrl1.Enable(False)
1232             self.dial.ip._source.selected = dict(zip(self.Tgen.tgen[tgen], self.Tgen.tgen[tgen]))
1233             self.dial.Show()
1234         event.Skip()
1235
1236     def OnCompute(self, evt):
1237         ira = wx.GetApp().GetTopWindow()
1238         ira.tree.OnTgenCompute(evt)
1239
1240     def OnOK(self, evt):
1241         self.Destroy()
1242
1243     def OnDialClose(self, evt):
1244         if self.dial.edit :
1245             del self.Tgen.tgen[self.activetgen]
1246             self.tgens.Clear()
1247             self.tgencontent.Clear()
1248             for val in self.Tgen.tgen :
1249                 self.tgens.Append(val)
1250         self.Tgen.tgen[self.dial.m_textCtrl1.GetValue()] = self.dial.ip.GetSelections()
1251         self.Tgen.write()
1252         self.tgens.Append(self.dial.m_textCtrl1.GetValue())
1253         self.dial.Destroy()
1254         evt.Skip()
1255
1256 class ExportMetaTable :
1257     def __init__(self, parent, corpus):
1258         self.ira = parent
1259         dial = PrefSimpleFile(self, self.ira, **{'mask' : '*.csv', 'title': _(u"metadata table").decode('utf8')})
1260         dial.fbb.SetValue(corpus.pathout['metadata.csv'])
1261         dial.CenterOnParent()
1262         res = dial.ShowModal()
1263         if res == wx.ID_OK :
1264             fileout = dial.fbb.GetValue()
1265             dial.Destroy()
1266             corpus.export_meta_table(fileout)
1267             dlg = wx.MessageDialog(self.ira, _("Done !").decode('utf8'), _(u"Export metadata").decode('utf8'), wx.OK | wx.ICON_INFORMATION)
1268             dlg.CenterOnParent()
1269             dlg.ShowModal()
1270             dlg.Destroy()
1271         else :
1272             dial.Destroy()
1273
1274
1275 def redosimi(self, evt) :
1276     with open(self.pathout['selected.csv'],'r') as f :
1277         selected = f.read()
1278     selected = [int(val) for val in selected.splitlines()]
1279     if self.actives is None :
1280         with codecs.open(self.pathout['actives.csv'], 'r', self.parametres['encoding']) as f :
1281             self.actives = f.read()
1282         self.actives = self.actives.splitlines()#[act for act in self.actives.splitlines()]
1283     if os.path.exists(self.pathout['actives_nb.csv']) :
1284         with open(self.pathout['actives_nb.csv'], 'r') as f :
1285             act_nb = f.read()
1286             act_nb = act_nb.splitlines()
1287         dictcol = dict([[i, [self.actives[i], int(act_nb[i])]] for i, val in enumerate(self.actives)])
1288     else :
1289         dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)])
1290     #res = SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], selected = selected, dlg = True)
1291     #if res.ok :
1292     if evt is not None :
1293         prep = PrepSimi(self.ira, self, self.parametres,self.pathout['selected.csv'], self.actives, indices_simi, wordlist = dictcol, selected = selected)
1294     else :
1295         class EmptyBase(object): pass
1296         prep = EmptyBase()
1297         prep.val = wx.ID_OK
1298         prep.parametres = self.parametres
1299         order_actives = [[i, act, self.corpus.getlemeff(act)] for i, act in enumerate(self.actives)]
1300         order_actives = sorted(order_actives, key=itemgetter(2), reverse = True)
1301         with open(self.pathout['selected.csv'], 'w') as f :
1302             f.write('\n'.join([`order_actives[val][0]` for val in self.parametres['selected']]))
1303     if prep.val == wx.ID_OK or evt is None:
1304         self.parametres = prep.parametres
1305
1306         script = PrintSimiScript(self)
1307         script.make_script()
1308         pid = exec_rcode(self.ira.RPath, script.scriptout, wait = True)
1309         check_Rresult(self.ira, pid)
1310         if self.parametres['type_graph'] in [1,3] :
1311             if self.parametres['svg'] :
1312                 filename, ext = os.path.splitext(script.filename)
1313                 fileout = filename + '.svg'
1314             elif self.parametres['type_graph'] == 3 :
1315                 fileout = script.filename
1316                 parametres = {'gexffile' :  fileout,
1317                   'dirout' : os.path.dirname(fileout),
1318                   'titre': 'Le titre',
1319                   #'nodemin': self.param['txt_min'],
1320                   #'nodemax': self.param['txt_max'],
1321                   #'bargraphw' : 60*int(self.param['clnb']),
1322                   }
1323                 web = WebExport(self.ira, parametres)
1324                 fileout = web.exportsimi()
1325             else :
1326                 fileout = script.filename
1327             if os.path.exists(self.pathout['liste_graph']):
1328                 graph_simi = read_list_file(self.pathout['liste_graph'])
1329                 graph_simi.append([os.path.basename(fileout), script.txtgraph])
1330             else :
1331                 graph_simi = [[os.path.basename(fileout), script.txtgraph]]
1332             self.fileout = fileout
1333             print_liste(self.pathout['liste_graph'], graph_simi)
1334         DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
1335         if evt is not None :
1336             if self.parametres['type_graph'] in [1,3] :
1337                 if self.parametres['svg'] or self.parametres['type_graph'] == 3 :
1338                     self.graphpan.sizer_3.Add(hl.HyperLinkCtrl(self.graphpan.panel_1, -1, fileout, URL = fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1339                 else :
1340                     self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1341                 self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
1342                 self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
1343                 self.graphpan.Layout()
1344                 self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL))