...
[iramuteq] / guifunct.py
index a12d169..b3b0782 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 #Author: Pierre Ratinaud
 #Copyright (c) 2008-2011 Pierre Ratinaud
-#Lisense: GNU/GPL
+#License: GNU/GPL
 
 import wx
 import os
@@ -9,12 +9,13 @@ import sys
 from copy import copy
 import dialog
 from listlex import *
+from vitemspicker import VItemsPicker, EVT_IP_SELECTION_CHANGED, IP_SORT_CHOICES, IP_SORT_SELECTED, IP_REMOVE_FROM_CHOICES
 from functions import treat_var_mod
 
 
 def OnOpen(self, type):
         if type == "Data":
-             wildcard = u"Fichiers supportés|*.ods;*.xls;*.csv;*.txt|Openoffice Clac|*.ods|Fichier excel|*.xls|Fichier csv|*.csv|Fichier texte|*.txt|Tous les fichiers|*"
+            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|*"
         elif type == "Texte":
             wildcard = "Fichier texte|*.txt|Tous les fichiers|*"
         elif type == "Analyse":
@@ -23,7 +24,7 @@ def OnOpen(self, type):
         if defaultDir.strip() == '':
             defaultDir = self.UserConfigPath.replace('.iramuteq','')
         dlg = wx.FileDialog(
-        self, message="Choisissez un fichier", defaultDir=defaultDir,
+        self, message=_(u"Choose a file").decode('utf8'), defaultDir=defaultDir,
         defaultFile="", wildcard=wildcard, style=wx.OPEN | wx.CHANGE_DIR)
         dlg.CenterOnParent()
         if dlg.ShowModal() == wx.ID_OK :
@@ -47,42 +48,37 @@ def getfileextension(file) :
 
 def get_table_param(self, filename) :
     if getfileextension(filename) == '.csv':
-        dlg = dialog.FileOptionDialog(self, -1, u"Format du fichier", sep=True, size=(350, 200),
+        dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=True, size=(350, 200),
                      style=wx.DEFAULT_DIALOG_STYLE)
         dlg.CenterOnParent()
         val = dlg.ShowModal()
         if val == wx.ID_OK:
-            self.tableau.parametre['colsep'] = dlg.colsep[dlg.choice3.GetSelection()]
-            self.tableau.parametre['txtsep'] = dlg.txtsep[dlg.choice4.GetSelection()]
-            if self.tableau.parametre['colsep'] == 'tabulation' :
-                self.tableau.parametre['colsep'] = '\t'
-            self.tableau.parametre['filetype'] = 'csv'
-        else :
-            dlg.Destroy()
+            self.tableau.parametres['colsep'] = dlg.colsep[dlg.choice3.GetSelection()]
+            self.tableau.parametres['txtsep'] = dlg.txtsep[dlg.choice4.GetSelection()]
+            if self.tableau.parametres['colsep'] == 'tabulation' :
+                self.tableau.parametres['colsep'] = '\t'
+            self.tableau.parametres['filetype'] = 'csv'
+            self.tableau.parametres['encodage'] = dlg.le[dlg.list_encodages.GetSelection()]
     elif  getfileextension(filename) == '.xls' :
-        dlg = dialog.FileOptionDialog(self, -1, u"Format du fichier", sep=False, sheet = True, size=(350, 200),
+        dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, sheet = True, size=(350, 200),
                      style=wx.DEFAULT_DIALOG_STYLE)
         dlg.CenterOnParent()
         val = dlg.ShowModal()
         if val == wx.ID_OK:    
-            self.tableau.parametre['colsep'] = ';'
-            self.tableau.parametre['txtsep'] = '\"'
-            self.tableau.parametre['encodage'] = sys.getdefaultencoding()
-            self.tableau.parametre['sheetnb'] = dlg.spin1.GetValue()
-            self.tableau.parametre['filetype'] = 'xls'
-        else :
-            dlg.Destroy()
+            self.tableau.parametres['colsep'] = ';'
+            self.tableau.parametres['txtsep'] = '\"'
+            self.tableau.parametres['encodage'] = sys.getdefaultencoding()
+            self.tableau.parametres['sheetnb'] = dlg.spin1.GetValue()
+            self.tableau.parametres['filetype'] = 'xls'
     elif getfileextension(filename) == '.ods':
