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