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