-        dlg = dialog.FileOptionDialog(self, -1, u"Format du fichier", sep=False, size=(350, 200),
+        dlg = dialog.FileOptionDialog(self, -1, _(u"File format").decode('utf8'), sep=False, size=(350, 200),
                      style=wx.DEFAULT_DIALOG_STYLE)
         dlg.CenterOnParent()
         val = dlg.ShowModal()
         if val == wx.ID_OK:          
-            self.tableau.parametre['colsep'] = ';'
-            self.tableau.parametre['txtsep'] = '\"'
-            self.tableau.parametre['filetype'] = 'ods'
-        else :
-            dlg.Destroy()
+            self.tableau.parametres['colsep'] = ';'
+            self.tableau.parametres['txtsep'] = '\"'
+            self.tableau.parametres['filetype'] = 'ods'
     else :
         val = False
     if val == wx.ID_OK:       
@@ -94,7 +90,8 @@ def get_table_param(self, filename) :
             self.tableau.firstcolisrownames = True
         else:
             self.tableau.firstcolisrownames = False
-        dlg.Destroy()
+    dlg.Destroy()
+    return val
 
 def getPage(ira) :
     if '_mgr' in dir(ira) :
@@ -119,7 +116,7 @@ class SelectColumn :
         self.ira = parent
         if dlg :
             dial = dialog.SelectColDial(self.ira)
-            listcol = ListForSpec(dial, self, dictcol, ['forme', 'eff'])
+            listcol = ListForSpec(dial, self, dictcol, ['eff'])
             dial.bSizer2.Add( listcol, 2, wx.ALL|wx.EXPAND, 5 )
             dial.m_sdbSizer2.AddButton( dial.m_sdbSizer2OK )
             dial.m_sdbSizer2.AddButton( dial.butok)
@@ -161,7 +158,7 @@ class SelectColumn :
 class PrefSimi ( wx.Dialog ):
     
     def __init__( self, parent, ID, paramsimi, indices, wordlist = None, selected = None, actives = None):
-        wx.Dialog.__init__ ( self, None, id = wx.ID_ANY, title = u"Paramètres", pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.DEFAULT_DIALOG_STYLE )
+        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 )
         self.parent = parent
         self.ira = parent
         self.paramsimi=paramsimi
@@ -171,9 +168,18 @@ class PrefSimi ( wx.Dialog ):
         
         bSizer16 = wx.BoxSizer( wx.HORIZONTAL )
         if wordlist is not None :
-            self.listcol = ListForSpec(self, self, wordlist, ['forme', 'eff'])
+            self.listcol = ListForSpec(self, self, wordlist, ['eff'])
             self.listcol.SetMinSize( wx.Size( 270,-1 ) )
-            bSizer16.Add( self.listcol, 0, wx.ALL|wx.EXPAND, 5 )
+            listsizer = wx.BoxSizer( wx.VERTICAL )
+            countsizer = wx.BoxSizer( wx.HORIZONTAL )
+            self.butcount = wx.Button(self, -1, "count")
+            self.textcount = wx.TextCtrl(self, -1, "", wx.DefaultPosition, wx.Size( 100,-1 ), wx.TE_READONLY )
+            countsizer.Add(self.butcount, 0, wx.ALL, 5)
+            countsizer.Add(self.textcount, 0, wx.ALL, 5 )
+            listsizer.Add(countsizer, 0, wx.ALL, 5)
+            listsizer.Add(self.listcol, 2, wx.ALL|wx.EXPAND, 5 )
+            #bSizer16.Add( self.listcol, 0, wx.ALL|wx.EXPAND, 5 )
+            bSizer16.Add( listsizer, 0, wx.ALL|wx.EXPAND, 5)
             if selected is None :
                 for row in xrange(self.listcol.GetItemCount()):
                     self.listcol.Select(row)
@@ -197,7 +203,7 @@ class PrefSimi ( wx.Dialog ):
         
         if not self.paramsimi['first'] :
 
-            self.m_staticText271 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Utiliser les coordonnées\nprécédentes", wx.DefaultPosition, wx.DefaultSize, 0 )
+            self.m_staticText271 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Use previous coordinates").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
             self.m_staticText271.Wrap( -1 )
             fgSizer3.Add( self.m_staticText271, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
             
@@ -210,7 +216,7 @@ class PrefSimi ( wx.Dialog ):
             self.m_staticline37 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
             fgSizer3.Add( self.m_staticline37, 0, wx.EXPAND, 5 )
         
-        self.m_staticText3 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Indice", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText3 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Score").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText3.Wrap( -1 )
         fgSizer3.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
@@ -225,7 +231,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline292 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer3.Add( self.m_staticline292, 0, wx.EXPAND, 5 )
         
-        self.m_staticText4 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Layout", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText4 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Layout").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText4.Wrap( -1 )
         fgSizer3.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
@@ -240,15 +246,15 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline295 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer3.Add( self.m_staticline295, 0, wx.EXPAND, 5 )
         
-        self.m_staticText5 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Type de graph", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText5 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Graphic type").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText5.Wrap( -1 )
         fgSizer3.Add( self.m_staticText5, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
-        choice3Choices = [ u"dynamique", u"statique", u"3D" ]
+        choice3Choices = [ u"dynamique", u"statique", u"3D", u'web2D', u"web3D" ]
         self.choice3 = wx.Choice( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choice3Choices, 0 )
         self.choice3.SetSelection( 0 )
 
-        label_format = wx.StaticText(self.m_panel2, -1, u"Format de l'image")
+        label_format = wx.StaticText(self.m_panel2, -1, _(u"Picture format").decode('utf8'))
         self.choix_format =  wx.Choice(self.m_panel2, -1, (100,50), choices = ['png', 'svg'])
         self.choix_format.SetSelection( 0 )
         hsizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -263,7 +269,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline297 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer3.Add( self.m_staticline297, 0, wx.EXPAND, 5 )
         
-        self.m_staticText8 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Arbre maximum", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText8 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Maximum tree").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText8.Wrap( -1 )
         fgSizer3.Add( self.m_staticText8, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -276,7 +282,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline299 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer3.Add( self.m_staticline299, 0, wx.EXPAND, 5 )
         
-        self.m_staticText91 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Graph à seuil", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText91 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Edges threshold").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText91.Wrap( -1 )
         fgSizer3.Add( self.m_staticText91, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -297,7 +303,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline2911 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer3.Add( self.m_staticline2911, 0, wx.EXPAND, 5 )
         
-        self.m_staticText19 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Texte sur les sommets", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText19 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Text on vertex").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText19.Wrap( -1 )
         fgSizer3.Add( self.m_staticText19, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -310,20 +316,33 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline2913 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer3.Add( self.m_staticline2913, 0, wx.EXPAND, 5 )
         
-        self.m_staticText20 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Indices sur les arêtes", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText20 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Score on edges").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText20.Wrap( -1 )
         fgSizer3.Add( self.m_staticText20, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
         self.check_elab = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
         fgSizer3.Add( self.check_elab, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
+        self.m_staticline39 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
+        fgSizer3.Add( self.m_staticline39, 0, wx.EXPAND |wx.ALL, 5 )
+        
+        self.m_staticline40 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
+        fgSizer3.Add( self.m_staticline40, 0, wx.EXPAND |wx.ALL, 5 )
+        
+        self.m_staticText321 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Edge curved"), wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText321.Wrap( -1 )
+        fgSizer3.Add( self.m_staticText321, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        self.check_curved = wx.CheckBox( self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
+        fgSizer3.Add( self.check_curved, 0, wx.ALL, 5 )        
+        
         self.m_staticline2914 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer3.Add( self.m_staticline2914, 0, wx.EXPAND, 5 )
         
         self.m_staticline2915 = wx.StaticLine( self.m_panel2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer3.Add( self.m_staticline2915, 0, wx.EXPAND, 5 )
         
-        self.m_staticText27 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Taille du texte", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText27 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Text size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText27.Wrap( -1 )
         fgSizer3.Add( self.m_staticText27, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -338,7 +357,7 @@ class PrefSimi ( wx.Dialog ):
         
         bsizer34 = wx.BoxSizer(wx.HORIZONTAL)
         
-        comtext =  wx.StaticText( self.m_panel2, wx.ID_ANY, u"Communauté", wx.DefaultPosition, wx.DefaultSize, 0 )
+        comtext =  wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Communities").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         comtext.Wrap( -1 )
         bsizer34.Add(comtext, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
 
@@ -357,7 +376,7 @@ class PrefSimi ( wx.Dialog ):
         fgSizer3.Add( sizer54, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
 
         if 'bystar' in self.paramsimi :
-            self.m_staticText40 = wx.StaticText( self.m_panel2, wx.ID_ANY, u"Sélectionner une variable", wx.DefaultPosition, wx.DefaultSize, 0 )
+            self.m_staticText40 = wx.StaticText( self.m_panel2, wx.ID_ANY, _(u"Select a variable").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
             self.m_staticText40.Wrap( -1 )
             fgSizer3.Add( self.m_staticText40, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
             
@@ -376,7 +395,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_panel2.SetSizer( bSizer18 )
         self.m_panel2.Layout()
         bSizer18.Fit( self.m_panel2 )
-        self.m_notebook1.AddPage( self.m_panel2, u"Paramètres du graph", True )
+        self.m_notebook1.AddPage( self.m_panel2, _(u"Graph settings").decode('utf8'), True )
         self.m_panel3 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
         fgSizer5 = wx.FlexGridSizer( 0, 3, 0, 0 )
         fgSizer5.SetFlexibleDirection( wx.BOTH )
@@ -386,7 +405,7 @@ class PrefSimi ( wx.Dialog ):
         fgSizer51.SetFlexibleDirection( wx.BOTH )
         fgSizer51.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
         
-        self.m_staticText6 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"Taille du graphique", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText6 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Picture size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText6.Wrap( -1 )
         fgSizer51.Add( self.m_staticText6, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
@@ -394,14 +413,14 @@ class PrefSimi ( wx.Dialog ):
         fgSizer31.SetFlexibleDirection( wx.BOTH )
         fgSizer31.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
         
-        self.m_staticText9 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"hauteur", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText9 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"height").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText9.Wrap( -1 )
         fgSizer31.Add( self.m_staticText9, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
         self.spin_height = wx.SpinCtrl( self.m_panel3, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 10, 100000, 800 )
         fgSizer31.Add( self.spin_height, 0, wx.ALL, 5 )
         
-        self.m_staticText10 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"largeur", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText10 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"width").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText10.Wrap( -1 )
         fgSizer31.Add( self.m_staticText10, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
@@ -417,7 +436,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline4 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer51.Add( self.m_staticline4, 0, wx.EXPAND, 5 )
         
-        self.m_staticText101 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"Taille des sommets \nproportionnelle à l'effectif\n(les scores sont normalisés)", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText101 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Vertex size proportional to frequency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText101.Wrap( -1 )
         fgSizer51.Add( self.m_staticText101, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
@@ -464,7 +483,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline32 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer51.Add( self.m_staticline32, 0, wx.EXPAND, 5 )
         
-        self.m_staticText1011 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"Taille du texte des sommets \nproportionnelle à l'effectif\n(les scores sont normalisés)", wx.DefaultPosition, wx.DefaultSize, 0 )
+        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 )
         self.m_staticText1011.Wrap( -1 )
         fgSizer51.Add( self.m_staticText1011, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -511,7 +530,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline322 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer51.Add( self.m_staticline322, 0, wx.EXPAND, 5 )
         
-        self.m_staticText10111 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"Largeur des arêtes\nproportionnelle à l'indice", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText10111 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Edges width proportional to score").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText10111.Wrap( -1 )
         fgSizer51.Add( self.m_staticText10111, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -550,7 +569,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline34 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer51.Add( self.m_staticline34, 0, wx.EXPAND, 5 )
         
-        self.m_staticText28 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"Gradiant de gris sur les textes en fonction \nde l'effectif (du chi2) (0=noir; 1=blanc)", wx.DefaultPosition, wx.DefaultSize, 0 )
+        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 )
         self.m_staticText28.Wrap( -1 )
         fgSizer51.Add( self.m_staticText28, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
         
@@ -599,7 +618,7 @@ class PrefSimi ( wx.Dialog ):
         
         bSizer5 = wx.BoxSizer( wx.HORIZONTAL )
         
-        self.m_staticText21 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"Couleur des sommets", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText21 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Vertex color").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText21.Wrap( -1 )
         bSizer5.Add( self.m_staticText21, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -611,7 +630,7 @@ class PrefSimi ( wx.Dialog ):
         
         bSizer6 = wx.BoxSizer( wx.HORIZONTAL )
         
-        self.m_staticText22 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"Couleur des arêtes", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText22 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Edges color").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText22.Wrap( -1 )
         bSizer6.Add( self.m_staticText22, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -627,7 +646,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline332 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer51.Add( self.m_staticline332, 0, wx.EXPAND, 5 )
         
-        self.m_staticText23 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"Taille des sommets unique", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText23 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Vertex size").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText23.Wrap( -1 )
         fgSizer51.Add( self.m_staticText23, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -648,7 +667,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline334 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer51.Add( self.m_staticline334, 0, wx.EXPAND, 5 )
         
-        self.m_staticText24 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"Transparence des sphères", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText24 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Spheres transparency").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText24.Wrap( -1 )
         fgSizer51.Add( self.m_staticText24, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -661,7 +680,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_staticline336 = wx.StaticLine( self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer51.Add( self.m_staticline336, 0, wx.EXPAND, 5 )
         
-        self.m_staticText25 = wx.StaticText( self.m_panel3, wx.ID_ANY, u"Faire un film", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText25 = wx.StaticText( self.m_panel3, wx.ID_ANY, _(u"Make a movie").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText25.Wrap( -1 )
         fgSizer51.Add( self.m_staticText25, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
         
@@ -684,7 +703,7 @@ class PrefSimi ( wx.Dialog ):
         self.m_panel3.SetSizer( fgSizer5 )
         self.m_panel3.Layout()
         fgSizer5.Fit( self.m_panel3 )
-        self.m_notebook1.AddPage( self.m_panel3, u"Paramètres graphiques", False )
+        self.m_notebook1.AddPage( self.m_panel3, _(u"Graphical settings").decode('utf8'), False )
         
         fgSizer10.Add( self.m_notebook1, 1, wx.EXPAND |wx.ALL, 5 )
         
@@ -709,16 +728,6 @@ class PrefSimi ( wx.Dialog ):
         self.__set_properties()
  
         # Connect Events
-       # if not self.paramsimi['first'] :
-       #     self.check_coord.Bind( wx.EVT_CHECKBOX, self.OnKeepCoords )
-       # self.choice3.Bind( wx.EVT_CHOICE, self.OnChangeType )
-       # self.check2.Bind( wx.EVT_CHECKBOX, self.OnCheck2 )
-       # self.checki.Bind( wx.EVT_CHECKBOX, self.OnChecki )
-       # self.check_vcex.Bind( wx.EVT_CHECKBOX, self.OnCheck_vcex )
-       # self.checkit.Bind( wx.EVT_CHECKBOX, self.OnCheckit )
-       # self.check_s_size.Bind( wx.EVT_CHECKBOX, self.OnCheck_s_size )
-        
-        # Connect Events
         if not self.paramsimi['first'] :
             self.check_coord.Bind( wx.EVT_CHECKBOX, self.OnKeepCoords )
         self.choice3.Bind( wx.EVT_CHOICE, self.OnChangeType )
@@ -729,12 +738,17 @@ class PrefSimi ( wx.Dialog ):
             self.checki.Bind( wx.EVT_CHECKBOX, self.OnChecki )
         self.check_vcex.Bind( wx.EVT_CHECKBOX, self.OnCheck_vcex )
         self.check_s_size.Bind( wx.EVT_CHECKBOX, self.OnCheck_s_size )
+        self.listcol.Bind( wx.EVT_LIST_ITEM_SELECTED, self.ChangeCount)
+        self.listcol.Bind( wx.EVT_LIST_ITEM_DESELECTED, self.ChangeCount)
+        self.butcount.Bind( wx.EVT_BUTTON, self.ChangeCount)
+        self.ChangeCount(wx.EVT_BUTTON)
+        
 
     def __set_properties(self):
         self.choice1.SetSelection(self.paramsimi['coeff'])
         self.choice2.SetSelection(self.paramsimi['layout'])
         self.choice3.SetSelection(self.paramsimi['type_graph'])
-        if self.paramsimi['type_graph'] != 2 :
+        if self.paramsimi['type_graph'] not in  [2,3] :
             self.film.Enable(False)
             self.slider_sphere.Enable(False)
         else :
@@ -776,6 +790,10 @@ class PrefSimi ( wx.Dialog ):
         self.comcheck.SetValue(self.paramsimi['com'])
         self.choix_com.SetSelection(self.paramsimi['communities'])
         self.halo.SetValue(self.paramsimi['halo'])
+        self.check_curved.SetValue(self.paramsimi.get('edgecurved', True))
+    
+    def ChangeCount(self, evt) :
+        self.textcount.SetValue('%i' % self.listcol.GetSelectedItemCount())
 
     def OnCheck_s_size(self, evt):
         if self.check_s_size.GetValue() :
@@ -839,7 +857,7 @@ class PrefSimi ( wx.Dialog ):
         else :
             self.spin_width.Enable(True)
             self.spin_height.Enable(True)
-        if event.GetInt() != 2 :
+        if event.GetInt() not in [2,3] :
             self.film.Enable(False)
             self.slider_sphere.Enable(False)
         else :
@@ -877,7 +895,7 @@ class PrepSimi :
             if 'bystar' in self.parametres :
                 if self.dial.check_bystar.GetValue() :
                     variables = treat_var_mod(self.parametres['stars'])
-                    vardial = dialog.OptLexi(parent) 
+                    vardial = dialog.OptLexi(parent, force_chi = True
                     vardial.listet = self.parametres['stars']
                     vardial.variables = [v for v in variables]
                     for et in vardial.variables :
@@ -895,19 +913,22 @@ class PrepSimi :
                         self.parametres['listet'] = self.etline
                     else:
                         vardial.Destroy()
-            last = self.dial.listcol.GetFirstSelected()
-            lastl = [self.dial.listcol.GetFirstSelected()]
-            indexes = [self.dial.listcol.getColumnText(self.dial.listcol.GetFirstSelected(),0)]
-            while self.dial.listcol.GetNextSelected(last) != -1:
-                last = self.dial.listcol.GetNextSelected(last)
-                lastl.append(last)
-                indexes.append(self.dial.listcol.getColumnText(last,0))
-            column = [actives.index(val) for val in indexes]
-            column.sort()
-            with open(pathout, 'w') as f :
-                f.write('\n'.join([`val` for val in column]))
-            self.make_param()
-            self.dial.Destroy()
+                        self.val = False
+                        self.dial.Destroy()
+            if self.val :
+                last = self.dial.listcol.GetFirstSelected()
+                lastl = [self.dial.listcol.GetFirstSelected()]
+                indexes = [self.dial.listcol.getColumnText(self.dial.listcol.GetFirstSelected(),0)]
+                while self.dial.listcol.GetNextSelected(last) != -1:
+                    last = self.dial.listcol.GetNextSelected(last)
+                    lastl.append(last)
+                    indexes.append(self.dial.listcol.getColumnText(last,0))
+                column = [actives.index(val) for val in indexes]
+                column.sort()
+                with open(pathout, 'w') as f :
+                    f.write('\n'.join([`val` for val in column]))
+                self.make_param()
+                self.dial.Destroy()
         else :
             self.dial.Destroy()
 
@@ -949,15 +970,258 @@ class PrepSimi :
                           'com'  :self.dial.comcheck.GetValue(),
                           'communities' : self.dial.choix_com.GetSelection(),
                           'halo' : self.dial.halo.GetValue(),
+                          'edgecurved' : self.dial.check_curved.GetValue(),
                           }
         if 'cexfromchi' in self.parametres :
             param['cexfromchi'] = self.dial.checkit.GetValue()
         if 'sfromchi' in self.parametres :
             param['sfromchi'] = self.dial.checki.GetValue()
         if 'vlabcolor' in self.parametres :
-           param['vlabcolor'] = self.parametres['vlabcolor']
+            param['vlabcolor'] = self.parametres['vlabcolor']
         if 'check_bystar' in dir(self.dial) :
             param['bystar'] = self.dial.check_bystar.GetValue()
             param['stars'] = self.parametres['stars']
         self.parametres.update(param)
 
+class CreateTgenDialog ( wx.Frame ):
+    
+    def __init__( self, parent, lemlist, tgen = None, tgens = None ):
+        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u'Tgen Creator', pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP )
+        
+        self.tgens = tgens
+        self.edit = False
+        self.parent = parent
+        self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
+        
+        bSizer2 = wx.BoxSizer( wx.VERTICAL )
+        
+        fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
+        fgSizer3.SetFlexibleDirection( wx.BOTH )
+        fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
+        
+        self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"Name", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText3.Wrap( -1 )
+        fgSizer3.Add( self.m_staticText3, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
+        
+        self.m_textCtrl1 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_textCtrl1.SetMinSize( wx.Size( 250,-1 ) )
+
+        
+        fgSizer3.Add( self.m_textCtrl1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        
+        bSizer2.Add( fgSizer3, 1, wx.ALIGN_CENTER_HORIZONTAL, 5 )
+        
+        self.ip = VItemsPicker(self,-1, lemlist,'Forms', 'Selected')
+        self.ip._source.SetMinSize( wx.Size( 250, 400 ) )
+        
+        bSizer2.Add( self.ip, 0, wx.ALL, 5 )
+        
+        m_sdbSizer3 = wx.StdDialogButtonSizer()
+        self.m_sdbSizer3OK = wx.Button( self, wx.ID_OK )
+        m_sdbSizer3.AddButton( self.m_sdbSizer3OK )
+        self.m_sdbSizer3Cancel = wx.Button( self, wx.ID_CANCEL )
+        m_sdbSizer3.AddButton( self.m_sdbSizer3Cancel )
+        m_sdbSizer3.Realize();
+        
+        bSizer2.Add( m_sdbSizer3, 1, wx.EXPAND, 5 )
+        
+        
+        self.SetSizer( bSizer2 )
+        self.Layout()
+        bSizer2.Fit( self )
+        
+        self.Centre( wx.BOTH )
+        
+        self.m_textCtrl1.Bind( wx.EVT_TEXT, self.OnTextEnter )
+        self.ip.Bind(EVT_IP_SELECTION_CHANGED, self.OnSelectionChange)
+        self.m_sdbSizer3OK.Bind(wx.EVT_BUTTON, self.OnClose)
+        self.m_sdbSizer3Cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
+        
+        #self.ip.SetItems(lemlist)
+        self.m_sdbSizer3OK.Enable(False)
+        
+        if tgen is not None :
+            self.m_textCtrl1.SetValue(tgen)
+            self.ip._destData = dict([[i,[word,'']] for i, word in enumerate(tgens[tgen])])
+            self.ip._SetDestItems()
+            #self.ip.SetSelections(tgens[tgen])
+            self.m_sdbSizer3OK.Enable(True)
+            self.edit = True
+        else :
+            self.edit = False
+    
+    def __del__( self ):
+        pass
+    
+    def OnTextEnter(self, evt):
+        if self.m_textCtrl1.GetValue() != '' and self.m_textCtrl1.GetValue() not in self.tgens and self.ip.GetSelections() != []:
+            self.m_sdbSizer3OK.Enable(True)
+        else :
+            self.m_sdbSizer3OK.Enable(False)
+        if self.m_textCtrl1.GetValue() != '' and self.ip.GetSelections() and self.edit:
+            self.m_sdbSizer3OK.Enable(True)
+    
+    def OnSelectionChange(self, evt):
+        if self.ip.GetSelections() != [] and self.m_textCtrl1.GetValue() != '' and self.m_textCtrl1.GetValue() not in self.tgens :
+            self.m_sdbSizer3OK.Enable(True)
+        else :
+            self.m_sdbSizer3OK.Enable(False)
+        if self.m_textCtrl1.GetValue() != '' and self.ip.GetSelections() and self.edit:
+            self.m_sdbSizer3OK.Enable(True)
+    
+    def OnClose(self, evt):
+        self.Close()
+    
+    def OnCancel(self, evt):
+        self.Destroy()
+
+class TGenFrame ( wx.Frame ):
+    
+    def __init__( self, parent, corpus, Tgen ):
+        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Tgen", pos = wx.DefaultPosition, size = wx.Size( 600,434 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP )
+        
+        self.Tgen = Tgen
+        self.parent = parent
+        self.corpus = corpus
+        self.activetgen = None
+        
+        self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
+        
+        bSizer1 = wx.BoxSizer( wx.VERTICAL )
+        
+        fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 )
+        fgSizer1.SetFlexibleDirection( wx.BOTH )
+        fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
+        
+        self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Tgen", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText1.Wrap( -1 )
+        fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"Content", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText2.Wrap( -1 )
+        fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        tgensChoices = Tgen.tgen.keys()
+        self.tgens = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, tgensChoices, 0 )
+        self.tgens.SetMinSize( wx.Size( 200,250 ) )
+        
+        fgSizer1.Add( self.tgens, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        tgencontentChoices = []
+        self.tgencontent = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, tgencontentChoices, 0|wx.VSCROLL )
+        self.tgencontent.SetMinSize( wx.Size( 200,250 ) )
+        
+        fgSizer1.Add( self.tgencontent, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        fgSizer2 = wx.FlexGridSizer( 0, 2, 0, 0 )
+        fgSizer2.SetFlexibleDirection( wx.BOTH )
+        fgSizer2.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
+        
+        self.but_new = wx.Button( self, wx.ID_ANY, u"New...", wx.DefaultPosition, wx.DefaultSize, 0 )
+        fgSizer2.Add( self.but_new, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        self.but_del = wx.Button( self, wx.ID_ANY, u"Delete", wx.DefaultPosition, wx.DefaultSize, 0 )
+        fgSizer2.Add( self.but_del, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        
+        fgSizer1.Add( fgSizer2, 0, wx.EXPAND, 5 )
+        
+        fgSizer3 = wx.FlexGridSizer( 0, 2, 0, 0 )
+        fgSizer3.SetFlexibleDirection( wx.BOTH )
+        fgSizer3.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
+        self.but_edit = wx.Button( self, wx.ID_ANY, u"Edit", wx.DefaultPosition, wx.DefaultSize, 0 )
+        fgSizer3.Add( self.but_edit, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        self.but_compute = wx.Button( self, wx.ID_ANY, u"Compute", wx.DefaultPosition, wx.DefaultSize, 0 )
+        fgSizer3.Add( self.but_compute, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )      
+
+        fgSizer1.Add( fgSizer3, 0, wx.EXPAND, 5 )
+
+        bSizer1.Add( fgSizer1, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        m_sdbSizer2 = wx.StdDialogButtonSizer()
+        self.m_sdbSizer2OK = wx.Button( self, wx.ID_OK )
+        m_sdbSizer2.AddButton( self.m_sdbSizer2OK )
+        #self.m_sdbSizer2Cancel = wx.Button( self, wx.ID_CANCEL )
+        #m_sdbSizer2.AddButton( self.m_sdbSizer2Cancel )
+        m_sdbSizer2.Realize();
+        
+        bSizer1.Add( m_sdbSizer2, 0, wx.EXPAND, 5 )
+        
+        
+        self.SetSizer( bSizer1 )
+        self.Layout()
+        
+        self.Centre( wx.BOTH )
+        
+        # Connect Events
+        self.tgens.Bind( wx.EVT_LISTBOX, self.GetContent )
+        self.but_new.Bind( wx.EVT_BUTTON, self.OnNewTgen )
+        self.but_del.Bind( wx.EVT_BUTTON, self.OnDeleteTgen )
+        self.but_edit.Bind( wx.EVT_BUTTON, self.OnEditTgen )
+        self.but_compute.Bind(wx.EVT_BUTTON, self.OnCompute)
+        self.m_sdbSizer2OK.Bind( wx.EVT_BUTTON, self.OnOK )
+        
+    def __del__( self ):
+        pass
+
+    def GetContent( self, event ):
+        tgen = event.GetString()
+        if tgen != '' :
+            self.tgencontent.Clear()
+            for word in self.Tgen[tgen] :
+                self.tgencontent.Append(word)
+    
+    def OnNewTgen( self, event, tgen = None ):
+        if tgen is None :
+            self.dial = CreateTgenDialog(self, dict([[i, [lem, self.corpus.lems[lem].freq]] for i, lem in enumerate(self.corpus.lems.keys())]), tgens = self.Tgen.tgen)
+        else :
+            self.dial = CreateTgenDialog(self, dict([[i, [lem, self.corpus.lems[lem].freq]] for i, lem in enumerate(self.corpus.lems.keys())]), tgen = tgen, tgens = self.Tgen.tgen)
+            self.dial.ip._source.selected = dict(zip(self.Tgen.tgen[tgen], self.Tgen.tgen[tgen]))
+            self.activetgen = tgen
+        self.dial.Show()
+        self.dial.Bind(wx.EVT_CLOSE, self.OnDialClose)
+    
+    def OnDeleteTgen( self, event ):
+        if self.tgens.GetSelection() != -1 :
+            tgens = self.tgens.GetItems()
+            del self.Tgen.tgen[tgens[self.tgens.GetSelection()]]
+            self.Tgen.write()
+            self.tgens.Clear()
+            self.tgencontent.Clear()
+            for val in self.Tgen.tgen :
+                self.tgens.Append(val)
+        event.Skip()
+    
+    def OnEditTgen( self, event ):
+        if self.tgens.GetSelection() != -1 :
+            tgens = self.tgens.GetItems()
+            tgen = tgens[self.tgens.GetSelection()]
+            self.activetgen = tgen
+            self.dial = CreateTgenDialog(self, dict([[i, [lem, self.corpus.lems[lem].freq]] for i, lem in enumerate(self.corpus.lems.keys())]), tgen = tgen, tgens = self.Tgen.tgen)
+            self.dial.Bind(wx.EVT_CLOSE, self.OnDialClose)
+            self.dial.m_textCtrl1.Enable(False)
+            self.dial.ip._source.selected = dict(zip(self.Tgen.tgen[tgen], self.Tgen.tgen[tgen]))
+            self.dial.Show()
+        event.Skip()
+    
+    def OnCompute(self, evt):
+        ira = wx.GetApp().GetTopWindow()
+        ira.tree.OnTgenCompute(evt)
+    
+    def OnOK(self, evt):
+        self.Destroy()
+    
+    def OnDialClose(self, evt):
+        if self.dial.edit :
+            del self.Tgen.tgen[self.activetgen]
+            self.tgens.Clear()
+            self.tgencontent.Clear()
+            for val in self.Tgen.tgen :
+                self.tgens.Append(val)
+        self.Tgen.tgen[self.dial.m_textCtrl1.GetValue()] = self.dial.ip.GetSelections()
+        self.Tgen.write()
+        self.tgens.Append(self.dial.m_textCtrl1.GetValue())
+        self.dial.Destroy()
+        evt.Skip()